@sanity/ui 2.9.0-corel.0 → 2.9.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/_chunks-cjs/getTheme_v2.js +110 -54
- package/dist/_chunks-cjs/getTheme_v2.js.map +1 -1
- package/dist/_chunks-es/getTheme_v2.mjs +110 -54
- package/dist/_chunks-es/getTheme_v2.mjs.map +1 -1
- package/dist/_legacy/getTheme_v2.esm.js +110 -54
- package/dist/_legacy/getTheme_v2.esm.js.map +1 -1
- package/dist/index.d.mts +14 -21
- package/dist/index.d.ts +14 -21
- package/dist/index.esm.js +3327 -3068
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +3328 -3070
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +3327 -3068
- package/dist/index.mjs.map +1 -1
- package/dist/theme.d.mts +8 -8
- package/dist/theme.d.ts +8 -8
- package/dist/theme.esm.js +1144 -592
- package/dist/theme.esm.js.map +1 -1
- package/dist/theme.js +1144 -592
- package/dist/theme.js.map +1 -1
- package/dist/theme.mjs +1144 -592
- package/dist/theme.mjs.map +1 -1
- package/package.json +60 -52
- package/src/core/__workshop__/constants.ts +15 -19
- package/src/core/components/breadcrumbs/__workshop__/example.tsx +1 -3
- package/src/core/components/breadcrumbs/__workshop__/index.ts +0 -5
- package/src/core/components/breadcrumbs/breadcrumbs.styles.ts +13 -1
- package/src/core/components/breadcrumbs/breadcrumbs.tsx +31 -39
- package/src/core/components/dialog/dialog.tsx +4 -2
- package/src/core/components/menu/__workshop__/tones.tsx +5 -6
- package/src/core/components/menu/menu.tsx +15 -11
- package/src/core/components/menu/menuButton.tsx +14 -36
- package/src/core/components/menu/menuGroup.tsx +2 -1
- package/src/core/components/menu/menuItem.tsx +4 -2
- package/src/core/components/tab/tabList.tsx +3 -11
- package/src/core/components/toast/__workshop__/hook.tsx +1 -1
- package/src/core/components/toast/toast.tsx +2 -2
- package/src/core/components/toast/toastProvider.tsx +5 -6
- package/src/core/components/toast/toastState.ts +6 -0
- package/src/core/constants.ts +1 -1
- package/src/core/hooks/useArrayProp.ts +14 -9
- package/src/core/hooks/useElementRect/__workshop__/example.tsx +2 -2
- package/src/core/primitives/avatar/avatarStack.tsx +2 -5
- package/src/core/primitives/badge/__workshop__/tones.tsx +6 -13
- package/src/core/primitives/button/__workshop__/custom.tsx +4 -3
- package/src/core/primitives/button/__workshop__/props.tsx +1 -1
- package/src/core/primitives/button/button.tsx +6 -11
- package/src/core/primitives/button/styles.ts +1 -1
- package/src/core/primitives/card/__workshop__/allTones.tsx +6 -8
- package/src/core/primitives/card/__workshop__/asButton.tsx +42 -24
- package/src/core/primitives/card/__workshop__/asComponent.tsx +1 -1
- package/src/core/primitives/card/__workshop__/checkered.tsx +17 -7
- package/src/core/primitives/card/__workshop__/interactive.tsx +10 -3
- package/src/core/primitives/card/__workshop__/listNavigation.tsx +5 -3
- package/src/core/primitives/card/__workshop__/props.tsx +7 -5
- package/src/core/primitives/card/__workshop__/selected.tsx +4 -1
- package/src/core/primitives/checkbox/__workshop__/tones.tsx +6 -0
- package/src/core/primitives/code/__workshop__/props.tsx +1 -1
- package/src/core/primitives/container/__workshop__/example.tsx +1 -1
- package/src/core/primitives/flex/__workshop__/example.tsx +3 -3
- package/src/core/primitives/flex/flex.tsx +1 -5
- package/src/core/primitives/grid/__workshop__/responsive.tsx +12 -12
- package/src/core/primitives/heading/__workshop__/opticalAlignment.tsx +13 -25
- package/src/core/primitives/heading/heading.tsx +1 -1
- package/src/core/primitives/inline/__workshop__/plain.tsx +3 -3
- package/src/core/primitives/label/__workshop__/opticalAlignment.tsx +6 -6
- package/src/core/primitives/popover/__workshop__/AlignedStory.tsx +1 -1
- package/src/core/primitives/popover/__workshop__/MatchReferenceWidthStory.tsx +3 -3
- package/src/core/primitives/popover/__workshop__/OpenOnMountStory.tsx +1 -1
- package/src/core/primitives/popover/__workshop__/PlainStory.tsx +1 -1
- package/src/core/primitives/popover/popover.tsx +6 -5
- package/src/core/primitives/radio/__workshop__/plain.tsx +2 -2
- package/src/core/primitives/select/__workshop__/readOnly.tsx +1 -1
- package/src/core/primitives/text/__workshop__/example.tsx +6 -6
- package/src/core/primitives/text/__workshop__/opticalAlignment.tsx +11 -21
- package/src/core/primitives/text/styles.ts +0 -1
- package/src/core/primitives/text/text.tsx +2 -4
- package/src/core/primitives/textArea/__workshop__/plain.tsx +1 -1
- package/src/core/primitives/textInput/__workshop__/index.ts +0 -5
- package/src/core/primitives/textInput/__workshop__/plain.tsx +1 -2
- package/src/core/primitives/textInput/__workshop__/readOnly.tsx +6 -2
- package/src/core/primitives/textInput/__workshop__/tones.tsx +38 -0
- package/src/core/styles/card/_cardColorStyle.ts +8 -8
- package/src/core/styles/flex/flexStyle.ts +0 -18
- package/src/core/styles/flex/types.ts +0 -2
- package/src/core/theme/__workshop__/debug/story.tsx +18 -11
- package/src/core/theme/themeProvider.tsx +4 -6
- package/src/core/utils/elementQuery/elementQuery.tsx +16 -17
- package/src/core/utils/layer/layerProvider.tsx +1 -1
- package/src/theme/build/_deprecated/color/muted/createMuted.ts +2 -2
- package/src/theme/build/buildColorTheme.ts +12 -8
- package/src/theme/build/renderColorTheme.ts +54 -232
- package/src/theme/defaults/colorTokens.ts +13 -18
- package/src/theme/system/color/_constants.ts +6 -10
- package/src/theme/versioning/themeColor_v0_v2.ts +26 -26
- package/src/theme/versioning/v0_v2.ts +4 -4
- package/src/core/components/breadcrumbs/__workshop__/buttons.tsx +0 -58
- package/src/core/primitives/textInput/__workshop__/multipleTones.tsx +0 -20
|
@@ -16,8 +16,6 @@ export function responsiveFlexStyle(): Array<
|
|
|
16
16
|
BASE_STYLE,
|
|
17
17
|
responsiveFlexAlignStyle,
|
|
18
18
|
responsiveFlexGapStyle,
|
|
19
|
-
responsiveFlexGapXStyle,
|
|
20
|
-
responsiveFlexGapYStyle,
|
|
21
19
|
responsiveFlexWrapStyle,
|
|
22
20
|
responsiveFlexJustifyStyle,
|
|
23
21
|
responsiveFlexDirectionStyle,
|
|
@@ -42,22 +40,6 @@ function responsiveFlexGapStyle(props: ResponsiveFlexStyleProps & ThemeProps) {
|
|
|
42
40
|
}))
|
|
43
41
|
}
|
|
44
42
|
|
|
45
|
-
function responsiveFlexGapXStyle(props: ResponsiveFlexStyleProps & ThemeProps) {
|
|
46
|
-
const {media, space} = getTheme_v2(props.theme)
|
|
47
|
-
|
|
48
|
-
return _responsive(media, props.$gapX, (gapX) => ({
|
|
49
|
-
columnGap: gapX ? rem(space[gapX]) : undefined,
|
|
50
|
-
}))
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
function responsiveFlexGapYStyle(props: ResponsiveFlexStyleProps & ThemeProps) {
|
|
54
|
-
const {media, space} = getTheme_v2(props.theme)
|
|
55
|
-
|
|
56
|
-
return _responsive(media, props.$gapY, (gapY) => ({
|
|
57
|
-
rowGap: gapY ? rem(space[gapY]) : undefined,
|
|
58
|
-
}))
|
|
59
|
-
}
|
|
60
|
-
|
|
61
43
|
export function responsiveFlexWrapStyle(props: ResponsiveFlexStyleProps & ThemeProps): CSSObject[] {
|
|
62
44
|
const {media} = getTheme_v2(props.theme)
|
|
63
45
|
|
|
@@ -12,7 +12,7 @@ import {
|
|
|
12
12
|
ThemeColorState_v2,
|
|
13
13
|
} from '@sanity/ui/theme'
|
|
14
14
|
import {useBoolean, useSelect} from '@sanity/ui-workshop'
|
|
15
|
-
import {CSSProperties
|
|
15
|
+
import {CSSProperties} from 'react'
|
|
16
16
|
import {Badge, Box, Flex, KBD, Stack, Text} from '../../../primitives'
|
|
17
17
|
import {useRootTheme} from '../../useRootTheme'
|
|
18
18
|
|
|
@@ -50,16 +50,13 @@ export default function DebugStory() {
|
|
|
50
50
|
const button = useBoolean('Button', false, 'Props') || false
|
|
51
51
|
const selectable = useBoolean('Selectable', false, 'Props') || false
|
|
52
52
|
|
|
53
|
-
const features: Features =
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
}),
|
|
61
|
-
[base, button, scheme, selectable, tone],
|
|
62
|
-
)
|
|
53
|
+
const features: Features = {
|
|
54
|
+
base,
|
|
55
|
+
button,
|
|
56
|
+
schemes: scheme == 'all' ? ['light', 'dark'] : [scheme],
|
|
57
|
+
selectable,
|
|
58
|
+
tones: tone == 'all' ? ['transparent', 'default'] : [tone],
|
|
59
|
+
}
|
|
63
60
|
|
|
64
61
|
return (
|
|
65
62
|
<Flex>
|
|
@@ -352,11 +349,21 @@ function getStateVars(state: ThemeColorState_v2) {
|
|
|
352
349
|
'--card-badge-default-fg-color': state.badge.default.fg,
|
|
353
350
|
'--card-badge-default-icon-color': state.badge.default.icon,
|
|
354
351
|
|
|
352
|
+
'--card-badge-neutral-bg-color': state.badge.neutral.bg,
|
|
353
|
+
'--card-badge-neutral-dot-color': state.badge.neutral.dot,
|
|
354
|
+
'--card-badge-neutral-fg-color': state.badge.neutral.fg,
|
|
355
|
+
'--card-badge-neutral-icon-color': state.badge.neutral.icon,
|
|
356
|
+
|
|
355
357
|
'--card-badge-primary-bg-color': state.badge.primary.bg,
|
|
356
358
|
'--card-badge-primary-dot-color': state.badge.primary.dot,
|
|
357
359
|
'--card-badge-primary-fg-color': state.badge.primary.fg,
|
|
358
360
|
'--card-badge-primary-icon-color': state.badge.primary.icon,
|
|
359
361
|
|
|
362
|
+
'--card-badge-suggest-bg-color': state.badge.suggest.bg,
|
|
363
|
+
'--card-badge-suggest-dot-color': state.badge.suggest.dot,
|
|
364
|
+
'--card-badge-suggest-fg-color': state.badge.suggest.fg,
|
|
365
|
+
'--card-badge-suggest-icon-color': state.badge.suggest.icon,
|
|
366
|
+
|
|
360
367
|
'--card-badge-positive-bg-color': state.badge.positive.bg,
|
|
361
368
|
'--card-badge-positive-dot-color': state.badge.positive.dot,
|
|
362
369
|
'--card-badge-positive-fg-color': state.badge.positive.fg,
|
|
@@ -25,12 +25,10 @@ export interface ThemeProviderProps {
|
|
|
25
25
|
*/
|
|
26
26
|
export function ThemeProvider(props: ThemeProviderProps): React.ReactElement {
|
|
27
27
|
const parentTheme = useContext(ThemeContext)
|
|
28
|
-
const {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
tone = parentTheme?.tone || 'default',
|
|
33
|
-
} = props
|
|
28
|
+
const {children} = props
|
|
29
|
+
const scheme = props.scheme ?? (parentTheme?.scheme || 'light')
|
|
30
|
+
const rootTheme = props.theme ?? (parentTheme?.theme || null)
|
|
31
|
+
const tone = props.tone ?? (parentTheme?.tone || 'default')
|
|
34
32
|
|
|
35
33
|
const themeContext: ThemeContextValue | null = useMemo(() => {
|
|
36
34
|
if (!rootTheme) return null
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {forwardRef,
|
|
1
|
+
import {forwardRef, useImperativeHandle, useMemo, useState} from 'react'
|
|
2
2
|
import {useElementSize} from '../../hooks'
|
|
3
3
|
import {useTheme_v2} from '../../theme'
|
|
4
4
|
import {findMaxBreakpoints, findMinBreakpoints} from './helpers'
|
|
@@ -21,31 +21,30 @@ export const ElementQuery = forwardRef(function ElementQuery(
|
|
|
21
21
|
forwardedRef: React.ForwardedRef<HTMLDivElement>,
|
|
22
22
|
) {
|
|
23
23
|
const theme = useTheme_v2()
|
|
24
|
-
const {children, media
|
|
24
|
+
const {children, media: _media, ...restProps} = props
|
|
25
|
+
const media = _media ?? theme.media
|
|
25
26
|
|
|
26
|
-
const ref = useRef<HTMLDivElement | null>(null)
|
|
27
27
|
const [element, setElement] = useState<HTMLDivElement | null>(null)
|
|
28
28
|
const elementSize = useElementSize(element)
|
|
29
29
|
const width = useMemo(() => elementSize?.border.width ?? window.innerWidth, [elementSize])
|
|
30
30
|
|
|
31
|
-
const max = useMemo(() =>
|
|
32
|
-
|
|
31
|
+
const max = useMemo(() => {
|
|
32
|
+
const eq = findMaxBreakpoints(media, width)
|
|
33
33
|
|
|
34
|
-
|
|
34
|
+
return eq.length ? eq.join(' ') : undefined
|
|
35
|
+
}, [media, width])
|
|
36
|
+
const min = useMemo(() => {
|
|
37
|
+
const eq = findMinBreakpoints(media, width)
|
|
35
38
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
39
|
+
return eq.length ? eq.join(' ') : undefined
|
|
40
|
+
}, [media, width])
|
|
41
|
+
|
|
42
|
+
useImperativeHandle<HTMLDivElement | null, HTMLDivElement | null>(forwardedRef, () => element, [
|
|
43
|
+
element,
|
|
44
|
+
])
|
|
40
45
|
|
|
41
46
|
return (
|
|
42
|
-
<div
|
|
43
|
-
data-ui="ElementQuery"
|
|
44
|
-
{...restProps}
|
|
45
|
-
data-eq-max={max.length ? max.join(' ') : undefined}
|
|
46
|
-
data-eq-min={min.length ? min.join(' ') : undefined}
|
|
47
|
-
ref={setRef}
|
|
48
|
-
>
|
|
47
|
+
<div data-ui="ElementQuery" {...restProps} data-eq-max={max} data-eq-min={min} ref={setElement}>
|
|
49
48
|
{children}
|
|
50
49
|
</div>
|
|
51
50
|
)
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import {ThemeColorBase, ThemeColorMuted,
|
|
1
|
+
import {ThemeColorBase, ThemeColorMuted, ThemeColorName} 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: ThemeColorName,
|
|
9
9
|
): ThemeColorMuted {
|
|
10
10
|
return {
|
|
11
11
|
default: {
|
|
@@ -47,11 +47,13 @@ function buildColorScheme(
|
|
|
47
47
|
): ThemeColorScheme_v2 {
|
|
48
48
|
const {scheme} = options
|
|
49
49
|
|
|
50
|
-
|
|
51
|
-
acc[tone] = buildCardColorTheme({scheme, tone}, config)
|
|
50
|
+
const colorScheme = {} as ThemeColorScheme_v2
|
|
52
51
|
|
|
53
|
-
|
|
54
|
-
|
|
52
|
+
for (const tone of THEME_COLOR_CARD_TONES) {
|
|
53
|
+
colorScheme[tone] = buildCardColorTheme({scheme, tone}, config)
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
return colorScheme
|
|
55
57
|
}
|
|
56
58
|
|
|
57
59
|
function buildCardColorTheme(
|
|
@@ -165,11 +167,13 @@ function buildBadgeColorTheme(
|
|
|
165
167
|
): ThemeColorBadge_v2 {
|
|
166
168
|
const {scheme} = options
|
|
167
169
|
|
|
168
|
-
|
|
169
|
-
|
|
170
|
+
const colorBadge = {} as ThemeColorBadge_v2
|
|
171
|
+
|
|
172
|
+
for (const tone of THEME_COLOR_STATE_TONES) {
|
|
173
|
+
colorBadge[tone] = _buildBadgeColorTheme(tokens, {scheme, tone}, config)
|
|
174
|
+
}
|
|
170
175
|
|
|
171
|
-
|
|
172
|
-
}, {} as ThemeColorBadge_v2)
|
|
176
|
+
return colorBadge
|
|
173
177
|
}
|
|
174
178
|
|
|
175
179
|
function _buildBadgeColorTheme(
|