Skip to content
This repository was archived by the owner on May 21, 2025. It is now read-only.

Commit f40a167

Browse files
committed
added yalc due to facebook/react#14257
1 parent b29976a commit f40a167

File tree

8 files changed

+61
-9
lines changed

8 files changed

+61
-9
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,5 @@ src/*.js
2626
src/*.js.map
2727
*.tgz
2828
dist
29+
.yalc
30+
yalc.lock

examples/typescript-app/package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"@types/node": "^12.0.0",
1212
"@types/react": "^17.0.0",
1313
"@types/react-dom": "^17.0.0",
14-
"create-styles": "file:../../dist",
14+
"create-styles": "file:.yalc/create-styles",
1515
"react": "^17.0.2",
1616
"react-dom": "^17.0.2",
1717
"react-scripts": "4.0.3",
@@ -22,7 +22,9 @@
2222
"start": "react-scripts start",
2323
"build": "react-scripts build",
2424
"test": "react-scripts test",
25-
"eject": "react-scripts eject"
25+
"eject": "react-scripts eject",
26+
"install:dev:create-styles": "yalc add create-styles && yarn install",
27+
"install:prod:create-styles": "yarn add create-styles && yarn install"
2628
},
2729
"browserslist": {
2830
"production": [

examples/typescript-app/src/ui/screens/Home/Home.styles.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { css } from '@emotion/react';
22
import { createStyles } from '../../../theme';
3+
import { keyframes } from 'create-styles';
34

45
export const useStyles = createStyles<HomeStyles>()((theme, params) => ({
56
root: css`
@@ -15,6 +16,22 @@ export const useStyles = createStyles<HomeStyles>()((theme, params) => ({
1516
fontSize: '100px',
1617
color: params.toggled ? 'black' : theme.colors.green,
1718
},
19+
rotate: {
20+
'& g': {
21+
opacity: 0,
22+
animation: `${keyframes`
23+
60%, 100% {
24+
opacity: 0;
25+
}
26+
0% {
27+
opacity: 0;
28+
}
29+
40% {
30+
opacity: 1;
31+
}
32+
`} 3.5s infinite ease-in-out`,
33+
},
34+
},
1835
}));
1936

2037
export default useStyles;

examples/typescript-app/src/ui/screens/Home/Home.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,13 @@ import { css } from '@emotion/react';
55

66
const Home: React.FC = () => {
77
const [toggled, setToggled] = React.useState(false);
8-
const { classes } = useStyles({ toggled });
8+
const { classes, cx } = useStyles({ toggled });
99

1010
return (
1111
<div className={classes.root}>
12-
<p className={classes.text}>Hello world</p>
12+
<p className={cx({ [classes.rotate]: toggled }, classes.text)}>
13+
Hello world
14+
</p>
1315
<Button
1416
color={'#4f5be8'}
1517
radius={20}

examples/typescript-app/yarn.lock

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3377,6 +3377,11 @@ cliui@^6.0.0:
33773377
strip-ansi "^6.0.0"
33783378
wrap-ansi "^6.2.0"
33793379

3380+
clsx@^1.1.1:
3381+
version "1.1.1"
3382+
resolved "https://registry.yarnpkg.com/clsx/-/clsx-1.1.1.tgz#98b3134f9abbdf23b2663491ace13c5c03a73188"
3383+
integrity sha512-6/bPho624p3S2pMyvP5kKBPXnI3ufHLObBFCfgx+LkeR5lg2XYy2hqZqUf45ypD8COn2bhgGJSUE+l5dhNBieA==
3384+
33803385
co@^4.6.0:
33813386
version "4.6.0"
33823387
resolved "https://registry.yarnpkg.com/co/-/co-4.6.0.tgz#6ea6bdf3d853ae54ccb8e47bfa0bf3f9031fb184"
@@ -3690,8 +3695,10 @@ create-hmac@^1.1.0, create-hmac@^1.1.4, create-hmac@^1.1.7:
36903695
safe-buffer "^5.0.1"
36913696
sha.js "^2.4.8"
36923697

3693-
"create-styles@file:../../dist":
3694-
version "0.0.0"
3698+
"create-styles@file:.yalc/create-styles":
3699+
version "0.0.3"
3700+
dependencies:
3701+
clsx "^1.1.1"
36953702

36963703
[email protected], cross-spawn@^7.0.0, cross-spawn@^7.0.2:
36973704
version "7.0.3"

package.json

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,14 @@
1919
"types": "dist/index.d.ts",
2020
"scripts": {
2121
"build": "shx rm -rf dist && rollup --c config/rollup/rollup.config.js",
22+
"dev:publish": "yalc publish",
23+
"dev:push": "yalc push",
24+
"watch:push": "tsc-watch --onSuccess \"yarn run dev:push\"",
2225
"prepare": "yarn run build",
2326
"pack": "npm pack",
24-
"test": "jest"
27+
"test": "jest",
28+
"lint": "eslint src/**/*",
29+
"install:clean": "shx rm -rf dist && shx rm -rf node_modules && yarn install"
2530
},
2631
"dependencies": {
2732
"clsx": "^1.1.1"
@@ -31,8 +36,7 @@
3136
"@emotion/react": "^11.5.0",
3237
"@emotion/serialize": "^1.0.2",
3338
"@emotion/utils": "^1.0.0",
34-
"react": ">=16.8.0",
35-
"react-dom": ">=16.8.0"
39+
"react": ">=16.8.0"
3640
},
3741
"devDependencies": {
3842
"@babel/cli": "^7.16.0",

src/GlobalStyles.tsx

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import React from 'react';
2+
import * as ReactEmotion from '@emotion/react';
3+
import { StyleItem } from './createStyles';
4+
5+
// https://emotion.sh/docs/globals#gatsby-focus-wrapper
6+
const GlobalStyles: React.FC<GlobalStylesProps> = (props) => {
7+
const { styles } = props;
8+
9+
return <ReactEmotion.Global styles={ReactEmotion.css(styles)} />;
10+
};
11+
12+
export default GlobalStyles;
13+
14+
type GlobalStylesProps = { styles: StyleItem };

src/index.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,9 @@ import { makeCreateStyles } from './createStyles';
22

33
export * from './createStyles';
44
export { CacheContext } from './cache';
5+
export * from './GlobalStyles';
6+
7+
// Reexport from @emotion/react
8+
export { keyframes } from '@emotion/react';
59

610
export default makeCreateStyles;

0 commit comments

Comments
 (0)