-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #534 from pixiv/toshusai/add-story-docs
Feat: add docs for storybook
- Loading branch information
Showing
9 changed files
with
117 additions
and
6 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { Meta, Story } from '@storybook/addon-docs' | ||
|
||
<Meta title="DOCS/README" /> | ||
|
||
![charcoal logo](https://charcoal-web.pixiv.design/charcoal-ogp.jpg) | ||
|
||
# Charcoal | ||
|
||
## charcoal について | ||
|
||
charcoal は [ピクシブ株式会社](https://www.pixiv.co.jp/) | ||
のデザインシステムです。ここでは特に、Web フロントエンドの実装に用いる npm パッケージ集のことを言います。 | ||
オープンソースであり、ソースコードは全て[Apache License 2.0 ](https://www.apache.org/licenses/LICENSE-2.0) のもと [GitHub リポジトリ](https://github.com/pixiv/charcoal) として公開されています。 | ||
|
||
## charcoal という名前 | ||
|
||
「charcoal(木炭)」とはデッサンの道具であり、線を引く、表現の基礎となる素材の一つです。 | ||
また創作物を主役とするサービスの基盤として、それ自体は色を持たないモノクロの素材である、というニュアンスも含みます。 | ||
|
||
## 設計思想 | ||
|
||
charcoal はいわゆるコンポーネント実装も含みますが、それ以外にも UI の実装に必要なパッケージを多数収録しています。 | ||
charcoal の設計思想は「定数」「ユーティリティ」「コンポーネント」の三層構造として説明されます。 |
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,44 @@ | ||
import { Meta, Story } from '@storybook/addon-docs' | ||
|
||
<Meta title="styled/README" /> | ||
|
||
# Install | ||
|
||
## yarn | ||
|
||
``` | ||
yarn add @charcoal-ui/styled | ||
``` | ||
|
||
# Usage | ||
|
||
```tsx | ||
import { FC, ReactNode } from 'react' | ||
import { light, dark } from '@charcoal-ui/theme' | ||
import { | ||
TokenInjector, | ||
useTheme, | ||
useThemeSetter, | ||
themeSelector, | ||
prefersColorScheme, | ||
} from '@charcoal-ui/styled' | ||
|
||
const ExampleProvider: FC<{ children: ReactNode }> = ({ children }) => { | ||
const [theme] = useTheme() | ||
useThemeSetter() | ||
return ( | ||
<ThemeProvider theme={theme === 'dark' ? dark : light}> | ||
<TokenInjector | ||
theme={{ | ||
':root': light, | ||
[themeSelector('light')]: light, | ||
[themeSelector('dark')]: dark, | ||
[prefersColorScheme('dark')]: dark, | ||
}} | ||
background="background1" | ||
/> | ||
{children} | ||
</ThemeProvider> | ||
) | ||
} | ||
``` |
2 changes: 1 addition & 1 deletion
2
...d/src/__snapshots__/index.story.storyshot → ...snapshots__/addThemeUtils.story.storyshot
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { Canvas, Meta } from '@storybook/blocks' | ||
|
||
<Meta title="styled/createTheme" /> | ||
|
||
# `createTheme`(`deprecated`) | ||
|
||
The helper function for styled-components has a performance issue. | ||
|
||
```tsx | ||
import styled from 'styled-components' | ||
import { createTheme } from '@charcoal-ui/styled' | ||
|
||
export const theme = createTheme(styled) | ||
|
||
export const Preview = () => { | ||
return ( | ||
<> | ||
<Ex>brand</Ex> | ||
<Ex2>hover or press me</Ex2> | ||
</> | ||
) | ||
} | ||
const Ex = styled.p` | ||
${theme((o) => [o.bg.brand, o.font.text5, o.width.px(104), o.height.px(104)])} | ||
` | ||
|
||
const Ex2 = styled.p` | ||
${theme((o) => [ | ||
o.bg.success.hover.press, | ||
o.font.text5, | ||
o.width.px(104), | ||
o.height.px(104), | ||
])} | ||
` | ||
``` |
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