Skip to content

Commit

Permalink
docs: update color-mode and color-style pages
Browse files Browse the repository at this point in the history
  • Loading branch information
cheton committed Oct 14, 2023
1 parent 669b906 commit 6bb3400
Show file tree
Hide file tree
Showing 8 changed files with 126 additions and 83 deletions.
32 changes: 32 additions & 0 deletions packages/react-docs/pages/components/color-mode/dark-mode.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import {
Box,
DarkMode,
Text,
useColorMode,
useColorStyle,
} from '@tonic-ui/react';
import React from 'react';

const Component = () => {
const [colorMode] = useColorMode();
const [colorStyle] = useColorStyle({ colorMode });

return (
<Box
backgroundColor={colorStyle.background.secondary}
color={colorStyle.color.primary}
>
<Text px="4x" py="3x">
The color mode is set to {colorMode}
</Text>
</Box>
);
};

const App = () => (
<DarkMode>
<Component />
</DarkMode>
);

export default App;
Original file line number Diff line number Diff line change
Expand Up @@ -10,29 +10,7 @@ import { DarkMode } from '@tonic-ui/react';

## Usage

```jsx noInline
function Example() {
const [colorMode] = useColorMode();
const [colorStyle] = useColorStyle({ colorMode });

return (
<Box
backgroundColor={colorStyle.background.secondary}
color={colorStyle.color.primary}
>
<Text px="4x" py="3x">
The color mode is set to {colorMode}
</Text>
</Box>
);
}

render(
<DarkMode>
<Example />
</DarkMode>
);
```
{render('./dark-mode')}

## Props

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import {
Divider,
InvertedMode,
Text,
Tooltip,
} from '@tonic-ui/react';
import React from 'react';

const App = () => {
return (
<Tooltip
label={(
<InvertedMode width={80} py="1x">
<Text>Title</Text>
<Divider my="2x" />
<Text>Content</Text>
</InvertedMode>
)}
>
<Text display="inline-block">Hover Me</Text>
</Tooltip>
);
};

export default App;
32 changes: 32 additions & 0 deletions packages/react-docs/pages/components/color-mode/inverted-mode.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import {
Box,
InvertedMode,
Text,
useColorMode,
useColorStyle,
} from '@tonic-ui/react';
import React from 'react';

const Component = () => {
const [colorMode] = useColorMode();
const [colorStyle] = useColorStyle({ colorMode });

return (
<Box
backgroundColor={colorStyle.background.secondary}
color={colorStyle.color.primary}
>
<Text px="4x" py="3x">
The current color mode is inverted to {colorMode} mode
</Text>
</Box>
);
};

const App = () => (
<InvertedMode>
<Component />
</InvertedMode>
);

export default App;
Original file line number Diff line number Diff line change
Expand Up @@ -10,47 +10,13 @@ import { InvertedMode } from '@tonic-ui/react';

## Usage

```jsx noInline
function Example() {
const [colorMode] = useColorMode();
const [colorStyle] = useColorStyle({ colorMode });

return (
<Box
backgroundColor={colorStyle.background.secondary}
color={colorStyle.color.primary}
>
<Text px="4x" py="3x">
The current color mode is inverted to {colorMode} mode
</Text>
</Box>
);
}

render(
<InvertedMode>
<Example />
</InvetedMode>
);
```
{render('./inverted-mode')}

### Rendering tooltip label

The `InvertedMode` component is useful when you want to render a tooltip label in inverted mode.

```jsx
<Tooltip
label={(
<InvertedMode width={80} py="1x">
<Text>Title</Text>
<Divider my="2x" />
<Text>Content</Text>
</InvertedMode>
)}
>
<Text display="inline-block">Hover Me</Text>
</Tooltip>
```
{render('./inverted-mode-tooltip')}

## Props

Expand Down
32 changes: 32 additions & 0 deletions packages/react-docs/pages/components/color-mode/light-mode.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import {
Box,
LightMode,
Text,
useColorMode,
useColorStyle,
} from '@tonic-ui/react';
import React from 'react';

const Component = () => {
const [colorMode] = useColorMode();
const [colorStyle] = useColorStyle({ colorMode });

return (
<Box
backgroundColor={colorStyle.background.secondary}
color={colorStyle.color.primary}
>
<Text px="4x" py="3x">
The color mode is set to {colorMode}
</Text>
</Box>
);
};

const App = () => (
<LightMode>
<Component />
</LightMode>
);

export default App;
Original file line number Diff line number Diff line change
Expand Up @@ -10,29 +10,7 @@ import { LightMode } from '@tonic-ui/react';

## Usage

```jsx noInline
function Example() {
const [colorMode] = useColorMode();
const [colorStyle] = useColorStyle({ colorMode });

return (
<Box
backgroundColor={colorStyle.background.secondary}
color={colorStyle.color.primary}
>
<Text px="4x" py="3x">
The color mode is set to {colorMode}
</Text>
</Box>
);
}

render(
<LightMode>
<Example />
</LightMode>
);
```
{render('./light-mode')}

## Props

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import React from 'react';

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

0 comments on commit 6bb3400

Please sign in to comment.