@sanity/ui 3.0.0-static.16 → 3.0.0-static.18

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.
Files changed (98) hide show
  1. package/README.md +2 -4
  2. package/bin/{ui.js → sanity-ui.cjs} +1 -1
  3. package/dist/_chunks-cjs/{_visual-editing.js → _visual-editing.cjs} +6 -6
  4. package/dist/_chunks-cjs/_visual-editing.cjs.map +1 -0
  5. package/dist/_chunks-cjs/{buildCommand.js → buildCommand.cjs} +26 -10
  6. package/dist/_chunks-cjs/buildCommand.cjs.map +1 -0
  7. package/dist/_chunks-cjs/{refractor.js → refractor.cjs} +1 -1
  8. package/dist/_chunks-cjs/refractor.cjs.map +1 -0
  9. package/dist/_chunks-es/{_visual-editing.mjs → _visual-editing.js} +7 -7
  10. package/dist/_chunks-es/_visual-editing.js.map +1 -0
  11. package/dist/_chunks-es/{refractor.mjs → refractor.js} +1 -1
  12. package/dist/_chunks-es/refractor.js.map +1 -0
  13. package/dist/_visual-editing.cjs +30 -0
  14. package/dist/_visual-editing.cjs.map +1 -0
  15. package/dist/_visual-editing.js +29 -29
  16. package/dist/_visual-editing.js.map +1 -1
  17. package/dist/{cli.js → cli.cjs} +4 -4
  18. package/dist/cli.cjs.map +1 -0
  19. package/dist/{css.mjs → css.cjs} +491 -499
  20. package/dist/css.cjs.map +1 -0
  21. package/dist/{css.d.mts → css.d.cts} +26 -26
  22. package/dist/css.d.ts +26 -26
  23. package/dist/css.js +491 -497
  24. package/dist/css.js.map +1 -1
  25. package/dist/{index.mjs → index.cjs} +368 -367
  26. package/dist/{index.mjs.map → index.cjs.map} +1 -1
  27. package/dist/{index.d.mts → index.d.cts} +3 -2
  28. package/dist/index.d.ts +3 -2
  29. package/dist/index.js +366 -367
  30. package/dist/index.js.map +1 -1
  31. package/dist/{theme.mjs → theme.cjs} +219 -196
  32. package/dist/theme.cjs.map +1 -0
  33. package/dist/{theme.d.mts → theme.d.cts} +2 -0
  34. package/dist/theme.d.ts +2 -0
  35. package/dist/theme.js +218 -195
  36. package/dist/theme.js.map +1 -1
  37. package/dist/{sanity-palette.css → ui-palette.css} +1 -1
  38. package/dist/ui-palette.min.css +1 -0
  39. package/dist/{system.css → ui-system.css} +258 -140
  40. package/dist/ui-system.min.css +1 -0
  41. package/dist/{sanity-theme.css → ui-theme.css} +199 -199
  42. package/dist/ui-theme.min.css +1 -0
  43. package/dist/ui.css +29152 -0
  44. package/dist/ui.min.css +1 -0
  45. package/package.json +20 -20
  46. package/src/cli/buildCommand.ts +55 -20
  47. package/src/cli/index.ts +1 -1
  48. package/src/core/StyleTags.tsx +4 -4
  49. package/src/core/components/autocomplete/__workshop__/async.tsx +2 -2
  50. package/src/core/components/autocomplete/__workshop__/custom.tsx +2 -2
  51. package/src/core/components/autocomplete/__workshop__/focusAndBlur.tsx +3 -3
  52. package/src/core/hooks/useMediaIndex/useMediaIndex.test.tsx +2 -18
  53. package/src/core/hooks/useMediaIndex/useMediaIndex.ts +9 -9
  54. package/src/core/primitives/button/__workshop__/custom.tsx +18 -41
  55. package/src/core/primitives/button/button.tsx +3 -1
  56. package/src/core/primitives/card/__workshop__/asButton.tsx +0 -9
  57. package/src/core/primitives/card/__workshop__/interactive.tsx +0 -1
  58. package/src/core/primitives/card/__workshop__/props.tsx +0 -3
  59. package/src/core/primitives/card/__workshop__/selected.tsx +6 -37
  60. package/src/core/primitives/heading/__workshop__/opticalAlignment.tsx +1 -1
  61. package/src/core/primitives/heading/__workshop__/plain.tsx +1 -8
  62. package/src/core/primitives/label/__workshop__/plain.tsx +1 -9
  63. package/src/core/primitives/text/__workshop__/example.tsx +1 -9
  64. package/src/css/{compilePalette.ts → _compilePalette.ts} +2 -2
  65. package/src/css/{compileSystem.ts → _compileSystem.ts} +1 -1
  66. package/src/css/{compileTheme.ts → _compileTheme.ts} +3 -3
  67. package/src/css/{compileTheme_v3.ts → _compileTheme_v3.ts} +7 -1
  68. package/src/css/_system.style.ts +1 -0
  69. package/src/css/constants.ts +1 -0
  70. package/src/css/index.ts +3 -3
  71. package/src/css/primitives/button/button.style.ts +23 -9
  72. package/src/css/primitives/button/button.ts +1 -12
  73. package/src/css/primitives/button/types.ts +1 -6
  74. package/src/css/primitives/card/card.style.ts +12 -21
  75. package/src/css/primitives/kbd/kbd.style.ts +3 -6
  76. package/src/css/types.ts +32 -27
  77. package/src/theme/v3/color/buildColor_v3.ts +53 -25
  78. package/src/theme/v3/color/card.ts +0 -42
  79. package/src/theme/v3/color/renderColor.test.ts +1 -0
  80. package/src/theme/v3/color/renderColor.ts +9 -2
  81. package/src/theme/v3/color/token.ts +1 -0
  82. package/src/theme/v3/defaultTokens.ts +7 -2
  83. package/dist/_chunks-cjs/_visual-editing.js.map +0 -1
  84. package/dist/_chunks-cjs/buildCommand.js.map +0 -1
  85. package/dist/_chunks-cjs/refractor.js.map +0 -1
  86. package/dist/_chunks-es/_visual-editing.mjs.map +0 -1
  87. package/dist/_chunks-es/refractor.mjs.map +0 -1
  88. package/dist/_visual-editing.mjs +0 -30
  89. package/dist/_visual-editing.mjs.map +0 -1
  90. package/dist/cli.js.map +0 -1
  91. package/dist/css.mjs.map +0 -1
  92. package/dist/sanity-palette.min.css +0 -1
  93. package/dist/sanity-theme.min.css +0 -1
  94. package/dist/system.min.css +0 -1
  95. package/dist/theme.mjs.map +0 -1
  96. package/src/css/primitives/button/_constants.ts +0 -17
  97. /package/dist/{_visual-editing.d.mts → _visual-editing.d.cts} +0 -0
  98. /package/dist/{cli.d.ts → cli.d.cts} +0 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sanity/ui",
