Skip to content

Commit

Permalink
chore: add react-component-tsx example.
Browse files Browse the repository at this point in the history
  • Loading branch information
jaywcjlove committed Oct 14, 2023
1 parent 7bd60b8 commit 305cc2a
Show file tree
Hide file tree
Showing 32 changed files with 455 additions and 16 deletions.
13 changes: 13 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@ jobs:
working-directory: example/react-router
run: npm run build

- name: example @template/react-router-ts
working-directory: example/react-router-ts
run: npm run build

- name: example @template/rematch-tsx
working-directory: example/rematch-tsx
run: npm run build
Expand Down Expand Up @@ -180,6 +184,10 @@ jobs:
working-directory: example/react-router
run: npm run build

- name: example @template/react-router-ts
working-directory: example/react-router-ts
run: npm run build

- name: example @template/rematch-tsx
working-directory: example/rematch-tsx
run: npm run build
Expand Down Expand Up @@ -247,6 +255,11 @@ jobs:
working-directory: example/react-router
- run: cp -rp example/react-router/react-router.zip ./zip

- name: Compress react-router-ts Example.
run: zip -r -y react-router-ts.zip . -x "node_modules/*" -x "build/*" -x "dist/*" -x "coverage/*" -x ".eslintcache" -x "sandbox.config.json"
working-directory: example/react-router-ts
- run: cp -rp example/react-router-ts/react-router-ts.zip ./zip

- name: Compress rematch-tsx Example.
run: zip -r -y rematch-tsx.zip . -x "node_modules/*" -x "build/*" -x "dist/*" -x "coverage/*" -x ".eslintcache" -x "sandbox.config.json"
working-directory: example/rematch-tsx
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ jobs:
working-directory: example/react-router
run: npm run build

- name: example @template/react-router-ts
working-directory: example/react-router-ts
run: npm run build

