Skip to content

Commit

Permalink
Merge pull request #5 from bennodev19/develop
Browse files Browse the repository at this point in the history
Update stylesheet API
  • Loading branch information
bennobuilder authored Nov 19, 2021
2 parents b85f903 + 42a7958 commit ba5cfb9
Show file tree
Hide file tree
Showing 20 changed files with 741 additions and 480 deletions.
379 changes: 261 additions & 118 deletions README.md

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions examples/typescript-app/src/theme.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { makeCreateStyles } from 'create-styles';
import { createStyleSheet } from 'create-styles';

export type Theme = {
colors: {
Expand Down Expand Up @@ -26,6 +26,6 @@ export const useTheme = (): Theme => {
};
};

export const createStyles = makeCreateStyles(useTheme);
export const styleSheet = createStyleSheet({ theme: useTheme });

export default createStyles;
export default styleSheet;
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import createStyles from '../../../theme';
import { ExtractStylesType } from 'create-styles';
import styleSheet from '../../../theme';
import { UseStylesExtractStylesType } from 'create-styles';

const useStyles = createStyles<ButtonStyles>()(
({ theme, params: { color, radius } }) => ({
const useStyles = styleSheet
.withParams<ButtonStyles>()
.create(({ theme, params: { color, radius } }) => ({
root: {
color: theme.colors.white,
backgroundColor: color,
Expand All @@ -13,8 +14,7 @@ const useStyles = createStyles<ButtonStyles>()(
cursor: 'pointer',
height: 100,
},
})
);
}));

export default useStyles;

Expand All @@ -23,4 +23,4 @@ type ButtonStyles = {
radius: number;
};

export type ExtractedStylesType = ExtractStylesType<typeof useStyles>;
export type ExtractedStylesType = UseStylesExtractStylesType<typeof useStyles>;
10 changes: 5 additions & 5 deletions examples/typescript-app/src/ui/screens/Home/Home.styles.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { css, keyframes } from '@emotion/react';
import { createStyles } from '../../../theme';
import { styleSheet } from '../../../theme';

const bounce = keyframes`
from, 20%, 53%, 80%, to {
Expand All @@ -19,8 +19,9 @@ const bounce = keyframes`
}
`;

export const useStyles = createStyles<HomeStyles>()(
({ theme, params, createRef, assignRef }) => {
export const useStyles = styleSheet
.withParams<HomeStyles>()
.create(({ theme, params, createRef, assignRef }) => {
// create reference
const text = createRef('text');

Expand Down Expand Up @@ -58,8 +59,7 @@ export const useStyles = createStyles<HomeStyles>()(
animation: ${bounce} 1s ease infinite;
`,
};
}
);
});

export default useStyles;

Expand Down
2 changes: 1 addition & 1 deletion examples/typescript-app/src/ui/screens/Home/Home.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { css } from '@emotion/react';

const Home: React.FC = () => {
const [toggled, setToggled] = React.useState(false);
const { classes, cx } = useStyles({ toggled });
const { classes, cx } = useStyles({ toggled }, { name: 'Home' });

return (
<div className={classes.root}>
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "create-styles",
"version": "0.0.5",
"description": "Css-in-Js styles engine, based on Emotion",
"name": "dynamic-styles",
"version": "0.0.6",
"description": "Dynamic Css-in-Js styles engine, based on Emotion",
"license": "MIT",
"homepage": "https://github.com/bennodev19/emotion-create-styles",
"author": "BennoDev <[email protected]>",
Expand Down
33 changes: 0 additions & 33 deletions src/cache/getCache.ts

This file was deleted.

5 changes: 0 additions & 5 deletions src/cache/index.ts

This file was deleted.

File renamed without changes.
2 changes: 1 addition & 1 deletion src/components/GlobalStyles.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';
import * as ReactEmotion from '@emotion/react';
import { StyleItem } from '../createStyles';
import { StyleItem } from '../css/StyleSheet';

// https://emotion.sh/docs/globals#gatsby-focus-wrapper
const GlobalStyles: React.FC<GlobalStylesProps> = (props) => {
Expand Down
3 changes: 3 additions & 0 deletions src/components/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export * from './CacheProvider';
export * from './GlobalStyles';
export * from './NormalizeCSS';
1 change: 0 additions & 1 deletion src/config.ts

This file was deleted.

219 changes: 0 additions & 219 deletions src/createStyles.ts

This file was deleted.

Loading

0 comments on commit ba5cfb9

Please sign in to comment.