Skip to content

Commit f054a76

Browse files
committed
Migrate demo app to CRA
1 parent c3e2c3d commit f054a76

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+11190
-3310
lines changed

.eslintignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
public
1+
app
22
dist

.github/workflows/ci.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ jobs:
4141
run: yarn lint
4242
- name: Run test
4343
run: yarn test:cov
44-
- name: Run build
45-
run: yarn build:dist
44+
- name: Run build package
45+
run: yarn build:prod
4646

4747
- name: Coveralls GitHub Action
4848
uses: coverallsapp/github-action@master
@@ -69,13 +69,13 @@ jobs:
6969
${{ runner.os }}-yarn-
7070
- name: Install dependencies
7171
run: yarn install --frozen-lockfile
72-
- name: Run build
72+
- name: Run build demo app
7373
run: yarn build:demo
7474

7575
- name: Netlify GitHub Action
7676
uses: netlify/actions/cli@master
7777
with:
78-
args: deploy --prod --dir=public
78+
args: deploy --prod --dir=app/build
7979
env:
8080
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }}
8181
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}

.gitignore

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
*.log
33

44
node_modules
5-
demo/.dev
6-
public
75
dist
86
coverage
9-
.size-snapshot.json
7+
.size-snapshot.json

.prettierignore

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
*.log
2-
demo/.dev
3-
public
2+
app
43
dist
54
coverage
6-
.size-snapshot.json
5+
.size-snapshot.json

.stylelintrc.js

Lines changed: 0 additions & 4 deletions
This file was deleted.

CONTRIBUTING.md

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,30 +13,38 @@ Please note we have a [code of conduct](CODE_OF_CONDUCT.md), please follow it in
1313
3. If you’ve fixed a bug or added code that should be tested.
1414
4. Ensure the test suite passes by running `yarn test`.
1515
5. Update the [README.md](README.md) with details of changes to the interface.
16-
6. Update the [demo app](demo) if needed.
16+
6. Update the [demo app](app/src) if needed.
1717
7. Make sure your code lints by running `yarn lint`.
1818

1919
## Development Workflow
2020

21-
After cloning USE-WEB-ANIMATIONS, run `yarn` to fetch its dependencies. Then, you can run several commands:
21+
You can test new features or debug an issue by the way that I'm using.
2222

