@sanity/ui 2.0.0-alpha.34 → 2.0.0-alpha.36
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.cjs.mjs +4 -3
- package/dist/index.d.ts +29 -22
- package/dist/index.esm.js +397 -518
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +413 -534
- package/dist/index.js.map +1 -1
- package/dist/theme.cjs.mjs +10 -4
- package/dist/theme.d.ts +489 -201
- package/dist/theme.esm.js +2934 -2748
- package/dist/theme.esm.js.map +1 -1
- package/dist/theme.js +2943 -2751
- package/dist/theme.js.map +1 -1
- package/package.json +3 -3
- package/src/core/_compat.ts +7 -7
- package/src/core/components/dialog/dialog.tsx +5 -5
- package/src/core/components/dialog/styles.ts +4 -5
- package/src/core/components/hotkeys/hotkeys.tsx +4 -2
- package/src/core/components/menu/__workshop__/avatarMenu.tsx +50 -0
- package/src/core/components/menu/__workshop__/index.ts +5 -0
- package/src/core/components/menu/menuItem.tsx +7 -1
- package/src/core/components/skeleton/textSkeleton.tsx +12 -14
- package/src/core/components/tree/style.ts +14 -17
- package/src/core/hooks/useMediaIndex/useMediaIndex.test.tsx +3 -3
- package/src/core/hooks/useMediaIndex/useMediaIndex.ts +2 -3
- package/src/core/primitives/_selectable/style.ts +18 -18
- package/src/core/primitives/avatar/avatar.tsx +3 -3
- package/src/core/primitives/avatar/avatarCounter.tsx +4 -4
- package/src/core/primitives/avatar/avatarStack.tsx +2 -2
- package/src/core/primitives/avatar/styles.ts +7 -8
- package/src/core/primitives/avatar/types.ts +2 -2
- package/src/core/primitives/badge/__workshop__/props.tsx +1 -1
- package/src/core/primitives/badge/__workshop__/tones.tsx +1 -1
- package/src/core/primitives/badge/badge.tsx +1 -1
- package/src/core/primitives/badge/styles.ts +5 -6
- package/src/core/primitives/button/button.tsx +3 -4
- package/src/core/primitives/button/styles.ts +22 -23
- package/src/core/primitives/card/__workshop__/selected.tsx +15 -15
- package/src/core/primitives/card/card.tsx +1 -1
- package/src/core/primitives/card/styles.ts +22 -22
- package/src/core/primitives/checkbox/styles.ts +21 -22
- package/src/core/primitives/code/styles.ts +4 -1
- package/src/core/primitives/container/styles.ts +2 -3
- package/src/core/primitives/heading/styles.ts +4 -2
- package/src/core/primitives/inline/styles.ts +6 -6
- package/src/core/primitives/kbd/kbd.tsx +7 -11
- package/src/core/primitives/label/styles.ts +4 -3
- package/src/core/primitives/popover/helpers.ts +3 -4
- package/src/core/primitives/popover/popover.tsx +8 -4
- package/src/core/primitives/popover/types.ts +1 -1
- package/src/core/primitives/radio/styles.ts +17 -19
- package/src/core/primitives/select/styles.ts +27 -32
- package/src/core/primitives/stack/styles.ts +2 -3
- package/src/core/primitives/switch/__workshop__/props.tsx +11 -31
- package/src/core/primitives/switch/styles.ts +18 -21
- package/src/core/primitives/text/__workshop__/colored.tsx +10 -10
- package/src/core/primitives/text/styles.ts +9 -4
- package/src/core/primitives/tooltip/tooltip.tsx +3 -3
- package/src/core/styles/border/borderStyle.ts +6 -11
- package/src/core/styles/box/boxStyle.ts +5 -9
- package/src/core/styles/card/_cardColorStyle.ts +99 -0
- package/src/core/styles/card/index.ts +1 -0
- package/src/core/styles/flex/flexItemStyle.ts +2 -3
- package/src/core/styles/flex/flexStyle.ts +6 -11
- package/src/core/styles/font/responsiveFont.ts +4 -4
- package/src/core/styles/font/textAlignStyle.ts +3 -3
- package/src/core/styles/grid/gridItemStyle.ts +7 -13
- package/src/core/styles/grid/gridStyle.ts +9 -17
- package/src/core/styles/helpers.ts +5 -3
- package/src/core/styles/input/responsiveInputPaddingStyle.ts +6 -6
- package/src/core/styles/input/textInputStyle.ts +36 -40
- package/src/core/styles/margin/marginsStyle.test.ts +2 -3
- package/src/core/styles/padding/paddingStyle.test.ts +2 -3
- package/src/core/styles/radius/radiusStyle.ts +2 -3
- package/src/core/styles/shadow/shadowStyle.ts +4 -5
- package/src/core/theme/__workshop__/build/Root.tsx +24 -20
- package/src/core/theme/__workshop__/build/story.tsx +22 -26
- package/src/core/theme/__workshop__/canvas.tsx +21 -40
- package/src/core/theme/theme.test.tsx +2 -35
- package/src/core/theme/themeColorProvider.tsx +2 -2
- package/src/core/theme/themeContext.ts +2 -2
- package/src/core/theme/themeProvider.tsx +25 -25
- package/src/core/theme/types.ts +3 -2
- package/src/core/theme/useRootTheme.ts +1 -9
- package/src/core/theme/useTheme.ts +8 -1
- package/src/core/types/card.ts +2 -2
- package/src/core/utils/arrow/arrow.tsx +3 -3
- package/src/core/utils/elementQuery/elementQuery.tsx +3 -3
- package/src/core/utils/virtualList/virtualList.tsx +2 -2
- package/src/theme/build/_deprecated/color/muted/createMuted.ts +2 -2
- package/src/theme/build/buildColorTheme.test.ts +14 -15
- package/src/theme/build/buildColorTheme.ts +239 -292
- package/src/theme/build/buildTheme.test.ts +9 -7
- package/src/theme/build/buildTheme.ts +12 -9
- package/src/theme/build/colorToken.ts +3 -1
- package/src/theme/build/lib/color-fns/contrastRatio.ts +1 -0
- package/src/theme/build/lib/isRecord.ts +3 -0
- package/src/theme/build/merge.ts +18 -13
- package/src/theme/build/renderColorTheme.ts +205 -213
- package/src/theme/build/renderColorValue.ts +15 -8
- package/src/theme/build/resolveColorTokens.ts +177 -198
- package/src/theme/build/theme.test.ts +27 -0
- package/src/theme/config/helpers.ts +16 -8
- package/src/theme/config/system.ts +46 -17
- package/src/theme/config/tokens/color/types.ts +55 -32
- package/src/theme/config/tokens/types.ts +11 -4
- package/src/theme/config/types.ts +5 -11
- package/src/theme/{build/defaults → defaults}/colorPalette.ts +1 -1
- package/src/theme/{build/defaults → defaults}/colorTokens.ts +189 -136
- package/src/theme/{build/defaults → defaults}/config.ts +14 -12
- package/src/theme/{build/defaults → defaults}/fonts.ts +6 -6
- package/src/theme/getScopedTheme.ts +81 -0
- package/src/theme/index.ts +9 -1
- package/src/theme/system/avatar.ts +1 -1
- package/src/theme/system/color/_constants.ts +11 -11
- package/src/theme/system/color/_system.ts +10 -71
- package/src/theme/system/color/avatar.ts +22 -10
- package/src/theme/system/color/badge.ts +18 -7
- package/src/theme/system/color/button.ts +17 -23
- package/src/theme/system/color/color.ts +34 -0
- package/src/theme/system/color/index.ts +3 -10
- package/src/theme/system/color/input.ts +13 -11
- package/src/theme/system/color/kbd.ts +3 -3
- package/src/theme/system/color/selectable.ts +13 -19
- package/src/theme/system/color/shadow.ts +7 -0
- package/src/theme/system/color/state.ts +37 -0
- package/src/theme/system/css.ts +9 -0
- package/src/theme/system/focusRing.ts +7 -0
- package/src/theme/system/index.ts +5 -1
- package/src/theme/system/input.ts +1 -1
- package/src/theme/system/layer.ts +1 -2
- package/src/theme/system/shadow.ts +1 -0
- package/src/theme/system/styles.ts +19 -0
- package/src/theme/system/theme.ts +128 -0
- package/src/theme/system/{color → v0/color}/_generic.ts +2 -1
- package/src/theme/system/v0/color/_system.ts +13 -0
- package/src/theme/system/{color → v0/color}/base.ts +2 -0
- package/src/theme/system/v0/color/button.ts +42 -0
- package/src/theme/system/{color → v0/color}/card.ts +2 -1
- package/src/theme/system/v0/color/color.ts +40 -0
- package/src/theme/system/v0/color/index.ts +11 -0
- package/src/theme/system/v0/color/input.ts +34 -0
- package/src/theme/system/{color/_deprecated → v0/color}/muted.ts +1 -1
- package/src/theme/system/v0/color/selectable.ts +31 -0
- package/src/theme/system/{color/_deprecated → v0/color}/solid.ts +1 -1
- package/src/theme/system/v0/color/spot.ts +13 -0
- package/src/theme/system/v0/index.ts +1 -0
- package/src/theme/versioning/getTheme_v2.ts +38 -0
- package/src/theme/versioning/index.ts +5 -0
- package/src/theme/versioning/is_v0.ts +6 -0
- package/src/theme/versioning/is_v2.ts +6 -0
- package/src/theme/versioning/themeColor_v0_v2.ts +217 -0
- package/src/theme/versioning/v0_v2.ts +72 -0
- package/src/theme/versioning/v2_v0.ts +126 -0
- package/src/core/styles/colorVars/colorVarsStyle.ts +0 -43
- package/src/core/styles/colorVars/index.ts +0 -1
- package/src/core/theme/defaults.ts +0 -7
- package/src/theme/system/_system.ts +0 -95
- package/src/theme/system/color/_deprecated/spot.ts +0 -13
- package/src/theme/themes/studio/config.ts +0 -69
- package/src/theme/themes/studio/fonts.ts +0 -219
- package/src/theme/themes/studio/index.ts +0 -1
- package/src/theme/themes/studio/studioTheme.test.ts +0 -27
- package/src/theme/themes/studio/studioTheme.ts +0 -8
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import {useContext} from 'react'
|
|
2
|
-
import {isRecord} from '../lib/isRecord'
|
|
3
2
|
import {ThemeContext} from './themeContext'
|
|
4
3
|
import {ThemeContextValue} from './types'
|
|
5
4
|
|
|
@@ -7,18 +6,11 @@ import {ThemeContextValue} from './types'
|
|
|
7
6
|
* @public
|
|
8
7
|
*/
|
|
9
8
|
export function useRootTheme(): ThemeContextValue {
|
|
10
|
-
const value
|
|
9
|
+
const value = useContext(ThemeContext)
|
|
11
10
|
|
|
12
11
|
if (!value) {
|
|
13
12
|
throw new Error('useRootTheme(): missing context value')
|
|
14
13
|
}
|
|
15
14
|
|
|
16
|
-
// NOTE: This check is for future-compatiblity
|
|
17
|
-
// - If the value is not an object, it’s not compatible with the current version
|
|
18
|
-
// - If the value is an object, but doesn’t have `version: 0.0`, it’s not compatible with the current version
|
|
19
|
-
if (!isRecord(value) || value.version !== 0.0) {
|
|
20
|
-
throw new Error('useRootTheme(): the context value is not compatible')
|
|
21
|
-
}
|
|
22
|
-
|
|
23
15
|
return value as unknown as ThemeContextValue
|
|
24
16
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {Theme} from '@sanity/ui/theme'
|
|
1
|
+
import {Theme, Theme_v2, getTheme_v2} from '@sanity/ui/theme'
|
|
2
2
|
import {useTheme as useStyledTheme} from 'styled-components'
|
|
3
3
|
|
|
4
4
|
/**
|
|
@@ -7,3 +7,10 @@ import {useTheme as useStyledTheme} from 'styled-components'
|
|
|
7
7
|
export function useTheme(): Theme {
|
|
8
8
|
return useStyledTheme() as Theme
|
|
9
9
|
}
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* @public
|
|
13
|
+
*/
|
|
14
|
+
export function useTheme_v2(): Theme_v2 {
|
|
15
|
+
return getTheme_v2(useStyledTheme() as Theme)
|
|
16
|
+
}
|
package/src/core/types/card.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {ForwardedRef, HTMLProps, ReactElement, forwardRef} from 'react'
|
|
2
2
|
import styled, {css} from 'styled-components'
|
|
3
|
-
import {
|
|
3
|
+
import {useTheme_v2} from '../../theme'
|
|
4
4
|
import {Point, compileCommands, getRoundedCommands} from './cmds'
|
|
5
5
|
|
|
6
6
|
const Root = styled.div<{$w: number}>(
|
|
@@ -70,8 +70,8 @@ export const Arrow = forwardRef(function Arrow(
|
|
|
70
70
|
ref: ForwardedRef<HTMLDivElement>,
|
|
71
71
|
): ReactElement {
|
|
72
72
|
const {width: w, height: h, radius = 0, ...restProps} = props
|
|
73
|
-
const
|
|
74
|
-
const strokeWidth =
|
|
73
|
+
const {card} = useTheme_v2()
|
|
74
|
+
const strokeWidth = card.shadow.outline
|
|
75
75
|
|
|
76
76
|
const center = w / 2
|
|
77
77
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {forwardRef, useCallback, useMemo, useState} from 'react'
|
|
2
2
|
import {useElementSize, useForwardedRef} from '../../hooks'
|
|
3
|
-
import {
|
|
3
|
+
import {useTheme_v2} from '../../theme'
|
|
4
4
|
import {findMaxBreakpoints, findMinBreakpoints} from './helpers'
|
|
5
5
|
|
|
6
6
|
/**
|
|
@@ -20,8 +20,8 @@ export const ElementQuery = forwardRef(function ElementQuery(
|
|
|
20
20
|
props: MediaQueryProps & Omit<React.HTMLProps<HTMLDivElement>, 'as' | 'media'>,
|
|
21
21
|
ref: React.ForwardedRef<HTMLDivElement>,
|
|
22
22
|
) {
|
|
23
|
-
const theme =
|
|
24
|
-
const {children, media = theme.
|
|
23
|
+
const theme = useTheme_v2()
|
|
24
|
+
const {children, media = theme.media, ...restProps} = props
|
|
25
25
|
|
|
26
26
|
const forwardedRef = useForwardedRef(ref)
|
|
27
27
|
const [element, setElement] = useState<HTMLDivElement | null>(null)
|
|
@@ -5,7 +5,7 @@ import {_isScrollable} from '../../helpers'
|
|
|
5
5
|
import {useForwardedRef} from '../../hooks'
|
|
6
6
|
import {_ResizeObserver} from '../../observers'
|
|
7
7
|
import {StackProps} from '../../primitives'
|
|
8
|
-
import {
|
|
8
|
+
import {useTheme_v2} from '../../theme'
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
11
|
* @beta
|
|
@@ -51,7 +51,7 @@ export const VirtualList = forwardRef(function VirtualList(
|
|
|
51
51
|
ref: React.ForwardedRef<HTMLDivElement>,
|
|
52
52
|
): React.ReactElement {
|
|
53
53
|
const {as = 'div', gap = 0, getItemKey, items = [], onChange, renderItem, ...restProps} = props
|
|
54
|
-
const {space} =
|
|
54
|
+
const {space} = useTheme_v2()
|
|
55
55
|
const forwardedRef = useForwardedRef(ref)
|
|
56
56
|
const wrapperRef = useRef<HTMLDivElement | null>(null)
|
|
57
57
|
const [scrollTop, setScrollTop] = useState(0)
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import {ThemeColorBase,
|
|
1
|
+
import {ThemeColorBase, ThemeColorCardToneKey, ThemeColorMuted} from '../../../../system'
|
|
2
2
|
import {ThemeColorBuilderOpts} from '../factory'
|
|
3
3
|
|
|
4
4
|
export function createMutedTones(
|
|
5
5
|
opts: ThemeColorBuilderOpts,
|
|
6
6
|
base: ThemeColorBase,
|
|
7
7
|
dark: boolean,
|
|
8
|
-
name:
|
|
8
|
+
name: ThemeColorCardToneKey,
|
|
9
9
|
): ThemeColorMuted {
|
|
10
10
|
return {
|
|
11
11
|
default: {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import {ThemeColorTokens} from '../config'
|
|
2
|
-
import {
|
|
2
|
+
import {buildColorTheme} from './buildColorTheme'
|
|
3
3
|
|
|
4
4
|
test('buildColorTheme: base', () => {
|
|
5
5
|
const {light, dark} = buildColorTheme({
|
|
@@ -35,30 +35,30 @@ test('buildColorTheme: base', () => {
|
|
|
35
35
|
expect({
|
|
36
36
|
light: {
|
|
37
37
|
transparent: {
|
|
38
|
-
bg: light.transparent.
|
|
39
|
-
fg: light.transparent.
|
|
38
|
+
bg: light.transparent.bg,
|
|
39
|
+
fg: light.transparent.fg,
|
|
40
40
|
},
|
|
41
41
|
default: {
|
|
42
|
-
bg: light.default.
|
|
43
|
-
fg: light.default.
|
|
42
|
+
bg: light.default.bg,
|
|
43
|
+
fg: light.default.fg,
|
|
44
44
|
},
|
|
45
45
|
primary: {
|
|
46
|
-
bg: light.primary.
|
|
47
|
-
fg: light.primary.
|
|
46
|
+
bg: light.primary.bg,
|
|
47
|
+
fg: light.primary.fg,
|
|
48
48
|
},
|
|
49
49
|
},
|
|
50
50
|
dark: {
|
|
51
51
|
transparent: {
|
|
52
|
-
bg: dark.transparent.
|
|
53
|
-
fg: dark.transparent.
|
|
52
|
+
bg: dark.transparent.bg,
|
|
53
|
+
fg: dark.transparent.fg,
|
|
54
54
|
},
|
|
55
55
|
default: {
|
|
56
|
-
bg: dark.default.
|
|
57
|
-
fg: dark.default.
|
|
56
|
+
bg: dark.default.bg,
|
|
57
|
+
fg: dark.default.fg,
|
|
58
58
|
},
|
|
59
59
|
primary: {
|
|
60
|
-
bg: dark.primary.
|
|
61
|
-
fg: dark.primary.
|
|
60
|
+
bg: dark.primary.bg,
|
|
61
|
+
fg: dark.primary.fg,
|
|
62
62
|
},
|
|
63
63
|
},
|
|
64
64
|
}).toEqual({
|
|
@@ -135,8 +135,7 @@ test('buildColorTheme: button', () => {
|
|
|
135
135
|
},
|
|
136
136
|
}
|
|
137
137
|
|
|
138
|
-
const light =
|
|
139
|
-
const dark = buildColorScheme({scheme: 'dark'}, {color: tokens})
|
|
138
|
+
const {dark, light} = buildColorTheme({color: tokens})
|
|
140
139
|
|
|
141
140
|
expect({
|
|
142
141
|
light: {
|