-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add
InvertedMode
component for color mode inversion (#759)
* feat: add `InvertedMode` component for color mode inversion * docs: update icons in sidebar routes * docs: update color mode and color style sections * docs: update tooltip.mdx * feat: add inverted background to color style * docs: update useColorMode.mdx * test: update tests for color mode and color style
- Loading branch information
Showing
20 changed files
with
418 additions
and
137 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
packages/react-docs/pages/components/color-mode/darkmode.mdx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
# DarkMode | ||
|
||
The `DarkMode` component enables you to render its children in dark mode. It will override current color mode and set the color scheme to `dark`. | ||
|
||
## Import | ||
|
||
```js | ||
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> | ||
); | ||
``` | ||
|
||
## Props | ||
|
||
### DarkMode | ||
|
||
| Name | Type | Default | Description | | ||
| :--- | :--- | :------ | :---------- | | ||
| children | ReactNode | | | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61 changes: 61 additions & 0 deletions
61
packages/react-docs/pages/components/color-mode/invertedmode.mdx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
# InvertedMode | ||
|
||
The `InvertedMode` component is used to invert the color mode of its children. | ||
|
||
## Import | ||
|
||
```js | ||
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> | ||
); | ||
``` | ||
|
||
### 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> | ||
``` | ||
|
||
## Props | ||
|
||
### InvertedMode | ||
|
||
| Name | Type | Default | Description | | ||
| :--- | :--- | :------ | :---------- | | ||
| children | ReactNode | | | |
43 changes: 43 additions & 0 deletions
43
packages/react-docs/pages/components/color-mode/lightmode.mdx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
# LightMode | ||
|
||
The `LightMode` component enables you to render its children in light mode. It will override current color mode and set the color scheme to `light`. | ||
|
||
## Import | ||
|
||
```js | ||
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> | ||
); | ||
``` | ||
|
||
## Props | ||
|
||
### LightMode | ||
|
||
| Name | Type | Default | Description | | ||
| :--- | :--- | :------ | :---------- | | ||
| children | ReactNode | | | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.