23-
- `yarn dev` runs the [demo app](demo) as your playground at `localhost:10001`. Support live reloading.
23+
1. Run `yarn link-pkg` to link the package into the [app directory](app).
24+
2. Run `yarn start` to create an `ESM` build and type definition file by `rollup` watch mode.
25+
3. Access the [app directory](app).
26+
4. In the **app directory**, run `yarn link-pkg` to link with the package then run `yarn start` to start development.
27+
5. Try something cool via the [demo app](app/src).
28+
29+
## Development Workflow
30+
31+
There're several useful commands that you can use during the development:
32+
33+
- `yarn link-pkg` links the package into the [app directory](app). You can develop or debug it via the [demo app](app/src).
34+
- `yarn start` creates a `dist` folder with an `ESM` build and type definition file by `rollup` watch mode.
2435
- `yarn lint:code` lints all `.js` and `.tsx?` files.
2536
- `yarn lint:type` runs the [TypeScript](https://www.typescriptlang.org) type-checks.
26-
- `yarn lint:style` lints all `.css` and `.tsx?` (for [Emotion](https://emotion.sh)) files.
2737
- `yarn lint:format` formats all files except the file list of `.prettierignore`.
28-
- `yarn lint` lints `code`, `type`, `style`, and `format`.
38+
- `yarn lint` lints `code`, `type`, and `format`.
2939
- `yarn test` runs the complete test suite.
3040
- `yarn test:watch` runs an interactive test watcher (helpful in development).
3141
- `yarn test:cov` runs the complete test suite with coverage report.
32-
- `yarn build:demo` creates a `public` folder with all the static files.
33-
- `yarn build:dist` creates a `dist` folder with package builds (`CJS` & `ESM`) and type definition file. You can test the package locally via [yarn link](https://yarnpkg.com/lang/en/docs/cli/link).
34-
- `yarn build` creates both `public` and `dist`.
35-
- `yarn clean:dev` deletes the `demo/.dev` build folder.
36-
- `yarn clean:demo` deletes the `public` build folder.
42+
- `yarn build:dev` creates a `dist` folder with an `ESM` build and type definition file for development.
43+
- `yarn build:prod` creates a `dist` folder with package builds (`CJS` & `ESM`) and type definition file. You can test the package locally via [yarn link](https://yarnpkg.com/lang/en/docs/cli/link).
3744
- `yarn clean:dist` deletes the `dist` build folder.
45+
- `yarn clean:size` deletes the `.size-snapshot.json` file.
3846
- `yarn clean:cov` deletes the `coverage` report folder.
39-
- `yarn clean` deletes all the build/coverage folders.
47+
- `yarn clean` deletes build, test, and size relevant files.
4048

4149
## Style Guide
4250

app/.eslintignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
build

app/.eslintrc.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
module.exports = {
2+
extends: ["react-app", "welly"],
3+
rules: {
4+
"react/react-in-jsx-scope": "off",
5+
},
6+
};

app/.gitignore

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2+
3+
# dependencies
4+
/node_modules
5+
/.pnp
6+
.pnp.js
7+
8+
# testing
9+
/coverage
10+
11+
# production
12+
/build
13+
14+
# misc
15+
.DS_Store
16+
.env.local
17+
.env.development.local
18+
.env.test.local
19+
.env.production.local
20+
21+
npm-debug.log*
22+
yarn-debug.log*
23+
yarn-error.log*

app/.stylelintrc.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
module.exports = {
2+
extends: ["stylelint-config-standard", "stylelint-config-prettier"],
3+
customSyntax: "postcss-scss",
4+
rules: {
5+
"at-rule-no-unknown": [
6+
true,
7+
{
8+
ignoreAtRules: ["function", "if", "each", "include", "mixin"],
9+
},
10+
],
11+
},
12+
ignoreFiles: ["build/**/*.css"],
13+
};

app/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# App
2+
3+
🍿 The demo app of USE-WEB-ANIMATIONS.

app/package.json

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
{
2+
"name": "demo-app",
3+
"private": true,
4+
"scripts": {
5+
"link-pkg": "yarn link '@wellyshen/use-web-animations'",
6+
"start": "react-scripts start",
7+
"build": "react-scripts build",
8+
"lint": "run-s lint:*",
9+
"lint:code": "eslint --fix . --ext .js,.ts,.tsx",
10+
"lint:type": "tsc",
11+
"lint:style": "stylelint --fix \"**/*.{css,scss}\"",
12+
"lint:format": "prettier -w . -u --loglevel silent",
13+
"clean": "rimraf build",
14+
"eject": "react-scripts eject"
15+
},
16+
"browserslist": {
17+
"production": [
18+
">0.2%",
19+
"not dead",
20+
"not op_mini all"
21+
],
22+
"development": [
23+
"last 1 chrome version",
24+
"last 1 firefox version",
25+
"last 1 safari version"
26+
]
27+
},
28+
"dependencies": {
29+
"@types/node": "^16.11.33",
30+
"@types/react": "^18.0.8",
31+
"@types/react-dom": "^18.0.3",
32+
"@wellyshen/use-web-animations": "latest",
33+
"normalize.css": "^8.0.1",
34+
"react": "^18.1.0",
35+
"react-dom": "^18.1.0",
36+
"react-scripts": "5.0.1",
37+
"sass": "^1.51.0",
38+
"typescript": "^4.6.4"
39+
},
40+
"devDependencies": {
41+
"eslint-config-welly": "^1.13.0",
42+
"npm-run-all": "^4.1.5",
43+
"postcss-scss": "^4.0.4",
44+
"prettier": "^2.6.2",
45+
"rimraf": "^3.0.2",
46+
"stylelint": "^14.8.2",
47+
"stylelint-config-prettier": "^9.0.3",
48+
"stylelint-config-standard": "^25.0.0"
49+
}
50+
}

app/public/favicon.ico

3.78 KB
Binary file not shown.

app/public/index.html

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="utf-8" />
5+
<link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
6+
<meta name="viewport" content="width=device-width, initial-scale=1" />
7+
<meta name="theme-color" content="#000000" />
8+
<meta
9+
name="description"
10+
content="React hook for highly-performant and manipulable animations using Web Animations API."
11+
/>
12+
<link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />
13+
<!--
14+
manifest.json provides metadata used when your web app is installed on a
15+
user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
16+
-->
17+
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
18+
<!--
19+
Notice the use of %PUBLIC_URL% in the tags above.
20+
It will be replaced with the URL of the `public` folder during the build.
21+
Only files inside the `public` folder can be referenced from the HTML.
22+
23+
Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
24+
work correctly both with client-side routing and a non-root public URL.
25+
Learn how to configure a non-root public URL by running `npm run build`.
26+
-->
27+
<title>USE-WEB-ANIMATIONS</title>
28+
<meta property="og:title" content="USE-WEB-ANIMATIONS" />
29+
<meta property="og:type" content="website" />
30+
<meta
31+
property="og:image"
32+
content="https://use-web-animations.netlify.app/og_image.png"
33+
/>
34+
<meta
35+
property="og:description"
36+
content="React hook for highly-performant and manipulable animations using Web Animations API."
37+
/>
38+
<meta property="og:url" content="https://use-web-animations.netlify.app" />
39+
<meta name="twitter:card" content="summary_large_image" />
40+
<meta name="twitter:site" content="@use-web-animations" />
41+
<meta name="twitter:creator" content="@wellyshen" />
42+
43+
<link
44+
href="https://fonts.googleapis.com/css2?family=Bungee+Shade&family=Bowlby+One+SC&family=Roboto:wght@400;700&display=swap"
45+
rel="stylesheet"
46+
/>
47+
</head>
48+
<body>
49+
<noscript>You need to enable JavaScript to run this app.</noscript>
50+
<div id="root"></div>
51+
<!--
52+
This HTML file is a template.
53+
If you open it directly in the browser, you will see an empty page.
54+
55+
You can add webfonts, meta tags, or analytics to this file.
56+
The build step will place the bundled scripts into the <body> tag.
57+
58+
To begin the development, run `npm start` or `yarn start`.
59+
To create a production bundle, use `npm run build` or `yarn build`.
60+
-->
61+
</body>
62+
</html>
File renamed without changes.
File renamed without changes.

demo/static/site_assets/manifest.json renamed to app/public/manifest.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
2-
"short_name": "USE-WEB-ANIMATIONS",
3-
"name": "USE-WEB-ANIMATIONS",
2+
"short_name": "REACT COOL IMG",
3+
"name": "REACT COOL IMG",
44
"icons": [
55
{
66
"src": "favicon.ico",
File renamed without changes.

app/public/robots.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# https://www.robotstxt.org/robotstxt.html
2+
User-agent: *
3+
Disallow:

demo/Animations/index.tsx renamed to app/src/Animations/index.tsx

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
1-
import { FC, ChangeEvent } from "react";
1+
import type { FC, ChangeEvent } from "react";
2+
import useWebAnimations, * as animations from "@wellyshen/use-web-animations";
23

3-
import useWebAnimations from "../../src";
4-
import * as animations from "../../src/animations";
5-
import { container as sharedContainer, title, subtitle } from "../theme";
6-
import { container, link, target, select } from "./styles";
4+
import styles from "./styles.module.scss";
75

86
const Animations: FC = () => {
97
const { bounce } = animations;
@@ -13,14 +11,13 @@ const Animations: FC = () => {
1311
});
1412

1513
const play = () => {
16-
// @ts-expect-error
17-
getAnimation().play();
14+
getAnimation()?.play();
1815
};
1916

2017
const handleChangeSelect = ({
2118
currentTarget,
2219
}: ChangeEvent<HTMLSelectElement>) => {
23-
// @ts-expect-error
20+
// @ts-ignore
2421
const { keyframes, animationOptions } = animations[currentTarget.value];
2522

2623
animate({
@@ -30,24 +27,24 @@ const Animations: FC = () => {
3027
};
3128

3229
return (
33-
<div css={[sharedContainer, container]}>
34-
<h2 id="animations" css={title}>
30+
<div className={styles.container}>
31+
<h2 id="animations" className={styles.title}>
3532
ANIMATIONS
3633
</h2>
37-
<p css={subtitle}>
34+
<p className={styles.subtitle}>
3835
A collection of animations for Web Animations API, based on{" "}
3936
<a
40-
css={link}
37+
className={styles.link}
4138
href="https://animate.style"
4239
target="_blank"
4340
rel="noreferrer"
4441
>
45-
Animate.css
42+
Animate.className
4643
</a>
4744
.
4845
</p>
4946
<div
50-
css={target}
47+
className={styles.target}
5148
ref={ref}
5249
onClick={play}
5350
onKeyPress={play}
@@ -58,7 +55,7 @@ const Animations: FC = () => {
5855
🍿
5956
</span>
6057
</div>
61-
<select css={select} onChange={handleChangeSelect}>
58+
<select className={styles.select} onChange={handleChangeSelect}>
6259
<optgroup label="Attention Seekers">
6360
<option value="bounce">bounce</option>
6461
<option value="flash">flash</option>

0 commit comments

Comments
 (0)