@sanity/ui 2.16.22 → 2.16.23
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/_visual-editing.js +115 -1040
- package/dist/_chunks-cjs/_visual-editing.js.map +1 -1
- package/dist/_chunks-cjs/refractor.js.map +1 -1
- package/dist/_chunks-es/_visual-editing.mjs +115 -1040
- package/dist/_chunks-es/_visual-editing.mjs.map +1 -1
- package/dist/_chunks-es/refractor.mjs.map +1 -1
- package/dist/_visual-editing.d.mts +411 -351
- package/dist/_visual-editing.d.ts +411 -351
- package/dist/index.d.mts +1107 -930
- package/dist/index.d.ts +1107 -930
- package/dist/index.js +64 -155
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +64 -155
- package/dist/index.mjs.map +1 -1
- package/dist/theme.d.mts +769 -681
- package/dist/theme.d.ts +769 -681
- package/dist/theme.js +47 -0
- package/dist/theme.js.map +1 -1
- package/dist/theme.mjs +47 -0
- package/dist/theme.mjs.map +1 -1
- package/exports/_visual-editing.ts +1 -0
- package/package.json +49 -162
- package/src/core/_compat.ts +30 -0
- package/src/core/components/autocomplete/autocomplete.tsx +11 -4
- package/src/core/components/autocomplete/autocompleteOption.tsx +1 -0
- package/src/core/components/breadcrumbs/breadcrumbs.tsx +1 -0
- package/src/core/components/dialog/dialog.tsx +3 -0
- package/src/core/components/hotkeys/hotkeys.tsx +1 -0
- package/src/core/components/menu/menu.test.tsx +6 -4
- package/src/core/components/menu/menu.tsx +3 -2
- package/src/core/components/menu/menuButton.tsx +8 -0
- package/src/core/components/menu/menuGroup.tsx +5 -2
- package/src/core/components/menu/menuItem.tsx +4 -0
- package/src/core/components/menu/useMenuController.ts +6 -4
- package/src/core/components/skeleton/skeleton.tsx +2 -1
- package/src/core/components/tab/tab.tsx +1 -0
- package/src/core/components/tab/tabList.tsx +1 -0
- package/src/core/components/toast/toast.test.tsx +9 -4
- package/src/core/components/tree/tree.tsx +1 -0
- package/src/core/components/tree/treeGroup.tsx +1 -0
- package/src/core/components/tree/treeItem.tsx +2 -2
- package/src/core/hooks/useClickOutside.test.tsx +43 -15
- package/src/core/hooks/useClickOutside.ts +1 -1
- package/src/core/hooks/useClickOutsideEvent.test.tsx +8 -4
- package/src/core/hooks/useDelayed.test.ts +7 -6
- package/src/core/hooks/useElementRect/useElementRect.ts +1 -0
- package/src/core/hooks/useForwardedRef.ts +1 -0
- package/src/core/hooks/useMediaIndex/useMediaIndex.test.tsx +2 -1
- package/src/core/hooks/usePrefersDark.hydration.test.tsx +7 -5
- package/src/core/hooks/usePrefersDark.test.tsx +3 -1
- package/src/core/hooks/usePrefersReducedMotion.hydration.test.tsx +7 -5
- package/src/core/hooks/usePrefersReducedMotion.test.tsx +3 -1
- package/src/core/lib/createGlobalScopedContext.ts +1 -0
- package/src/core/lib/globalScope.ts +1 -0
- package/src/core/observers/elementSizeObserver.ts +1 -0
- package/src/core/primitives/avatar/avatar.tsx +1 -2
- package/src/core/primitives/avatar/avatarStack.tsx +1 -0
- package/src/core/primitives/badge/badge.test.tsx +3 -2
- package/src/core/primitives/badge/badge.tsx +2 -1
- package/src/core/primitives/box/box.tsx +2 -1
- package/src/core/primitives/button/button.test.tsx +3 -2
- package/src/core/primitives/button/button.tsx +2 -0
- package/src/core/primitives/button/styles.ts +1 -0
- package/src/core/primitives/card/card.tsx +1 -5
- package/src/core/primitives/card/types.ts +1 -0
- package/src/core/primitives/code/refractor.tsx +2 -0
- package/src/core/primitives/flex/flex.tsx +1 -3
- package/src/core/primitives/inline/inline.tsx +1 -0
- package/src/core/primitives/popover/popover.tsx +12 -3
- package/src/core/primitives/popover/popoverCard.tsx +1 -0
- package/src/core/primitives/popover/types.ts +0 -1
- package/src/core/primitives/stack/styles.ts +1 -0
- package/src/core/primitives/textInput/textInput.tsx +2 -0
- package/src/core/primitives/tooltip/tooltip.test.tsx +82 -49
- package/src/core/primitives/tooltip/tooltip.tsx +5 -0
- package/src/core/primitives/tooltip/tooltipCard.tsx +1 -0
- package/src/core/primitives/tooltip/tooltipDelayGroup/types.ts +2 -0
- package/src/core/styles/flex/types.ts +0 -1
- package/src/core/styles/font/responsiveFont.ts +0 -3
- package/src/core/styles/font/types.ts +1 -3
- package/src/core/styles/grid/gridStyle.ts +1 -0
- package/src/core/styles/margin/marginStyle.ts +1 -0
- package/src/core/styles/margin/marginsStyle.test.ts +2 -1
- package/src/core/styles/padding/paddingStyle.test.ts +2 -1
- package/src/core/styles/padding/paddingStyle.ts +1 -0
- package/src/core/theme/theme.test.tsx +7 -3
- package/src/core/theme/useRootTheme.ts +1 -0
- package/src/core/theme/useTheme.ts +2 -0
- package/src/core/utils/arrow/arrow.tsx +1 -0
- package/src/core/utils/boundaryElement/boundaryElement.test.tsx +9 -4
- package/src/core/utils/conditionalWrapper/conditionalWrapper.tsx +1 -0
- package/src/core/utils/getElementRef.ts +5 -0
- package/src/core/utils/layer/getLayerContext.test.ts +2 -0
- package/src/core/utils/layer/layer.test.tsx +9 -4
- package/src/core/utils/layer/layer.tsx +1 -0
- package/src/core/utils/layer/useLayer.ts +2 -0
- package/src/core/utils/portal/portal.test.tsx +9 -4
- package/src/core/utils/portal/portalProvider.tsx +4 -3
- package/src/core/utils/virtualList/virtualList.tsx +2 -1
- package/src/theme/build/_deprecated/color/_selectable/createSelectableTones.ts +10 -0
- package/src/theme/build/_deprecated/color/_solid/createSolidTones.ts +4 -0
- package/src/theme/build/_deprecated/color/button/createButtonModes.ts +5 -0
- package/src/theme/build/_deprecated/color/button/createButtonTones.ts +5 -0
- package/src/theme/build/_deprecated/color/card/createCardStates.ts +6 -0
- package/src/theme/build/_deprecated/color/color.test.ts +5 -1
- package/src/theme/build/_deprecated/color/defaults.ts +1 -0
- package/src/theme/build/_deprecated/color/factory.ts +36 -0
- package/src/theme/build/_deprecated/color/input/createInputModes.ts +5 -0
- package/src/theme/build/_deprecated/color/muted/createMuted.ts +4 -0
- package/src/theme/build/_deprecated/color/spot/createSpot.ts +3 -0
- package/src/theme/build/buildColorTheme.test.ts +2 -0
- package/src/theme/build/buildColorTheme.ts +7 -0
- package/src/theme/build/buildTheme.test.ts +2 -0
- package/src/theme/build/lib/color-fns/color-fns.test.ts +3 -1
- package/src/theme/build/merge.ts +5 -0
- package/src/theme/build/mixThemeColor.test.ts +2 -0
- package/src/theme/build/renderColorTheme.ts +6 -0
- package/src/theme/build/renderColorValue.ts +0 -2
- package/src/theme/build/resolveColorTokens.ts +6 -0
- package/src/theme/build/theme.test.ts +2 -0
- package/src/theme/config/helpers.ts +5 -0
- package/src/theme/config/system.ts +2 -0
- package/src/theme/config/tokens/color/types.ts +6 -4
- package/src/theme/config/tokens/parseTokenKey.test.ts +2 -0
- package/src/theme/config/tokens/parseTokenValue.test.ts +2 -0
- package/src/theme/config/tokens/parseTokenValue.ts +1 -0
- package/src/theme/getScopedTheme.ts +5 -0
- package/src/theme/system/color/_helpers.ts +4 -0
- package/src/theme/system/theme.ts +4 -0
- package/src/theme/system/v0/color/_system.ts +1 -0
- package/src/theme/system/v0/color/button.ts +14 -0
- package/src/theme/system/v0/color/card.ts +6 -0
- package/src/theme/system/v0/color/color.ts +11 -0
- package/src/theme/system/v0/color/input.ts +6 -0
- package/src/theme/system/v0/color/muted.ts +11 -0
- package/src/theme/system/v0/color/selectable.ts +11 -0
- package/src/theme/system/v0/color/solid.ts +11 -0
- package/src/theme/system/v0/color/spot.ts +1 -0
- package/src/theme/versioning/getTheme_v2.ts +15 -0
- package/src/theme/versioning/themeColor_v0_v2.ts +7 -0
- package/src/theme/versioning/themeColor_v2_v2_9.ts +1 -0
- package/src/theme/versioning/v0_v2.ts +13 -1
- package/src/theme/versioning/v2_v0.ts +15 -0
- package/src/core/__workshop__/constants.ts +0 -293
- package/src/core/components/autocomplete/__mocks__/apiStore.ts +0 -49
- package/src/core/components/autocomplete/__mocks__/countries.ts +0 -245
- package/src/core/components/autocomplete/__workshop__/async.tsx +0 -156
- package/src/core/components/autocomplete/__workshop__/constrainedHeight.tsx +0 -137
- package/src/core/components/autocomplete/__workshop__/custom.tsx +0 -89
- package/src/core/components/autocomplete/__workshop__/example.tsx +0 -79
- package/src/core/components/autocomplete/__workshop__/focusAndBlur.tsx +0 -36
- package/src/core/components/autocomplete/__workshop__/fullscreen.tsx +0 -294
- package/src/core/components/autocomplete/__workshop__/index.ts +0 -39
- package/src/core/components/autocomplete/__workshop__/types.ts +0 -4
- package/src/core/components/breadcrumbs/__workshop__/example.tsx +0 -62
- package/src/core/components/breadcrumbs/__workshop__/index.ts +0 -14
- package/src/core/components/dialog/__workshop__/activate.tsx +0 -134
- package/src/core/components/dialog/__workshop__/autoFocus.tsx +0 -29
- package/src/core/components/dialog/__workshop__/index.ts +0 -19
- package/src/core/components/dialog/__workshop__/layering.tsx +0 -41
- package/src/core/components/dialog/__workshop__/nested.tsx +0 -72
- package/src/core/components/dialog/__workshop__/onScroll.tsx +0 -39
- package/src/core/components/dialog/__workshop__/panes.tsx +0 -82
- package/src/core/components/dialog/__workshop__/position.tsx +0 -30
- package/src/core/components/dialog/__workshop__/props.tsx +0 -75
- package/src/core/components/dialog/__workshop__/provider.tsx +0 -11
- package/src/core/components/dialog/__workshop__/wrapped.tsx +0 -76
- package/src/core/components/hotkeys/__workshop__/index.ts +0 -14
- package/src/core/components/hotkeys/__workshop__/plain.tsx +0 -9
- package/src/core/components/menu/__workshop__/asComponent.tsx +0 -45
- package/src/core/components/menu/__workshop__/avatarMenu.tsx +0 -51
- package/src/core/components/menu/__workshop__/closableMenuButton.tsx +0 -46
- package/src/core/components/menu/__workshop__/constrainedInBoundary.tsx +0 -134
- package/src/core/components/menu/__workshop__/customMenuItem.tsx +0 -45
- package/src/core/components/menu/__workshop__/customSelectedState.tsx +0 -39
- package/src/core/components/menu/__workshop__/disableFocusOnClose.tsx +0 -40
- package/src/core/components/menu/__workshop__/groups.tsx +0 -156
- package/src/core/components/menu/__workshop__/index.ts +0 -89
- package/src/core/components/menu/__workshop__/menuButton.tsx +0 -80
- package/src/core/components/menu/__workshop__/menuGroupRight.tsx +0 -65
- package/src/core/components/menu/__workshop__/nestedMenu.tsx +0 -22
- package/src/core/components/menu/__workshop__/onCloseMenuButton.tsx +0 -41
- package/src/core/components/menu/__workshop__/selectedItem.tsx +0 -69
- package/src/core/components/menu/__workshop__/shouldFocus.tsx +0 -47
- package/src/core/components/menu/__workshop__/tones.tsx +0 -25
- package/src/core/components/menu/__workshop__/withoutArrow.tsx +0 -32
- package/src/core/components/skeleton/__workshop__/delay.tsx +0 -70
- package/src/core/components/skeleton/__workshop__/index.ts +0 -11
- package/src/core/components/skeleton/__workshop__/skeleton.tsx +0 -64
- package/src/core/components/tab/__workshop__/example.tsx +0 -79
- package/src/core/components/tab/__workshop__/index.ts +0 -14
- package/src/core/components/toast/__workshop__/hook.tsx +0 -71
- package/src/core/components/toast/__workshop__/index.ts +0 -19
- package/src/core/components/toast/__workshop__/toast.tsx +0 -26
- package/src/core/components/tree/__workshop__/basic.perf.ts +0 -19
- package/src/core/components/tree/__workshop__/basic.tsx +0 -105
- package/src/core/components/tree/__workshop__/index.ts +0 -21
- package/src/core/components/tree/__workshop__/tabFromElement.tsx +0 -84
- package/src/core/hooks/useElementRect/__workshop__/example.tsx +0 -32
- package/src/core/hooks/useElementRect/__workshop__/index.ts +0 -14
- package/src/core/hooks/useMediaIndex/__workshop__/index.ts +0 -14
- package/src/core/hooks/useMediaIndex/__workshop__/test.tsx +0 -14
- package/src/core/primitives/avatar/__workshop__/asButton.tsx +0 -14
- package/src/core/primitives/avatar/__workshop__/index.ts +0 -29
- package/src/core/primitives/avatar/__workshop__/stack.tsx +0 -25
- package/src/core/primitives/avatar/__workshop__/withinButton.tsx +0 -63
- package/src/core/primitives/avatar/__workshop__/withinMenuItem.tsx +0 -70
- package/src/core/primitives/badge/__workshop__/index.ts +0 -19
- package/src/core/primitives/badge/__workshop__/props.tsx +0 -30
- package/src/core/primitives/badge/__workshop__/tones.tsx +0 -21
- package/src/core/primitives/box/__workshop__/index.ts +0 -19
- package/src/core/primitives/box/__workshop__/props.tsx +0 -20
- package/src/core/primitives/box/__workshop__/responsive.tsx +0 -20
- package/src/core/primitives/button/__workshop__/custom.tsx +0 -51
- package/src/core/primitives/button/__workshop__/customIcons.tsx +0 -30
- package/src/core/primitives/button/__workshop__/disabled.tsx +0 -74
- package/src/core/primitives/button/__workshop__/index.ts +0 -59
- package/src/core/primitives/button/__workshop__/mixedChildren.tsx +0 -12
- package/src/core/primitives/button/__workshop__/props.tsx +0 -55
- package/src/core/primitives/button/__workshop__/sanityUploadButton.tsx +0 -36
- package/src/core/primitives/button/__workshop__/stacked.tsx +0 -58
- package/src/core/primitives/button/__workshop__/styled1.tsx +0 -17
- package/src/core/primitives/button/__workshop__/styled2.tsx +0 -19
- package/src/core/primitives/button/__workshop__/uploadButton.tsx +0 -28
- package/src/core/primitives/card/__workshop__/allTones.tsx +0 -25
- package/src/core/primitives/card/__workshop__/asButton.tsx +0 -107
- package/src/core/primitives/card/__workshop__/asComponent.tsx +0 -27
- package/src/core/primitives/card/__workshop__/checkered.tsx +0 -26
- package/src/core/primitives/card/__workshop__/index.ts +0 -18
- package/src/core/primitives/card/__workshop__/interactive.tsx +0 -30
- package/src/core/primitives/card/__workshop__/listNavigation.tsx +0 -80
- package/src/core/primitives/card/__workshop__/props.tsx +0 -53
- package/src/core/primitives/card/__workshop__/selected.tsx +0 -94
- package/src/core/primitives/card/__workshop__/styled.tsx +0 -14
- package/src/core/primitives/checkbox/__workshop__/example.tsx +0 -25
- package/src/core/primitives/checkbox/__workshop__/index.ts +0 -13
- package/src/core/primitives/checkbox/__workshop__/props.tsx +0 -33
- package/src/core/primitives/checkbox/__workshop__/readOnly.tsx +0 -16
- package/src/core/primitives/checkbox/__workshop__/tones.tsx +0 -28
- package/src/core/primitives/code/__workshop__/index.ts +0 -19
- package/src/core/primitives/code/__workshop__/opticalAlignment.tsx +0 -48
- package/src/core/primitives/code/__workshop__/props.tsx +0 -21
- package/src/core/primitives/container/__workshop__/example.tsx +0 -20
- package/src/core/primitives/container/__workshop__/index.ts +0 -8
- package/src/core/primitives/flex/__workshop__/example.tsx +0 -34
- package/src/core/primitives/flex/__workshop__/gap.tsx +0 -25
- package/src/core/primitives/flex/__workshop__/index.ts +0 -11
- package/src/core/primitives/grid/__workshop__/index.ts +0 -10
- package/src/core/primitives/grid/__workshop__/responsive.tsx +0 -54
- package/src/core/primitives/heading/__workshop__/index.ts +0 -19
- package/src/core/primitives/heading/__workshop__/opticalAlignment.tsx +0 -54
- package/src/core/primitives/heading/__workshop__/plain.tsx +0 -32
- package/src/core/primitives/inline/__workshop__/index.ts +0 -8
- package/src/core/primitives/inline/__workshop__/plain.tsx +0 -27
- package/src/core/primitives/kbd/__workshop__/index.ts +0 -8
- package/src/core/primitives/kbd/__workshop__/plain.tsx +0 -9
- package/src/core/primitives/label/__workshop__/index.ts +0 -19
- package/src/core/primitives/label/__workshop__/opticalAlignment.tsx +0 -48
- package/src/core/primitives/label/__workshop__/plain.tsx +0 -24
- package/src/core/primitives/popover/__workshop__/AlignedStory.tsx +0 -77
- package/src/core/primitives/popover/__workshop__/MarginsStory.tsx +0 -31
- package/src/core/primitives/popover/__workshop__/MatchReferenceWidthStory.tsx +0 -32
- package/src/core/primitives/popover/__workshop__/OpenOnMountStory.tsx +0 -11
- package/src/core/primitives/popover/__workshop__/PlainStory.tsx +0 -71
- package/src/core/primitives/popover/__workshop__/RecursiveStory.tsx +0 -71
- package/src/core/primitives/popover/__workshop__/SidePanelStory.tsx +0 -89
- package/src/core/primitives/popover/__workshop__/TestStory.tsx +0 -97
- package/src/core/primitives/popover/__workshop__/index.ts +0 -49
- package/src/core/primitives/radio/__workshop__/example.tsx +0 -63
- package/src/core/primitives/radio/__workshop__/index.ts +0 -11
- package/src/core/primitives/radio/__workshop__/plain.tsx +0 -28
- package/src/core/primitives/select/__workshop__/index.ts +0 -11
- package/src/core/primitives/select/__workshop__/plain.tsx +0 -27
- package/src/core/primitives/select/__workshop__/readOnly.tsx +0 -23
- package/src/core/primitives/spinner/__workshop__/Props.tsx +0 -15
- package/src/core/primitives/spinner/__workshop__/index.ts +0 -14
- package/src/core/primitives/stack/__workshop__/index.ts +0 -14
- package/src/core/primitives/stack/__workshop__/plain.tsx +0 -32
- package/src/core/primitives/switch/__workshop__/example.tsx +0 -23
- package/src/core/primitives/switch/__workshop__/index.ts +0 -11
- package/src/core/primitives/switch/__workshop__/props.tsx +0 -21
- package/src/core/primitives/text/__workshop__/colored.tsx +0 -30
- package/src/core/primitives/text/__workshop__/example.tsx +0 -39
- package/src/core/primitives/text/__workshop__/index.ts +0 -24
- package/src/core/primitives/text/__workshop__/opticalAlignment.tsx +0 -48
- package/src/core/primitives/textArea/__workshop__/index.ts +0 -14
- package/src/core/primitives/textArea/__workshop__/plain.tsx +0 -50
- package/src/core/primitives/textInput/__workshop__/clearButton.tsx +0 -30
- package/src/core/primitives/textInput/__workshop__/customValidity.tsx +0 -17
- package/src/core/primitives/textInput/__workshop__/index.ts +0 -44
- package/src/core/primitives/textInput/__workshop__/plain.tsx +0 -98
- package/src/core/primitives/textInput/__workshop__/readOnly.tsx +0 -9
- package/src/core/primitives/textInput/__workshop__/states.tsx +0 -53
- package/src/core/primitives/textInput/__workshop__/tones.tsx +0 -277
- package/src/core/primitives/textInput/__workshop__/typed.tsx +0 -23
- package/src/core/primitives/tooltip/__workshop__/customPortal.tsx +0 -102
- package/src/core/primitives/tooltip/__workshop__/index.ts +0 -29
- package/src/core/primitives/tooltip/__workshop__/overflowingBoundary.tsx +0 -74
- package/src/core/primitives/tooltip/__workshop__/props.tsx +0 -107
- package/src/core/primitives/tooltip/__workshop__/resizableBoundary.tsx +0 -86
- package/src/core/theme/__workshop__/build/Root.tsx +0 -367
- package/src/core/theme/__workshop__/build/helpers.ts +0 -46
- package/src/core/theme/__workshop__/build/story.tsx +0 -465
- package/src/core/theme/__workshop__/canvas.tsx +0 -352
- package/src/core/theme/__workshop__/color.tsx +0 -62
- package/src/core/theme/__workshop__/debug/story.tsx +0 -408
- package/src/core/theme/__workshop__/index.ts +0 -39
- package/src/core/theme/__workshop__/layer.tsx +0 -78
- package/src/core/theme/__workshop__/nestedProvider.tsx +0 -15
- package/src/core/utils/boundaryElement/__workshop__/index.ts +0 -14
- package/src/core/utils/boundaryElement/__workshop__/plain.tsx +0 -19
- package/src/core/utils/elementQuery/__workshop__/customMedia.tsx +0 -30
- package/src/core/utils/elementQuery/__workshop__/index.ts +0 -14
- package/src/core/utils/layer/__workshop__/_debug.tsx +0 -17
- package/src/core/utils/layer/__workshop__/index.ts +0 -24
- package/src/core/utils/layer/__workshop__/multipleRoots.tsx +0 -49
- package/src/core/utils/layer/__workshop__/nested.tsx +0 -98
- package/src/core/utils/layer/__workshop__/responsiveZOffset.tsx +0 -13
- package/src/core/utils/portal/__workshop__/index.ts +0 -14
- package/src/core/utils/portal/__workshop__/named.tsx +0 -63
- package/src/core/utils/virtualList/__workshop__/changingProps.tsx +0 -36
- package/src/core/utils/virtualList/__workshop__/elementScroll.tsx +0 -24
- package/src/core/utils/virtualList/__workshop__/index.ts +0 -29
- package/src/core/utils/virtualList/__workshop__/infiniteList.tsx +0 -48
- package/src/core/utils/virtualList/__workshop__/windowScrolll.tsx +0 -22
|
@@ -1,352 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
Box,
|
|
3
|
-
Card,
|
|
4
|
-
CardTone,
|
|
5
|
-
Flex,
|
|
6
|
-
Grid,
|
|
7
|
-
Stack,
|
|
8
|
-
Text,
|
|
9
|
-
ThemeColorProvider,
|
|
10
|
-
useRootTheme,
|
|
11
|
-
} from '@sanity/ui'
|
|
12
|
-
import {
|
|
13
|
-
getContrastRatio,
|
|
14
|
-
mix,
|
|
15
|
-
parseColor,
|
|
16
|
-
rgbToHex,
|
|
17
|
-
ThemeColorButton_v2,
|
|
18
|
-
ThemeColorButtonMode_v2,
|
|
19
|
-
ThemeColorButtonTone_v2,
|
|
20
|
-
ThemeColorCard_v2,
|
|
21
|
-
ThemeColorScheme_v2,
|
|
22
|
-
ThemeColorSelectable_v2,
|
|
23
|
-
ThemeColorSelectableTone_v2,
|
|
24
|
-
ThemeColorState_v2,
|
|
25
|
-
} from '@sanity/ui/theme'
|
|
26
|
-
import {useBoolean} from '@sanity/ui-workshop'
|
|
27
|
-
import {createContext, useContext} from 'react'
|
|
28
|
-
|
|
29
|
-
interface Features {
|
|
30
|
-
light: boolean
|
|
31
|
-
dark: boolean
|
|
32
|
-
|
|
33
|
-
base: boolean
|
|
34
|
-
button: boolean
|
|
35
|
-
input: boolean
|
|
36
|
-
selectable: boolean
|
|
37
|
-
spot: boolean
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
const defaultFeatures: Features = {
|
|
41
|
-
light: true,
|
|
42
|
-
dark: false,
|
|
43
|
-
|
|
44
|
-
base: false,
|
|
45
|
-
button: false,
|
|
46
|
-
input: false,
|
|
47
|
-
selectable: false,
|
|
48
|
-
spot: false,
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
const FeaturesContext = createContext<Features>(defaultFeatures)
|
|
52
|
-
|
|
53
|
-
function useFeatures() {
|
|
54
|
-
return useContext(FeaturesContext)
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
export default function CanvasStory() {
|
|
58
|
-
const {theme} = useRootTheme()
|
|
59
|
-
const features: Features = {
|
|
60
|
-
...defaultFeatures,
|
|
61
|
-
light: useBoolean('Light', defaultFeatures.light, 'Props') ?? defaultFeatures.light,
|
|
62
|
-
dark: useBoolean('Dark', defaultFeatures.dark, 'Props') ?? defaultFeatures.dark,
|
|
63
|
-
base: useBoolean('Base', defaultFeatures.base, 'Props') ?? defaultFeatures.base,
|
|
64
|
-
button: useBoolean('Button', defaultFeatures.button, 'Props') ?? defaultFeatures.button,
|
|
65
|
-
input: useBoolean('Input', defaultFeatures.input, 'Props') ?? defaultFeatures.input,
|
|
66
|
-
selectable:
|
|
67
|
-
useBoolean('Selectable', defaultFeatures.selectable, 'Props') ?? defaultFeatures.selectable,
|
|
68
|
-
spot: useBoolean('Avatar', defaultFeatures.spot, 'Props') ?? defaultFeatures.spot,
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
return (
|
|
72
|
-
<FeaturesContext.Provider value={features}>
|
|
73
|
-
<Flex>
|
|
74
|
-
{features.light && (
|
|
75
|
-
<ThemeColorProvider scheme="light">
|
|
76
|
-
<ColorScheme scheme={theme.v2!.color.light} />
|
|
77
|
-
</ThemeColorProvider>
|
|
78
|
-
)}
|
|
79
|
-
|
|
80
|
-
{features.dark && (
|
|
81
|
-
<ThemeColorProvider scheme="dark">
|
|
82
|
-
<ColorScheme scheme={theme.v2!.color.dark} />
|
|
83
|
-
</ThemeColorProvider>
|
|
84
|
-
)}
|
|
85
|
-
</Flex>
|
|
86
|
-
</FeaturesContext.Provider>
|
|
87
|
-
)
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
function ColorScheme(props: {scheme: ThemeColorScheme_v2}) {
|
|
91
|
-
const {scheme} = props
|
|
92
|
-
|
|
93
|
-
return (
|
|
94
|
-
<Flex direction="column" flex={1}>
|
|
95
|
-
<Color color={scheme.default} tone="default" />
|
|
96
|
-
<Color color={scheme.transparent} tone="transparent" />
|
|
97
|
-
<Color color={scheme.primary} tone="primary" />
|
|
98
|
-
<Color color={scheme.positive} tone="positive" />
|
|
99
|
-
<Color color={scheme.caution} tone="caution" />
|
|
100
|
-
<Color color={scheme.critical} tone="critical" />
|
|
101
|
-
</Flex>
|
|
102
|
-
)
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
function Color(props: {color: ThemeColorCard_v2; tone: CardTone}) {
|
|
106
|
-
const {color, tone} = props
|
|
107
|
-
const features = useFeatures()
|
|
108
|
-
|
|
109
|
-
return (
|
|
110
|
-
<Card padding={[3, 4]} tone={tone}>
|
|
111
|
-
<Stack
|
|
112
|
-
space={[3, 4]}
|
|
113
|
-
// style={{outline: '1px solid #ccc'}}
|
|
114
|
-
>
|
|
115
|
-
{features.base && <ColorBase color={color} />}
|
|
116
|
-
|
|
117
|
-
{features.button && <ColorButton color={color.button} />}
|
|
118
|
-
|
|
119
|
-
{features.input && (
|
|
120
|
-
<Box padding={2} style={{backgroundColor: color.input.default.enabled.bg}}>
|
|
121
|
-
<Text style={{color: 'inherit'}}>Input</Text>
|
|
122
|
-
</Box>
|
|
123
|
-
)}
|
|
124
|
-
|
|
125
|
-
{/* {features.muted && <ColorMuted color={color.muted} />} */}
|
|
126
|
-
|
|
127
|
-
{/* eslint-disable-next-line no-warning-comments */}
|
|
128
|
-
{/* @todo: remove use of `muted` here */}
|
|
129
|
-
{features.selectable && <ColorSelectable color={color.selectable || color.muted} />}
|
|
130
|
-
|
|
131
|
-
{/* {features.solid && <ColorSolid color={color.solid} />} */}
|
|
132
|
-
|
|
133
|
-
{features.spot && (
|
|
134
|
-
<Flex gap={1}>
|
|
135
|
-
<Box flex={1} style={{backgroundColor: color.avatar?.blue.bg, width: 25, height: 25}} />
|
|
136
|
-
<Box
|
|
137
|
-
flex={1}
|
|
138
|
-
style={{backgroundColor: color.avatar?.purple.bg, width: 25, height: 25}}
|
|
139
|
-
/>
|
|
140
|
-
<Box
|
|
141
|
-
flex={1}
|
|
142
|
-
style={{backgroundColor: color.avatar?.magenta.bg, width: 25, height: 25}}
|
|
143
|
-
/>
|
|
144
|
-
<Box flex={1} style={{backgroundColor: color.avatar?.red.bg, width: 25, height: 25}} />
|
|
145
|
-
<Box
|
|
146
|
-
flex={1}
|
|
147
|
-
style={{backgroundColor: color.avatar?.yellow.bg, width: 25, height: 25}}
|
|
148
|
-
/>
|
|
149
|
-
<Box
|
|
150
|
-
flex={1}
|
|
151
|
-
style={{backgroundColor: color.avatar?.green.bg, width: 25, height: 25}}
|
|
152
|
-
/>
|
|
153
|
-
<Box flex={1} style={{backgroundColor: color.avatar?.cyan.bg, width: 25, height: 25}} />
|
|
154
|
-
<Box flex={1} style={{backgroundColor: color.avatar?.gray.bg, width: 25, height: 25}} />
|
|
155
|
-
</Flex>
|
|
156
|
-
)}
|
|
157
|
-
</Stack>
|
|
158
|
-
</Card>
|
|
159
|
-
)
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
function ColorBase(props: {color: ThemeColorCard_v2}) {
|
|
163
|
-
const {color} = props
|
|
164
|
-
|
|
165
|
-
return (
|
|
166
|
-
<Stack
|
|
167
|
-
padding={3}
|
|
168
|
-
space={2}
|
|
169
|
-
style={{
|
|
170
|
-
borderRadius: 3,
|
|
171
|
-
boxShadow: `inset 0 0 0 1px ${color.border}`,
|
|
172
|
-
}}
|
|
173
|
-
>
|
|
174
|
-
<Text>Text</Text>
|
|
175
|
-
<Text muted>Muted</Text>
|
|
176
|
-
|
|
177
|
-
<Text accent>Accent</Text>
|
|
178
|
-
<Text>
|
|
179
|
-
{/* eslint-disable-next-line jsx-a11y/anchor-is-valid */}
|
|
180
|
-
<a href="#">Link</a>
|
|
181
|
-
</Text>
|
|
182
|
-
<Text>
|
|
183
|
-
<code>Code</code>
|
|
184
|
-
</Text>
|
|
185
|
-
<div
|
|
186
|
-
style={{
|
|
187
|
-
height: 9,
|
|
188
|
-
background: `linear-gradient(to right, ${color.skeleton?.from}, ${color.skeleton?.to})`,
|
|
189
|
-
}}
|
|
190
|
-
/>
|
|
191
|
-
</Stack>
|
|
192
|
-
)
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
function ColorButton(props: {color: ThemeColorButton_v2}) {
|
|
196
|
-
const {color} = props
|
|
197
|
-
|
|
198
|
-
return (
|
|
199
|
-
<Stack space={3}>
|
|
200
|
-
<ColorButtonMode color={color.default} />
|
|
201
|
-
<ColorButtonMode color={color.ghost} />
|
|
202
|
-
<ColorButtonMode color={color.bleed} />
|
|
203
|
-
</Stack>
|
|
204
|
-
)
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
function ColorButtonMode(props: {color: ThemeColorButtonMode_v2}) {
|
|
208
|
-
const {color} = props
|
|
209
|
-
|
|
210
|
-
return (
|
|
211
|
-
<Stack space={1}>
|
|
212
|
-
<Grid columns={5} marginBottom={1} gap={1}>
|
|
213
|
-
<Box>
|
|
214
|
-
<Text align="center" muted size={1}>
|
|
215
|
-
Enabled
|
|
216
|
-
</Text>
|
|
217
|
-
</Box>
|
|
218
|
-
<Box>
|
|
219
|
-
<Text align="center" muted size={1}>
|
|
220
|
-
Hovered
|
|
221
|
-
</Text>
|
|
222
|
-
</Box>
|
|
223
|
-
<Box>
|
|
224
|
-
<Text align="center" muted size={1}>
|
|
225
|
-
Pressed
|
|
226
|
-
</Text>
|
|
227
|
-
</Box>
|
|
228
|
-
<Box>
|
|
229
|
-
<Text align="center" muted size={1}>
|
|
230
|
-
Selected
|
|
231
|
-
</Text>
|
|
232
|
-
</Box>
|
|
233
|
-
<Box>
|
|
234
|
-
<Text align="center" muted size={1}>
|
|
235
|
-
Disabled
|
|
236
|
-
</Text>
|
|
237
|
-
</Box>
|
|
238
|
-
</Grid>
|
|
239
|
-
<ColorGenericStates color={color.default} />
|
|
240
|
-
<ColorGenericStates color={color.primary} />
|
|
241
|
-
<ColorGenericStates color={color.positive} />
|
|
242
|
-
<ColorGenericStates color={color.caution} />
|
|
243
|
-
<ColorGenericStates color={color.critical} />
|
|
244
|
-
</Stack>
|
|
245
|
-
)
|
|
246
|
-
}
|
|
247
|
-
|
|
248
|
-
function ColorGenericStates(props: {color: ThemeColorButtonTone_v2}) {
|
|
249
|
-
const {color} = props
|
|
250
|
-
|
|
251
|
-
return (
|
|
252
|
-
<Grid columns={5} gap={1}>
|
|
253
|
-
<ColorGenericState color={color.enabled} />
|
|
254
|
-
<ColorGenericState color={color.hovered} />
|
|
255
|
-
<ColorGenericState color={color.pressed} />
|
|
256
|
-
<ColorGenericState color={color.selected} />
|
|
257
|
-
<ColorGenericState color={color.disabled} />
|
|
258
|
-
</Grid>
|
|
259
|
-
)
|
|
260
|
-
}
|
|
261
|
-
|
|
262
|
-
function _contrast(baseBg: string, bg: string, fg: string) {
|
|
263
|
-
const baseBgRgb = parseColor(baseBg)
|
|
264
|
-
let bgRgb = parseColor(bg)
|
|
265
|
-
|
|
266
|
-
if (typeof bgRgb.a === 'number') {
|
|
267
|
-
bgRgb = mix(baseBgRgb, bgRgb, bgRgb.a)
|
|
268
|
-
}
|
|
269
|
-
|
|
270
|
-
return getContrastRatio(rgbToHex(bgRgb), fg)
|
|
271
|
-
}
|
|
272
|
-
|
|
273
|
-
function ColorGenericState(props: {color: ThemeColorState_v2}) {
|
|
274
|
-
const {color} = props
|
|
275
|
-
|
|
276
|
-
return (
|
|
277
|
-
<Stack
|
|
278
|
-
padding={2}
|
|
279
|
-
space={2}
|
|
280
|
-
style={{
|
|
281
|
-
backgroundColor: color.bg,
|
|
282
|
-
color: color.fg,
|
|
283
|
-
border: `1px solid ${color.border}`,
|
|
284
|
-
borderRadius: 3,
|
|
285
|
-
}}
|
|
286
|
-
>
|
|
287
|
-
<Flex style={{border: `1px solid ${color.border}`}}>
|
|
288
|
-
<Box flex={1} padding={3} style={{backgroundColor: color.bg}}>
|
|
289
|
-
<Text align="center" size={1} style={{color: 'inherit'}}>
|
|
290
|
-
bg
|
|
291
|
-
</Text>
|
|
292
|
-
</Box>
|
|
293
|
-
<Box flex={1} padding={3} style={{backgroundColor: color.muted.bg}}>
|
|
294
|
-
<Text align="center" size={1} style={{color: 'inherit'}}>
|
|
295
|
-
bg2
|
|
296
|
-
</Text>
|
|
297
|
-
</Box>
|
|
298
|
-
</Flex>
|
|
299
|
-
|
|
300
|
-
<Text align="center" size={1} style={{color: 'inherit'}}>
|
|
301
|
-
Text – {_contrast(color.bg, color.bg, color.fg).toFixed(2)}
|
|
302
|
-
</Text>
|
|
303
|
-
<Text align="center" size={1} style={{color: color.muted.fg}}>
|
|
304
|
-
Muted – {_contrast(color.bg, color.bg, color.muted.fg).toFixed(2)}
|
|
305
|
-
</Text>
|
|
306
|
-
<Text align="center" size={1} style={{color: color.link.fg}}>
|
|
307
|
-
Link – {_contrast(color.bg, color.bg, color.link.fg).toFixed(2)}
|
|
308
|
-
</Text>
|
|
309
|
-
<Text align="center" size={1} style={{color: color.accent.fg}}>
|
|
310
|
-
Accent – {_contrast(color.bg, color.bg, color.accent.fg).toFixed(2)}
|
|
311
|
-
</Text>
|
|
312
|
-
<Text align="center" size={1} style={{color: color.code.fg}}>
|
|
313
|
-
<span style={{backgroundColor: color.code.bg}}>Code</span> –{' '}
|
|
314
|
-
{_contrast(color.bg, color.code.bg, color.code.fg).toFixed(2)}
|
|
315
|
-
</Text>
|
|
316
|
-
<div
|
|
317
|
-
style={{
|
|
318
|
-
height: 9,
|
|
319
|
-
background: `linear-gradient(to right, ${color.skeleton?.from}, ${color.skeleton?.to})`,
|
|
320
|
-
}}
|
|
321
|
-
/>
|
|
322
|
-
</Stack>
|
|
323
|
-
)
|
|
324
|
-
}
|
|
325
|
-
|
|
326
|
-
function ColorSelectable(props: {color: ThemeColorSelectable_v2}) {
|
|
327
|
-
const {color} = props
|
|
328
|
-
|
|
329
|
-
return (
|
|
330
|
-
<Stack space={1}>
|
|
331
|
-
<ColorSelectableTone color={color.default} />
|
|
332
|
-
<ColorSelectableTone color={color.primary} />
|
|
333
|
-
<ColorSelectableTone color={color.positive} />
|
|
334
|
-
<ColorSelectableTone color={color.caution} />
|
|
335
|
-
<ColorSelectableTone color={color.critical} />
|
|
336
|
-
</Stack>
|
|
337
|
-
)
|
|
338
|
-
}
|
|
339
|
-
|
|
340
|
-
function ColorSelectableTone(props: {color: ThemeColorSelectableTone_v2}) {
|
|
341
|
-
const {color} = props
|
|
342
|
-
|
|
343
|
-
return (
|
|
344
|
-
<Grid columns={5} gap={1}>
|
|
345
|
-
<ColorGenericState color={color.enabled} />
|
|
346
|
-
<ColorGenericState color={color.hovered} />
|
|
347
|
-
<ColorGenericState color={color.pressed} />
|
|
348
|
-
<ColorGenericState color={color.selected} />
|
|
349
|
-
<ColorGenericState color={color.disabled} />
|
|
350
|
-
</Grid>
|
|
351
|
-
)
|
|
352
|
-
}
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
import {Box, Card, Tree, TreeItem, useRootTheme} from '@sanity/ui'
|
|
2
|
-
|
|
3
|
-
export default function ColorStory() {
|
|
4
|
-
const {theme} = useRootTheme()
|
|
5
|
-
|
|
6
|
-
if (!theme.color) {
|
|
7
|
-
return null
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
return (
|
|
11
|
-
<Box padding={[4, 5, 6]}>
|
|
12
|
-
<Tree space={1}>
|
|
13
|
-
{Object.entries(theme.color).map(([key, value]) => (
|
|
14
|
-
<ColorGroup key={key} name={key} value={value} />
|
|
15
|
-
))}
|
|
16
|
-
</Tree>
|
|
17
|
-
</Box>
|
|
18
|
-
)
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
function ColorGroup({name, value}: {name: string; value: Record<string, unknown>}) {
|
|
22
|
-
const entries = Object.entries(value)
|
|
23
|
-
|
|
24
|
-
return (
|
|
25
|
-
<TreeItem fontSize={1} padding={2} text={name}>
|
|
26
|
-
{entries.map(([key, value]) => {
|
|
27
|
-
if (value && typeof value === 'object') {
|
|
28
|
-
return <ColorGroup key={key} name={key} value={value as Record<string, unknown>} />
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
if (typeof value !== 'string') {
|
|
32
|
-
return null
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
return <ColorPreview key={key} name={key} value={value} />
|
|
36
|
-
})}
|
|
37
|
-
</TreeItem>
|
|
38
|
-
)
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
function ColorPreview({name, value}: {name: string; value: string}) {
|
|
42
|
-
const text = (
|
|
43
|
-
<>
|
|
44
|
-
<Card
|
|
45
|
-
radius={2}
|
|
46
|
-
style={{
|
|
47
|
-
backgroundColor: value,
|
|
48
|
-
boxShadow: 'inset 0 0 0 1px var(--card-shadow-outline-color)',
|
|
49
|
-
display: 'inline-block',
|
|
50
|
-
height: 17,
|
|
51
|
-
width: 25,
|
|
52
|
-
margin: '0 8px -6px 0',
|
|
53
|
-
verticalAlign: 'top',
|
|
54
|
-
}}
|
|
55
|
-
tone="inherit"
|
|
56
|
-
/>
|
|
57
|
-
{name} <code>{value}</code>
|
|
58
|
-
</>
|
|
59
|
-
)
|
|
60
|
-
|
|
61
|
-
return <TreeItem fontSize={1} padding={2} text={text} />
|
|
62
|
-
}
|