Skip to content

Commit

Permalink
docs: update useColorMode and useColorStyle pages
Browse files Browse the repository at this point in the history
  • Loading branch information
cheton committed Oct 14, 2023
1 parent ebf9964 commit 669b906
Show file tree
Hide file tree
Showing 5 changed files with 91 additions and 81 deletions.
2 changes: 1 addition & 1 deletion packages/react-docs/components/CodeBlock.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ const CodeBlock = ({
}, []);
const language = React.isValidElement(children)
? ensureString(children.props.className).replace(/language-/, '')
: null;
: '';

noInline = boolean(noInline);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,4 @@ Returns an array with the current color mode and a function to change the color

## Demos

{render('./color-mode')}
{render('./useColorMode')}
88 changes: 88 additions & 0 deletions packages/react-docs/pages/components/color-style/useColorStyle.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
import {
Box,
Divider,
Stack,
useColorMode,
useColorStyle,
} from '@tonic-ui/react';
import React from 'react';

const App = () => {
const [colorMode] = useColorMode();
const [colorStyle, setColorStyle] = useColorStyle({ colorMode });
const invertedPrimaryColor = {
dark: 'black:primary',
light: 'white:primary',
}[colorMode];

return (
<Stack spacing="4x" fontFamily="mono">
Background
<Box
sx={{
'> *': {
px: '3x',
py: '2x',
},
}}
>
<Box backgroundColor={colorStyle.background.primary}>
colorStyle.background.primary
</Box>
<Box backgroundColor={colorStyle.background.secondary}>
colorStyle.background.secondary
</Box>
<Box backgroundColor={colorStyle.background.tertiary}>
colorStyle.background.tertiary
</Box>
<Box backgroundColor={colorStyle.background.inverted} color={invertedPrimaryColor}>
colorStyle.background.inverted
</Box>
<Box backgroundColor={colorStyle.background.highlighted}>
colorStyle.background.highlighted
</Box>
<Box backgroundColor={colorStyle.background.selected}>
colorStyle.background.selected
</Box>
</Box>
<Divider />
<Box
sx={{
'> *': {
px: '3x',
},
'> *:not(:last-child)': {
pb: '2x',
},
}}
>
<Box color={colorStyle.color.primary}>
colorStyle.color.primary
</Box>
<Box color={colorStyle.color.secondary}>
colorStyle.color.secondary
</Box>
<Box color={colorStyle.color.tertiary}>
colorStyle.color.tertiary
</Box>
<Box color={colorStyle.color.disabled}>
colorStyle.color.disabled
</Box>
<Box color={colorStyle.color.success}>
colorStyle.color.success
</Box>
<Box color={colorStyle.color.info}>
colorStyle.color.info
</Box>
<Box color={colorStyle.color.warning}>
colorStyle.color.warning
</Box>
<Box color={colorStyle.color.error}>
colorStyle.color.error
</Box>
</Box>
</Stack>
);
};

export default App;
Original file line number Diff line number Diff line change
Expand Up @@ -42,82 +42,4 @@ Returns an array with the color style object and a function to set the color sty

## Demos

```jsx
function Example() {
const [colorMode] = useColorMode();
const [colorStyle, setColorStyle] = useColorStyle({ colorMode });
const invertedPrimaryColor = {
dark: 'black:primary',
light: 'white:primary',
}[colorMode];

return (
<Stack spacing="4x" fontFamily="mono">
Background
<Box
sx={{
'> *': {
px: '3x',
py: '2x',
},
}}
>
<Box backgroundColor={colorStyle.background.primary}>
colorStyle.background.primary
</Box>
<Box backgroundColor={colorStyle.background.secondary}>
colorStyle.background.secondary
</Box>
<Box backgroundColor={colorStyle.background.tertiary}>
colorStyle.background.tertiary
</Box>
<Box backgroundColor={colorStyle.background.inverted} color={invertedPrimaryColor}>
colorStyle.background.inverted
</Box>
<Box backgroundColor={colorStyle.background.highlighted}>
colorStyle.background.highlighted
</Box>
<Box backgroundColor={colorStyle.background.selected}>
colorStyle.background.selected
</Box>
</Box>
<Divider />
<Box
sx={{
'> *': {
px: '3x',
},
'> *:not(:last-child)': {
pb: '2x',
},
}}
>
<Box color={colorStyle.color.primary}>
colorStyle.color.primary
</Box>
<Box color={colorStyle.color.secondary}>
colorStyle.color.secondary
</Box>
<Box color={colorStyle.color.tertiary}>
colorStyle.color.tertiary
</Box>
<Box color={colorStyle.color.disabled}>
colorStyle.color.disabled
</Box>
<Box color={colorStyle.color.success}>
colorStyle.color.success
</Box>
<Box color={colorStyle.color.info}>
colorStyle.color.info
</Box>
<Box color={colorStyle.color.warning}>
colorStyle.color.warning
</Box>
<Box color={colorStyle.color.error}>
colorStyle.color.error
</Box>
</Box>
</Stack>
);
}
```
{render('./useColorStyle')}

0 comments on commit 669b906

Please sign in to comment.