3
- "version": "3.0.0-static.16",
3
+ "version": "3.0.0-static.18",
4
4
  "keywords": [
5
5
  "react",
6
6
  "ui",
@@ -21,39 +21,40 @@
21
21
  "license": "MIT",
22
22
  "author": "Sanity.io <hello@sanity.io>",
23
23
  "sideEffects": false,
24
- "type": "commonjs",
24
+ "type": "module",
25
25
  "exports": {
26
26
  ".": {
27
27
  "source": "./exports/index.ts",
28
- "import": "./dist/index.mjs",
29
- "require": "./dist/index.js",
28
+ "import": "./dist/index.js",
29
+ "require": "./dist/index.cjs",
30
30
  "default": "./dist/index.js"
31
31
  },
32
32
  "./_visual-editing": {
33
33
  "source": "./exports/_visual-editing.ts",
34
- "import": "./dist/_visual-editing.mjs",
35
- "require": "./dist/_visual-editing.js",
34
+ "import": "./dist/_visual-editing.js",
35
+ "require": "./dist/_visual-editing.cjs",
36
36
  "default": "./dist/_visual-editing.js"
37
37
  },
38
38
  "./css": {
39
39
  "source": "./exports/css.ts",
40
- "import": "./dist/css.mjs",
41
- "require": "./dist/css.js",
40
+ "import": "./dist/css.js",
41
+ "require": "./dist/css.cjs",
42
42
  "default": "./dist/css.js"
43
43
  },
44
44
  "./package.json": "./package.json",
45
45
  "./theme": {
46
46
  "source": "./exports/theme.ts",
47
- "import": "./dist/theme.mjs",
48
- "require": "./dist/theme.js",
47
+ "import": "./dist/theme.js",
48
+ "require": "./dist/theme.cjs",
49
49
  "default": "./dist/theme.js"
50
50
  },
51
- "./sanity-palette.css": "./dist/sanity-palette.css",
52
- "./sanity-theme.css": "./dist/sanity-theme.css",
53
- "./system.css": "./dist/system.css"
51
+ "./ui-palette.css": "./dist/ui-palette.css",
52
+ "./ui-theme.css": "./dist/ui-theme.css",
53
+ "./ui-system.css": "./dist/ui-system.css",
54
+ "./ui.css": "./dist/ui.css"
54
55
  },
55
- "main": "./dist/index.js",
56
- "module": "./dist/index.mjs",
56
+ "main": "./dist/index.cjs",
57
+ "module": "./dist/index.js",
57
58
  "types": "./dist/index.d.ts",
58
59
  "typesVersions": {
59
60
  "*": {
@@ -69,10 +70,9 @@
69
70
  }
70
71
  },
71
72
  "bin": {
72
- "ui": "./bin/ui.js"
73
+ "sanity-ui": "./bin/sanity-ui.cjs"
73
74
  },
74
75
  "files": [
75
- "css.js",
76
76
  "dist",
77
77
  "exports",
78
78
  "src"
@@ -218,8 +218,9 @@
218
218
  "bundle": false
219
219
  },
220
220
  "scripts": {
221
- "build": "run-s clean ui:build pkg:build pkg:check figma:pkg:build",
222
- "clean": "rimraf .workshop css.js dist theme.js",
221
+ "build": "run-s clean css:build pkg:build pkg:check figma:pkg:build",
222
+ "clean": "rimraf .workshop dist",
223
+ "css:build": "node -r esbuild-register scripts/build",
223
224
  "commit": "cz",
224
225
  "cypress:dev": "run-p dev cypress:open",
225
226
  "cypress:open": "cypress open",
@@ -236,7 +237,6 @@
236
237
  "test": "jest",
237
238
  "test:browser": "start-server-and-test 'run-s workshop:build workshop:start' http://localhost:1337 'run-s cypress:run'",
238
239
  "ts:check": "tsc",
239
- "ui:build": "node -r esbuild-register scripts/build",
240
240
  "watch": "pkg watch --strict",
241
241
  "workshop:build": "workshop build",
242
242
  "workshop:dev": "workshop dev",
@@ -1,6 +1,6 @@
1
1
  /* eslint-disable no-console */
2
2
 
3
- import {compilePalette, compileSystem, compileTheme} from '@sanity/ui/css'
3
+ import {_compilePalette, _compileSystem, _compileTheme} from '@sanity/ui/css'
4
4
  import {buildTheme_v3, RootTheme} from '@sanity/ui/theme'
5
5
  import cssnano from 'cssnano'
6
6
  import fs from 'fs/promises'
@@ -10,6 +10,20 @@ import postcss from 'postcss'
10
10
  import {format, resolveConfig} from 'prettier'
11
11
  import prettyBytes from 'pretty-bytes'
12
12
 
13
+ export async function buildCommand(options: {cwd?: string; outDir?: string}): Promise<void> {
14
+ const cwd = options.cwd ?? process.cwd()
15
+ const outDir = options.outDir ?? path.resolve(cwd, 'dist')
16
+
17
+ await Promise.all([
18
+ buildPalette(outDir),
19
+ buildTheme(outDir),
20
+ buildSystem(outDir),
21
+ buildAll(outDir),
22
+ ])
23
+ }
24
+
25
+ //
26
+
13
27
  async function minify(css: string) {
14
28
  return postcss([cssnano()]).process(css, {from: undefined})
15
29
  }
@@ -28,48 +42,69 @@ function prettySize(str: string) {
28
42
  return `${prettyBytes(str.length)} / ${prettyBytes(gzipSizeSync(str))}`
29
43
  }
30
44
 
45
+ // @sanity/ui/ui-palette.css
31
46
  async function buildPalette(outDir: string) {
32
- const css = compilePalette()
47
+ const css = _compilePalette()
33
48
  const minified = await minify(css)
34
49
  const prettified = await prettify(css)
35
50
 
36
51
  await fs.mkdir(outDir, {recursive: true})
37
- await fs.writeFile(path.resolve(outDir, 'sanity-palette.css'), prettified, 'utf-8')
38
- await fs.writeFile(path.resolve(outDir, 'sanity-palette.min.css'), minified.css, 'utf-8')
52
+ await fs.writeFile(path.resolve(outDir, 'ui-palette.css'), prettified, 'utf-8')
53
+ await fs.writeFile(path.resolve(outDir, 'ui-palette.min.css'), minified.css, 'utf-8')
39
54
 
40
- console.log(`- built sanity-palette.css (${prettySize(prettified)})`)
41
- console.log(`- built sanity-palette.min.css (${prettySize(minified.css)})`)
55
+ console.log(`- built ui-palette.css (${prettySize(prettified)})`)
56
+ console.log(`- built ui-palette.min.css (${prettySize(minified.css)})`)
42
57
  }
43
58
 
59
+ // @sanity/ui/ui-theme.css
44
60
  async function buildTheme(outDir: string) {
45
- const css = await prettify(compileTheme({v3: buildTheme_v3()} as RootTheme))
61
+ const css = await prettify(_compileTheme({v3: buildTheme_v3()} as RootTheme))
46
62
  const minified = await minify(css)
47
63
  const prettified = await prettify(css)
48
64
 
49
65
  await fs.mkdir(outDir, {recursive: true})
50
- await fs.writeFile(path.resolve(outDir, 'sanity-theme.css'), prettified, 'utf-8')
51
- await fs.writeFile(path.resolve(outDir, 'sanity-theme.min.css'), minified.css, 'utf-8')
66
+ await fs.writeFile(path.resolve(outDir, 'ui-theme.css'), prettified, 'utf-8')
67
+ await fs.writeFile(path.resolve(outDir, 'ui-theme.min.css'), minified.css, 'utf-8')
52
68
 
53
- console.log(`- built sanity-theme.css (${prettySize(prettified)})`)
54
- console.log(`- built sanity-theme.min.css (${prettySize(minified.css)})`)
69
+ console.log(`- built ui-theme.css (${prettySize(prettified)})`)
70
+ console.log(`- built ui-theme.min.css (${prettySize(minified.css)})`)
55
71
  }
56
72
 
73
+ // @sanity/ui/ui-system.css
57
74
  async function buildSystem(outDir: string) {
58
- const css = await prettify(compileSystem())
75
+ const css = await prettify(_compileSystem())
59
76
  const minified = await minify(css)
60
77
  const prettified = await prettify(css)
61
78
 
62
79
  await fs.mkdir(outDir, {recursive: true})
63
- await fs.writeFile(path.resolve(outDir, 'system.css'), prettified, 'utf-8')
64
- await fs.writeFile(path.resolve(outDir, 'system.min.css'), minified.css, 'utf-8')
80
+ await fs.writeFile(path.resolve(outDir, 'ui-system.css'), prettified, 'utf-8')
81
+ await fs.writeFile(path.resolve(outDir, 'ui-system.min.css'), minified.css, 'utf-8')
65
82
 
66
- console.log(`- built system.css (${prettySize(prettified)})`)
67
- console.log(`- built system.min.css (${prettySize(minified.css)})`)
83
+ console.log(`- built ui-system.css (${prettySize(prettified)})`)
84
+ console.log(`- built ui-system.min.css (${prettySize(minified.css)})`)
68
85
  }
69
86
 
70
- export async function buildCommand(options: {cwd?: string; outDir?: string}): Promise<void> {
71
- const cwd = options.cwd ?? process.cwd()
72
- const outDir = options.outDir ?? path.resolve(cwd, 'dist')
87
+ // @sanity/ui/ui.css
88
+ async function buildAll(outDir: string) {
89
+ const css = await prettify(
90
+ [
91
+ `/* @sanity/ui/ui-palette.css */\n`,
92
+ _compilePalette(),
93
+ `\n\n/* @sanity/ui/ui-theme.css */\n`,
94
+ _compileTheme({v3: buildTheme_v3()} as RootTheme),
95
+ `\n\n/* @sanity/ui/ui-system.css */\n`,
96
+ _compileSystem(),
97
+ `\n`,
98
+ ].join(''),
99
+ )
100
+
101
+ const minified = await minify(css)
102
+ const prettified = await prettify(css)
103
+
104
+ await fs.mkdir(outDir, {recursive: true})
105
+ await fs.writeFile(path.resolve(outDir, 'ui.css'), prettified, 'utf-8')
106
+ await fs.writeFile(path.resolve(outDir, 'ui.min.css'), minified.css, 'utf-8')
73
107
 
74
- await Promise.all([buildPalette(outDir), buildTheme(outDir), buildSystem(outDir)])
108
+ console.log(`- built ui.css (${prettySize(prettified)})`)
109
+ console.log(`- built ui.min.css (${prettySize(minified.css)})`)
75
110
  }
package/src/cli/index.ts CHANGED
@@ -2,7 +2,7 @@ import {cac} from 'cac'
2
2
 
3
3
  import {version} from '../../package.json'
4
4
 
5
- const cli = cac('ui')
5
+ const cli = cac('sanity-ui')
6
6
 
7
7
  cli
8
8
  .command('build')
@@ -1,4 +1,4 @@
1
- import {compilePalette, compileSystem, compileTheme} from '@sanity/ui/css'
1
+ import {_compilePalette, _compileSystem, _compileTheme} from '@sanity/ui/css'
2
2
  import {buildTheme_v3, RootTheme, Theme_v3} from '@sanity/ui/theme'
3
3
  import {ReactNode} from 'react'
4
4
 
@@ -11,13 +11,13 @@ export function StyleTags(props: {theme?: Theme_v3}): ReactNode {
11
11
  return (
12
12
  <>
13
13
  <style href="sanity-palette" precedence="palette">
14
- {compilePalette()}
14
+ {_compilePalette()}
15
15
  </style>
16
16
  <style href="sanity-theme" precedence="theme">
17
- {compileTheme({v3: theme} as RootTheme)}
17
+ {_compileTheme({v3: theme} as RootTheme)}
18
18
  </style>
19
19
  <style href="sanity-system" precedence="system">
20
- {compileSystem()}
20
+ {_compileSystem()}
21
21
  </style>
22
22
  </>
23
23
  )
@@ -103,11 +103,11 @@ export default function AsyncStory() {
103
103
  />
104
104
  </LayerProvider>
105
105
 
106
- <Card overflow="auto" padding={3} radius={2} tone="transparent">
106
+ <Box muted overflow="auto" padding={3} radius={2}>
107
107
  <Code language="json" size={1}>
108
108
  {JSON.stringify({loading, options, query, value}, null, 2)}
109
109
  </Code>
110
- </Card>
110
+ </Box>
111
111
  </Stack>
112
112
  </Box>
113
113
  )
@@ -77,9 +77,9 @@ export default function CustomStory() {
77
77
  />
78
78
  </Stack>
79
79
 
80
- <Card padding={3} radius={2} tone="transparent">
80
+ <Box muted padding={3} radius={2}>
81
81
  <Code size={1}>{JSON.stringify(value)}</Code>
82
- </Card>
82
+ </Box>
83
83
  <Box>
84
84
  <Button id="set-value-btn" onClick={() => setValue('NO')} text="Set to NO" />
85
85
  </Box>
@@ -1,4 +1,4 @@
1
- import {Autocomplete, Box, Button, Card, Code, Stack} from '@sanity/ui'
1
+ import {Autocomplete, Box, Button, Code, Stack} from '@sanity/ui'
2
2
  import {useCallback, useState} from 'react'
3
3
 
4
4
  export default function FocusAndBlurStory() {
@@ -22,11 +22,11 @@ export default function FocusAndBlurStory() {
22
22
  value={value}
23
23
  />
24
24
  <Stack space={3}>
25
- <Card overflow="auto" padding={3} radius={2} tone="transparent">
25
+ <Box muted overflow="auto" padding={3} radius={2}>
26
26
  <Code id="focus-and-blur-log" language="json" size={1}>
27
27
  {JSON.stringify(log)}
28
28
  </Code>
29
- </Card>
29
+ </Box>
30
30
 
31
31
  <Button id="focus-and-blur-clear-btn" mode="ghost" onClick={handleClear} text="Clear" />
32
32
  </Stack>
@@ -1,13 +1,9 @@
1
1
  /** @jest-environment node */
2
2
 
3
- import {buildTheme} from '@sanity/ui/theme'
4
3
  import {renderToStaticMarkup, renderToString} from 'react-dom/server'
5
4
 
6
- import {ThemeProvider} from '../../_compat'
7
5
  import {useMediaIndex} from './useMediaIndex'
8
6
 
9
- const theme = buildTheme()
10
-
11
7
  function Log() {
12
8
  const mediaIndex = useMediaIndex()
13
9
 
@@ -16,21 +12,9 @@ function Log() {
16
12
 
17
13
  describe('useMediaIndex', () => {
18
14
  it(`SSR to static markup returns 0`, () => {
19
- expect(
20
- renderToStaticMarkup(
21
- <ThemeProvider theme={theme}>
22
- <Log />
23
- </ThemeProvider>,
24
- ),
25
- ).toBe('mediaIndex: 0')
15
+ expect(renderToStaticMarkup(<Log />)).toBe('mediaIndex: 0')
26
16
  })
27
17
  it(`SSR to markup for hydration doesn't throw`, () => {
28
- expect(
29
- renderToString(
30
- <ThemeProvider theme={theme}>
31
- <Log />
32
- </ThemeProvider>,
33
- ),
34
- ).toMatchInlineSnapshot(`"mediaIndex: <!-- -->0"`)
18
+ expect(renderToString(<Log />)).toMatchInlineSnapshot(`"mediaIndex: <!-- -->0"`)
35
19
  })
36
20
  })
@@ -1,14 +1,14 @@
1
+ import {Breakpoint, BREAKPOINTS} from '@sanity/ui/css'
1
2
  import {useMemo, useSyncExternalStore} from 'react'
2
3
 
3
- // TODO: get from theme?
4
- const media = [360, 600, 900, 1200, 1800, 2400]
4
+ const media = Object.values(BREAKPOINTS)
5
5
 
6
6
  /**
7
7
  * @internal
8
8
  */
9
9
  export interface _MediaStore {
10
10
  subscribe: (onStoreChange: () => void) => () => void
11
- getSnapshot: () => number
11
+ getSnapshot: () => Breakpoint
12
12
  }
13
13
 
14
14
  type MediaQueryMinWidth = `(min-width: ${number}px)`
@@ -18,14 +18,14 @@ type MediaQuery = `screen and ${MediaQueryMinWidth | MediaQueryMaxWidth | MediaQ
18
18
 
19
19
  function _getMediaQuery(media: number[], index: number): MediaQuery {
20
20
  if (index === 0) {
21
- return `screen and (max-width: ${media[index] - 1}px)`
21
+ return `screen and (max-width: ${media[index + 1] - 1}px)`
22
22
  }
23
23
 
24
24
  if (index === media.length) {
25
- return `screen and (min-width: ${media[index - 1]}px)`
25
+ return `screen and (min-width: ${media[index]}px)`
26
26
  }
27
27
 
28
- return `screen and (min-width: ${media[index - 1]}px) and (max-width: ${media[index] - 1}px)`
28
+ return `screen and (min-width: ${media[index]}px) and (max-width: ${media[index + 1] - 1}px)`
29
29
  }
30
30
 
31
31
  function _createMediaStore(): _MediaStore {
@@ -51,7 +51,7 @@ function _createMediaStore(): _MediaStore {
51
51
 
52
52
  const getSnapshot = () => {
53
53
  for (const {index, mq} of getSizes()) {
54
- if (mq.matches) return index
54
+ if (mq.matches) return index as Breakpoint
55
55
  }
56
56
 
57
57
  return 0
@@ -87,7 +87,7 @@ function _createMediaStore(): _MediaStore {
87
87
  *
88
88
  * @link https://beta.reactjs.org/apis/react/useSyncExternalStore#adding-support-for-server-rendering
89
89
  */
90
- function getServerSnapshot() {
90
+ function getServerSnapshot(): Breakpoint {
91
91
  return 0
92
92
  }
93
93
 
@@ -95,7 +95,7 @@ function getServerSnapshot() {
95
95
  * This API might change. DO NOT USE IN PRODUCTION.
96
96
  * @beta
97
97
  */
98
- export function useMediaIndex(): number {
98
+ export function useMediaIndex(): Breakpoint {
99
99
  const store = useMemo(() => _createMediaStore(), [])
100
100
 
101
101
  return useSyncExternalStore(store.subscribe, store.getSnapshot, getServerSnapshot)
@@ -1,49 +1,26 @@
1
- /* eslint-disable jsx-a11y/anchor-is-valid */
2
-
3
- import {Button, Flex, Grid, Stack, Text} from '@sanity/ui'
4
-
5
- import {WORKSHOP_BUTTON_TONE_OPTIONS} from '../../../../../workshop/constants'
1
+ import {Button, Flex, Grid, Hotkeys, Stack, Text} from '@sanity/ui'
2
+ import {THEME_COLOR_BUTTON_MODES, THEME_COLOR_STATE_TONES} from '@sanity/ui/theme'
6
3
 
7
4
  export default function CustomStory() {
8
- const tones = Object.entries(WORKSHOP_BUTTON_TONE_OPTIONS)
9
-
10
5
  return (
11
6
  <Flex align="center" height="fill" justify="center" padding={4} sizing="border">
12
7
  <Stack space={2}>
13
- <Grid columns={7} gap={1}>
14
- {tones.map(([title, tone]) => (
15
- <Button key={tone} mode="ghost" padding={3} tone={tone}>
16
- <Stack space={2}>
17
- <Text>{title}</Text>
18
- <Text muted>Muted</Text>
19
- <Text muted>
20
- <a href="#">Link</a>
21
- </Text>
22
- <Text>
23
- <code>Code</code>
24
- </Text>
25
- <Text accent>Accent</Text>
26
- </Stack>
27
- </Button>
28
- ))}
29
- </Grid>
30
- <Grid columns={7} gap={1}>
31
- {tones.map(([title, tone]) => (
32
- <Button key={tone} mode="default" padding={3} tone={tone}>
33
- <Stack space={2}>
34
- <Text>{title}</Text>
35
- <Text muted>Muted</Text>
36
- <Text muted>
37
- <a href="#">Link</a>
38
- </Text>
39
- <Text>
40
- <code>Code</code>
41
- </Text>
42
- <Text accent>Accent</Text>
43
- </Stack>
44
- </Button>
45
- ))}
46
- </Grid>
8
+ {THEME_COLOR_BUTTON_MODES.map((mode) => (
9
+ <Grid columns={7} gap={1} key={mode}>
10
+ {THEME_COLOR_STATE_TONES.map((tone) => (
11
+ <Button key={tone} mode={mode} padding={3} tone={tone}>
12
+ <Stack space={2}>
13
+ <Text>Text</Text>
14
+ <Text muted>Muted</Text>
15
+ <Text>
16
+ <code>Code</code>
17
+ </Text>
18
+ <Hotkeys keys={['Cmd', 'C']} />
19
+ </Stack>
20
+ </Button>
21
+ ))}
22
+ </Grid>
23
+ ))}
47
24
  </Stack>
48
25
  </Flex>
49
26
  )
@@ -108,8 +108,10 @@ export function Button<E extends ButtonElementType = typeof DEFAULT_BUTTON_ELEME
108
108
  <Element
109
109
  data-ui="Button"
110
110
  {...rest}
111
- className={composeClassNames(className, button({display, flex, mode, radius, tone, width}))}
111
+ className={composeClassNames(className, button({display, flex, radius, width}))}
112
112
  data-disabled={loading || disabled ? '' : undefined}
113
+ data-mode={mode}
114
+ data-tone={tone}
113
115
  data-selected={selected ? '' : undefined}
114
116
  disabled={Boolean(loading || disabled)}
115
117
  // @ts-expect-error - TODO: fix this
@@ -30,9 +30,6 @@ export default function AsButtonStory() {
30
30
  <Text muted size={1}>
31
31
  Muted
32
32
  </Text>
33
- <Text accent size={1}>
34
- Accent
35
- </Text>
36
33
  </Stack>
37
34
  </Card>
38
35
  ))}
@@ -61,9 +58,6 @@ export default function AsButtonStory() {
61
58
  <Text size={1} muted>
62
59
  Muted
63
60
  </Text>
64
- <Text accent size={1}>
65
- Accent
66
- </Text>
67
61
  </Stack>
68
62
  </Card>
69
63
  ))}
@@ -92,9 +86,6 @@ export default function AsButtonStory() {
92
86
  <Text size={1} muted>
93
87
  Muted
94
88
  </Text>
95
- <Text accent size={1}>
96
- Accent
97
- </Text>
98
89
  </Stack>
99
90
  </Card>
100
91
  ))}
@@ -21,7 +21,6 @@ export default function InteractiveCardStory() {
21
21
  Text <code>Code</code>
22
22
  </Text>
23
23
  <Text muted>Muted</Text>
24
- <Text accent>Accent</Text>
25
24
  </Stack>
26
25
  </Card>
27
26
  </div>
@@ -45,9 +45,6 @@ export default function PropsStory() {
45
45
  Text with {/* eslint-disable-next-line jsx-a11y/anchor-is-valid */}
46
46
  <a href="#">link</a>.
47
47
  </Text>
48
- <Text accent size={1}>
49
- Text with accent color.
50
- </Text>
51
48
  </Stack>
52
49
  </Card>
53
50
  </Flex>
@@ -1,29 +1,6 @@
1
1
  import {EditIcon, PublishIcon} from '@sanity/icons'
2
- import {Box, Card, Container, Flex, Inline, Stack, Text, useRootTheme} from '@sanity/ui'
3
- import {getTheme_v2, Theme, ThemeColorStateToneKey} from '@sanity/ui/theme'
2
+ import {Box, Card, Container, Flex, Inline, Stack, Text} from '@sanity/ui'
4
3
  import {useBoolean} from '@sanity/ui-workshop'
5
- import {css, styled} from 'styled-components'
6
-
7
- const TextWithTone = styled(Text)<{$tone: ThemeColorStateToneKey}>((props: {
8
- $tone: ThemeColorStateToneKey
9
- theme: Theme
10
- }) => {
11
- const {$tone} = props
12
- const {color} = getTheme_v2(props.theme)
13
- const tone = color.button.default[$tone]
14
-
15
- return css`
16
- &:not([data-selected]) {
17
- --card-fg-color: ${tone.enabled.bg};
18
- --card-muted-fg-color: ${tone.enabled.bg};
19
- }
20
-
21
- [data-ui='Card']:disabled & {
22
- --card-fg-color: inherit;
23
- --card-muted-fg-color: inherit;
24
- }
25
- `
26
- })
27
4
 
28
5
  export default function SelectedStory() {
29
6
  const disabled = useBoolean('Disabled', false) || false
@@ -62,31 +39,23 @@ export default function SelectedStory() {
62
39
  }
63
40
 
64
41
  function Preview({selected}: {selected: boolean}) {
65
- const rootTheme = useRootTheme()
66
-
67
42
  return (
68
43
  <Flex>
69
44
  <Box flex={1}>
70
45
  <Text size={1}>Title</Text>
71
46
  </Box>
72
47
  <Inline space={3}>
73
- <TextWithTone
74
- data-selected={selected ? '' : undefined}
75
- muted
76
- size={1}
77
- weight="medium"
78
- $tone={rootTheme.tone === 'default' ? 'caution' : 'default'}
79
- >
48
+ <Text data-selected={selected ? '' : undefined} muted size={1} weight="medium">
80
49
  <EditIcon />
81
- </TextWithTone>
82
- <TextWithTone
50
+ </Text>
51
+ <Text
83
52
  data-selected={selected ? '' : undefined}
84
53
  muted
85
54
  size={1}
86
- $tone={rootTheme.tone === 'default' ? 'positive' : 'default'}
55
+ // $tone={rootTheme.tone === 'default' ? 'positive' : 'default'}
87
56
  >
88
57
  <PublishIcon />
89
- </TextWithTone>
58
+ </Text>
90
59
  </Inline>
91
60
  </Flex>
92
61
  )
@@ -43,7 +43,7 @@ export default function OpticalAlignment() {
43
43
 
44
44
  <Flex>
45
45
  <Card padding={2} tone="neutral">
46
- <Heading accent>
46
+ <Heading>
47
47
  <AddCircleIcon />
48
48
  </Heading>
49
49
  </Card>
@@ -8,7 +8,6 @@ import {
8
8
  } from '../../../../../workshop/constants'
9
9
 
10
10
  export default function PlainStory() {
11
- const accent = useBoolean('Accent', false, 'Props')
12
11
  const muted = useBoolean('Muted', false, 'Props')
13
12
  const size = useSelect('Size', WORKSHOP_HEADING_FONT_SIZE_OPTIONS, 2, 'Props')
14
13
  const textChild = useText('Text', 'Hello, world', 'Props')
@@ -18,13 +17,7 @@ export default function PlainStory() {
18
17
 
19
18
  return (
20
19
  <Flex align="center" height="fill" justify="center" padding={[4, 5, 6]} sizing="border">
21
- <Heading
22
- accent={accent}
23
- muted={muted}
24
- size={size}
25
- textOverflow={textOverflow}
26
- weight={weight}
27
- >
20
+ <Heading muted={muted} size={size} textOverflow={textOverflow} weight={weight}>
28
21
  {textChild}
29
22
  </Heading>
30
23
  </Flex>
@@ -9,7 +9,6 @@ import {
9
9
  } from '../../../../../workshop/constants'
10
10
 
11
11
  export default function PlainStory() {
12
- const accent = useBoolean('Accent', false, 'Props')
13
12
  const align = useSelect('Align', WORKSHOP_TEXT_ALIGN_OPTIONS, undefined, 'Props') || undefined
14
13
  const muted = useBoolean('Muted', false, 'Props')
15
14
  const size = useSelect('Size', WORKSHOP_LABEL_FONT_SIZE_OPTIONS, undefined, 'Props')
@@ -21,14 +20,7 @@ export default function PlainStory() {
21
20
  return (
22
21
  <Flex align="center" height="fill" justify="center" padding={[4, 5, 6]} sizing="border">
23
22
  <Container width={0}>
24
- <Label
25
- accent={accent}
26
- align={align}
27
- muted={muted}
28
- size={size}
29
- textOverflow={textOverflow}
30
- weight={weight}
31
- >
23
+ <Label align={align} muted={muted} size={size} textOverflow={textOverflow} weight={weight}>
32
24
  {textChild}
33
25
  </Label>
34
26
  </Container>