@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.
@@ -8,4 +8,4 @@ declare module 'styled-components' {
8
8
  }
9
9
  }
10
10
  export declare const Example: () => JSX.Element;
11
- //# sourceMappingURL=index.story.d.ts.map
11
+ //# sourceMappingURL=addThemeUtils.story.d.ts.map
@@ -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.11.0",
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.11.0",
38
- "@charcoal-ui/theme": "^3.11.0",
39
- "@charcoal-ui/utils": "^3.11.0",
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": "503ef7c22e3eb46b39b8ddd93e8389025afdd411"
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
  // Jest Snapshot v1, https://goo.gl/fbAQLP
2
2
 
3
- exports[`Storybook Tests styled/example Example 1`] = `
3
+ exports[`Storybook Tests styled/addThemeUtils Example 1`] = `
4
4
  .c0 {
5
5
  gap: 40px;
6
6
  color: #1f1f1f;
@@ -1,6 +1,6 @@
1
1
  import { Canvas, Meta } from '@storybook/blocks'
2
2
 
3
- import * as CheckboxStories from './index.story'
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={CheckboxStories.Example} />
44
+ <Canvas of={Stories.Example} />
@@ -2,7 +2,7 @@ import styled, { ThemeProvider } from 'styled-components'
2
2
  import { MyTheme, myTheme } from './storyHelper'
3
3
 
4
4
  export default {
5
- title: 'styled/example',
5
+ title: 'styled/addThemeUtils',
6
6
  }
7
7
 
8
8
  declare module 'styled-components' {
@@ -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
+ ```
@@ -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 './index.story'
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"}