- name: example @template/rematch-tsx
working-directory: example/rematch-tsx
run: npm run build
Expand Down
2 changes: 1 addition & 1 deletion example/basic/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"dependencies": {
"react": "~18.2.0",
"react-dom": "~18.2.0",
"web-vitals": "^2.1.2"
"web-vitals": "^2.1.4"
},
"devDependencies": {
"kkt": "^7.5.3"
Expand Down
4 changes: 2 additions & 2 deletions example/docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
"dependencies": {
"react": "~18.2.0",
"react-dom": "~18.2.0",
"react-router-dom": "^6.8.2",
"web-vitals": "^2.1.2"
"react-router-dom": "^6.16.0",
"web-vitals": "^2.1.4"
},
"devDependencies": {
"@uiw/doc": "^4.21.23",
Expand Down
4 changes: 2 additions & 2 deletions example/electron/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
"license": "MIT",
"devDependencies": {
"@kkt/less-modules": "^7.5.3",
"@types/react": "~18.2.0",
"@types/react-dom": "~18.2.0",
"@types/react": "^18.2.28",
"@types/react-dom": "^18.2.13",
"electron": "~26.2.0",
"kkt": "^7.5.3",
"tsbb": "^4.1.5"
Expand Down
4 changes: 2 additions & 2 deletions example/react-component-tsx/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@
"@kkt/less-modules": "^7.5.3",
"@kkt/raw-modules": "^7.5.3",
"@kkt/scope-plugin-options": "^7.5.3",
"@types/react": "~18.2.0",
"@types/react-dom": "~18.2.0",
"@types/react": "^18.2.28",
"@types/react-dom": "^18.2.13",
"@types/react-test-renderer": "~18.0.0",
"compile-less-cli": "~1.9.0",
"husky": "~8.0.0",
Expand Down
23 changes: 23 additions & 0 deletions example/react-router-ts/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies
/node_modules
/.pnp
.pnp.js

# testing
/coverage

# production
/build

# misc
.DS_Store
.env.local
.env.development.local
.env.test.local
.env.production.local

npm-debug.log*
yarn-debug.log*
yarn-error.log*
31 changes: 31 additions & 0 deletions example/react-router-ts/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
Basic Example for react-router-ts
===

Use [`react-router`](https://github.com/remix-run/react-router) for the project.

## Quick Start

```bash
$ npx create-kkt my-app -e react-router-ts
cd my-app
npm install
```

**development**

Runs the project in development mode.

```bash
npm run start
```

**production**

Builds the app for production to the build folder.

```bash
npm run build
```

The build is minified and the filenames include the hashes.
Your app is ready to be deployed!
45 changes: 45 additions & 0 deletions example/react-router-ts/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
{
"name": "@template/react-router-ts",
"version": "7.5.3",
"private": true,
"dependencies": {
"react": "~18.2.0",
"react-dom": "~18.2.0",
"react-router-dom": "^6.16.0",
"web-vitals": "^2.1.4"
},
"devDependencies": {
"@testing-library/jest-dom": "^6.0.0",
"@testing-library/react": "^14.0.0",
"@testing-library/user-event": "^14.0.0",
"@types/jest": "^27.5.2",
"@types/node": "^16.18.58",
"@types/react": "^18.2.28",
"@types/react-dom": "^18.2.13",
"kkt": "^7.5.3"
},
"scripts": {
"start": "kkt start",
"build": "kkt build",
"test": "kkt test --env=jsdom",
"coverage": "kkt test --env=jsdom --coverage"
},
"eslintConfig": {
"extends": [
"react-app",
"react-app/jest"
]
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
}
}
Binary file added example/react-router-ts/public/favicon.ico
Binary file not shown.
43 changes: 43 additions & 0 deletions example/react-router-ts/public/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="theme-color" content="#000000" />
<meta
name="description"
content="Web site created using KKT"
/>
<link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />
<!--
manifest.json provides metadata used when your web app is installed on a
user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
-->
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
<!--
Notice the use of %PUBLIC_URL% in the tags above.
It will be replaced with the URL of the `public` folder during the build.
Only files inside the `public` folder can be referenced from the HTML.
Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
work correctly both with client-side routing and a non-root public URL.
Learn how to configure a non-root public URL by running `npm run build`.
-->
<title>React App</title>
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
<div id="root"></div>
<!--
This HTML file is a template.
If you open it directly in the browser, you will see an empty page.
You can add webfonts, meta tags, or analytics to this file.
The build step will place the bundled scripts into the <body> tag.
To begin the development, run `npm start` or `yarn start`.
To create a production bundle, use `npm run build` or `yarn build`.
-->
</body>
</html>
Binary file added example/react-router-ts/public/logo192.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added example/react-router-ts/public/logo512.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
25 changes: 25 additions & 0 deletions example/react-router-ts/public/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"short_name": "React App",
"name": "Create React App Sample",
"icons": [
{
"src": "favicon.ico",
"sizes": "64x64 32x32 24x24 16x16",
"type": "image/x-icon"
},
{
"src": "logo192.png",
"type": "image/png",
"sizes": "192x192"
},
{
"src": "logo512.png",
"type": "image/png",
"sizes": "512x512"
}
],
"start_url": ".",
"display": "standalone",
"theme_color": "#000000",
"background_color": "#ffffff"
}
3 changes: 3 additions & 0 deletions example/react-router-ts/public/robots.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# https://www.robotstxt.org/robotstxt.html
User-agent: *
Disallow:
20 changes: 20 additions & 0 deletions example/react-router-ts/src/comps/ErrorPage.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import React, { forwardRef, PropsWithoutRef } from 'react';
import { useRouteError } from 'react-router-dom';

export interface ErrorPageProps extends React.HTMLAttributes<HTMLDivElement> {}

export const ErrorPage = forwardRef<HTMLDivElement, PropsWithoutRef<ErrorPageProps>>(
({ children, ...htmlProps }, ref) => {
const error = useRouteError() as Response;
return (
<div id="error-page" {...htmlProps} ref={ref}>
<h1>Oops!</h1>
<p>Sorry, an unexpected error occurred.</p>
<p>
{error?.status && <em>{error?.status}</em>}
{error?.statusText && <i>{decodeURI(error?.statusText || '')}</i>}
</p>
</div>
);
},
);
113 changes: 113 additions & 0 deletions example/react-router-ts/src/comps/Fallback.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
import React from 'react';

export interface FallbackProps extends React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement> {}
const defaultStyle: React.CSSProperties = {
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
gap: '1rem',
left: 0,
right: 0,
top: 0,
bottom: 0,
position: 'absolute',
zIndex: 9999,
};

export const Fallback = ({ children, style, ...other }: FallbackProps) => (
<div {...other} style={{ ...defaultStyle, ...style }}>
<svg width="25" height="30" viewBox="0 0 135 140" fill="currentColor">
<rect y="10" width="15" height="120" rx="6">
<animate
attributeName="height"
begin="0.5s"
dur="1s"
values="120;110;100;90;80;70;60;50;40;140;120"
calcMode="linear"
repeatCount="indefinite"
/>
<animate
attributeName="y"
begin="0.5s"
dur="1s"
values="10;15;20;25;30;35;40;45;50;0;10"
calcMode="linear"
repeatCount="indefinite"
/>
</rect>
<rect x="30" y="10" width="15" height="120" rx="6">
<animate
attributeName="height"
begin="0.25s"
dur="1s"
values="120;110;100;90;80;70;60;50;40;140;120"
calcMode="linear"
repeatCount="indefinite"
/>
<animate
attributeName="y"
begin="0.25s"
dur="1s"
values="10;15;20;25;30;35;40;45;50;0;10"
calcMode="linear"
repeatCount="indefinite"
/>
</rect>
<rect x="60" width="15" height="140" rx="6">
<animate
attributeName="height"
begin="0s"
dur="1s"
values="120;110;100;90;80;70;60;50;40;140;120"
calcMode="linear"
repeatCount="indefinite"
/>
<animate
attributeName="y"
begin="0s"
dur="1s"
values="10;15;20;25;30;35;40;45;50;0;10"
calcMode="linear"
repeatCount="indefinite"
/>
</rect>
<rect x="90" y="10" width="15" height="120" rx="6">
<animate
attributeName="height"
begin="0.25s"
dur="1s"
values="120;110;100;90;80;70;60;50;40;140;120"
calcMode="linear"
repeatCount="indefinite"
/>
<animate
attributeName="y"
begin="0.25s"
dur="1s"
values="10;15;20;25;30;35;40;45;50;0;10"
calcMode="linear"
repeatCount="indefinite"
/>
</rect>
<rect x="120" y="10" width="15" height="120" rx="6">
<animate
attributeName="height"
begin="0.5s"
dur="1s"
values="120;110;100;90;80;70;60;50;40;140;120"
calcMode="linear"
repeatCount="indefinite"
/>
<animate
attributeName="y"
begin="0.5s"
dur="1s"
values="10;15;20;25;30;35;40;45;50;0;10"
calcMode="linear"
repeatCount="indefinite"
/>
</rect>
</svg>
<div>{children || 'Loading...'}</div>
</div>
);
Loading

0 comments on commit 305cc2a

Please sign in to comment.