@charcoal-ui/styled 3.11.0 → 3.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{index.story.d.ts → addThemeUtils.story.d.ts} +1 -1
- package/dist/addThemeUtils.story.d.ts.map +1 -0
- package/package.json +5 -5
- package/src/README.mdx +44 -0
- package/src/__snapshots__/{index.story.storyshot → addThemeUtils.story.storyshot} +1 -1
- package/src/{themeUtils.mdx → addThemeUtils.mdx} +2 -2
- package/src/{index.story.tsx → addThemeUtils.story.tsx} +1 -1
- package/src/createTheme.mdx +35 -0
- package/src/index.test.tsx +1 -1
- package/dist/index.story.d.ts.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"addThemeUtils.story.d.ts","sourceRoot":"","sources":["../src/addThemeUtils.story.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAW,MAAM,eAAe,CAAA;;;;AAEhD,wBAEC;AAED,OAAO,QAAQ,mBAAmB,CAAC;IACjC,UAAiB,YAAa,SAAQ,OAAO;KAAG;CACjD;AAED,eAAO,MAAM,OAAO,mBAiCnB,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@charcoal-ui/styled",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.12.0",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"types": "./dist/index.d.ts",
|
|
6
6
|
"main": "./dist/index.cjs.js",
|
|
@@ -34,9 +34,9 @@
|
|
|
34
34
|
"typescript": "^4.9.5"
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@charcoal-ui/foundation": "^3.
|
|
38
|
-
"@charcoal-ui/theme": "^3.
|
|
39
|
-
"@charcoal-ui/utils": "^3.
|
|
37
|
+
"@charcoal-ui/foundation": "^3.12.0",
|
|
38
|
+
"@charcoal-ui/theme": "^3.12.0",
|
|
39
|
+
"@charcoal-ui/utils": "^3.12.0",
|
|
40
40
|
"warning": "^4.0.3"
|
|
41
41
|
},
|
|
42
42
|
"peerDependencies": {
|
|
@@ -55,5 +55,5 @@
|
|
|
55
55
|
"url": "https://github.com/pixiv/charcoal.git",
|
|
56
56
|
"directory": "packages/styled"
|
|
57
57
|
},
|
|
58
|
-
"gitHead": "
|
|
58
|
+
"gitHead": "817a068941a10855b03ca57f380412e54f8bdf4b"
|
|
59
59
|
}
|
package/src/README.mdx
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { Meta, Story } from '@storybook/addon-docs'
|
|
2
|
+
|
|
3
|
+
<Meta title="styled/README" />
|
|
4
|
+
|
|
5
|
+
# Install
|
|
6
|
+
|
|
7
|
+
## yarn
|
|
8
|
+
|
|
9
|
+
```
|
|
10
|
+
yarn add @charcoal-ui/styled
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
# Usage
|
|
14
|
+
|
|
15
|
+
```tsx
|
|
16
|
+
import { FC, ReactNode } from 'react'
|
|
17
|
+
import { light, dark } from '@charcoal-ui/theme'
|
|
18
|
+
import {
|
|
19
|
+
TokenInjector,
|
|
20
|
+
useTheme,
|
|
21
|
+
useThemeSetter,
|
|
22
|
+
themeSelector,
|
|
23
|
+
prefersColorScheme,
|
|
24
|
+
} from '@charcoal-ui/styled'
|
|
25
|
+
|
|
26
|
+
const ExampleProvider: FC<{ children: ReactNode }> = ({ children }) => {
|
|
27
|
+
const [theme] = useTheme()
|
|
28
|
+
useThemeSetter()
|
|
29
|
+
return (
|
|
30
|
+
<ThemeProvider theme={theme === 'dark' ? dark : light}>
|
|
31
|
+
<TokenInjector
|
|
32
|
+
theme={{
|
|
33
|
+
':root': light,
|
|
34
|
+
[themeSelector('light')]: light,
|
|
35
|
+
[themeSelector('dark')]: dark,
|
|
36
|
+
[prefersColorScheme('dark')]: dark,
|
|
37
|
+
}}
|
|
38
|
+
background="background1"
|
|
39
|
+
/>
|
|
40
|
+
{children}
|
|
41
|
+
</ThemeProvider>
|
|
42
|
+
)
|
|
43
|
+
}
|
|
44
|
+
```
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Canvas, Meta } from '@storybook/blocks'
|
|
2
2
|
|
|
3
|
-
import * as
|
|
3
|
+
import * as Stories from './addThemeUtils.story'
|
|
4
4
|
|
|
5
5
|
<Meta title="styled/addThemeUtils" />
|
|
6
6
|
|
|
@@ -41,4 +41,4 @@ const AssertiveRingDiv = styled.div`
|
|
|
41
41
|
|
|
42
42
|
### Example
|
|
43
43
|
|
|
44
|
-
<Canvas of={
|
|
44
|
+
<Canvas of={Stories.Example} />
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { Canvas, Meta } from '@storybook/blocks'
|
|
2
|
+
|
|
3
|
+
<Meta title="styled/createTheme" />
|
|
4
|
+
|
|
5
|
+
# `createTheme`(`deprecated`)
|
|
6
|
+
|
|
7
|
+
The helper function for styled-components has a performance issue.
|
|
8
|
+
|
|
9
|
+
```tsx
|
|
10
|
+
import styled from 'styled-components'
|
|
11
|
+
import { createTheme } from '@charcoal-ui/styled'
|
|
12
|
+
|
|
13
|
+
export const theme = createTheme(styled)
|
|
14
|
+
|
|
15
|
+
export const Preview = () => {
|
|
16
|
+
return (
|
|
17
|
+
<>
|
|
18
|
+
<Ex>brand</Ex>
|
|
19
|
+
<Ex2>hover or press me</Ex2>
|
|
20
|
+
</>
|
|
21
|
+
)
|
|
22
|
+
}
|
|
23
|
+
const Ex = styled.p`
|
|
24
|
+
${theme((o) => [o.bg.brand, o.font.text5, o.width.px(104), o.height.px(104)])}
|
|
25
|
+
`
|
|
26
|
+
|
|
27
|
+
const Ex2 = styled.p`
|
|
28
|
+
${theme((o) => [
|
|
29
|
+
o.bg.success.hover.press,
|
|
30
|
+
o.font.text5,
|
|
31
|
+
o.width.px(104),
|
|
32
|
+
o.height.px(104),
|
|
33
|
+
])}
|
|
34
|
+
`
|
|
35
|
+
```
|
package/src/index.test.tsx
CHANGED
|
@@ -3,7 +3,7 @@ import 'jest-styled-components'
|
|
|
3
3
|
|
|
4
4
|
import renderer from 'react-test-renderer'
|
|
5
5
|
import styled, { ThemeProvider } from 'styled-components'
|
|
6
|
-
import { Example } from './
|
|
6
|
+
import { Example } from './addThemeUtils.story'
|
|
7
7
|
import { MyTheme, myTheme } from './storyHelper'
|
|
8
8
|
|
|
9
9
|
function render(children: JSX.Element) {
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.story.d.ts","sourceRoot":"","sources":["../src/index.story.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAW,MAAM,eAAe,CAAA;;;;AAEhD,wBAEC;AAED,OAAO,QAAQ,mBAAmB,CAAC;IACjC,UAAiB,YAAa,SAAQ,OAAO;KAAG;CACjD;AAED,eAAO,MAAM,OAAO,mBAiCnB,CAAA"}
|