@sanity/ui 3.0.0-static.10 → 3.0.0-static.12
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 +1300 -1269
- package/dist/_chunks-cjs/_visual-editing.js.map +1 -1
- package/dist/_chunks-cjs/buildCommand.js +28 -10
- package/dist/_chunks-cjs/buildCommand.js.map +1 -1
- package/dist/_chunks-es/_visual-editing.mjs +1298 -1263
- package/dist/_chunks-es/_visual-editing.mjs.map +1 -1
- package/dist/_visual-editing.d.mts +516 -360
- package/dist/_visual-editing.d.ts +516 -360
- package/dist/cli.js +1 -1
- package/dist/css.d.mts +258 -75
- package/dist/css.d.ts +258 -75
- package/dist/css.js +746 -752
- package/dist/css.js.map +1 -1
- package/dist/css.mjs +748 -754
- package/dist/css.mjs.map +1 -1
- package/dist/index.d.mts +1342 -871
- package/dist/index.d.ts +1342 -871
- package/dist/index.js +433 -325
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +429 -321
- package/dist/index.mjs.map +1 -1
- package/dist/sanity-palette.css +105 -1
- package/dist/sanity-palette.min.css +1 -0
- package/dist/sanity-theme.css +4571 -1
- package/dist/sanity-theme.min.css +1 -0
- package/dist/system.css +22053 -21710
- package/dist/system.min.css +1 -0
- package/dist/theme.d.mts +51 -106
- package/dist/theme.d.ts +51 -106
- package/dist/theme.js +19 -20
- package/dist/theme.js.map +1 -1
- package/dist/theme.mjs +19 -20
- package/dist/theme.mjs.map +1 -1
- package/package.json +10 -5
- package/src/cli/buildCommand.ts +46 -19
- package/src/css/_comp.ts +2 -2
- package/src/css/{compile/compileStyle.ts → _compileStyle.ts} +7 -7
- package/src/css/_resp.ts +0 -1
- package/src/css/{system.style.ts → _system.style.ts} +3 -2
- package/src/css/aspects/display/display.ts +1 -0
- package/src/css/aspects/display/types.ts +2 -3
- package/src/css/aspects/flex/types.ts +4 -12
- package/src/css/aspects/flexItem/types.ts +1 -3
- package/src/css/aspects/font/font.style.ts +7 -66
- package/src/css/aspects/font/types.ts +1 -3
- package/src/css/aspects/grid/grid.ts +1 -0
- package/src/css/aspects/grid/types.ts +5 -9
- package/src/css/aspects/gridItem/gridItem.ts +1 -1
- package/src/css/aspects/gridItem/types.ts +7 -18
- package/src/css/aspects/height/height.ts +3 -4
- package/src/css/aspects/inset/inset.ts +1 -0
- package/src/css/aspects/margin/margin.ts +1 -0
- package/src/css/aspects/margin/types.ts +1 -0
- package/src/css/aspects/maxWidth/maxWidth.ts +1 -0
- package/src/css/aspects/maxWidth/types.ts +1 -0
- package/src/css/aspects/minWidth/minWidth.ts +1 -0
- package/src/css/aspects/minWidth/types.ts +2 -0
- package/src/css/aspects/overflow/overflow.ts +1 -0
- package/src/css/aspects/padding/padding.ts +1 -0
- package/src/css/aspects/pointerEvents/pointerEvents.ts +1 -0
- package/src/css/aspects/position/position.ts +1 -0
- package/src/css/aspects/shadow/shadow.style.ts +16 -41
- package/src/css/aspects/shadow/shadow.ts +1 -0
- package/src/css/aspects/textOverflow/textOverflow.ts +1 -0
- package/src/css/aspects/textOverflow/types.ts +1 -0
- package/src/css/aspects/width/types.ts +2 -0
- package/src/css/aspects/width/width.ts +1 -0
- package/src/css/compilePalette.ts +32 -0
- package/src/css/compileSystem.ts +7 -0
- package/src/css/{compile/compileTheme.ts → compileTheme.ts} +1 -0
- package/src/css/compileTheme_v3.ts +434 -0
- package/src/css/components/breadcrumbs/breadcrumbs.ts +1 -0
- package/src/css/components/dialog/dialog.ts +7 -0
- package/src/css/components/menu/menu.ts +2 -0
- package/src/css/components/skeleton/skeleton.style.ts +8 -4
- package/src/css/components/skeleton/skeleton.ts +4 -0
- package/src/css/components/skeleton/types.ts +4 -0
- package/src/css/components/toast/toast.ts +5 -0
- package/src/css/components/tree/tree.ts +1 -0
- package/src/css/composeClassNames.ts +4 -2
- package/src/css/constants.ts +11 -0
- package/src/css/index.ts +4 -3
- package/src/css/primitives/_arrow/_arrow.style.ts +6 -8
- package/src/css/primitives/_arrow/_arrow.ts +7 -0
- package/src/css/primitives/_input/input.ts +2 -0
- package/src/css/primitives/_selectable/_selectable.style.ts +24 -25
- package/src/css/primitives/_selectable/selectable.ts +1 -2
- package/src/css/primitives/avatar/avatar.style.ts +5 -8
- package/src/css/primitives/avatar/avatar.ts +6 -0
- package/src/css/primitives/avatar/types.ts +1 -0
- package/src/css/primitives/box/types.ts +1 -3
- package/src/css/primitives/button/button.style.ts +48 -15
- package/src/css/primitives/button/button.ts +4 -21
- package/src/css/primitives/button/index.ts +1 -0
- package/src/css/primitives/button/types.ts +18 -0
- package/src/css/primitives/card/card.style.ts +4 -7
- package/src/css/primitives/card/card.ts +2 -2
- package/src/css/primitives/card/types.ts +2 -2
- package/src/css/primitives/checkbox/checkbox.ts +2 -0
- package/src/css/primitives/container/container.ts +1 -0
- package/src/css/primitives/container/types.ts +1 -0
- package/src/css/primitives/kbd/kbd.ts +1 -0
- package/src/css/primitives/label/types.ts +7 -2
- package/src/css/primitives/popover/popover.ts +2 -0
- package/src/css/primitives/radio/radio.ts +1 -0
- package/src/css/primitives/select/select.ts +2 -0
- package/src/css/primitives/spinner/spinner.ts +2 -0
- package/src/css/primitives/switch/switch.ts +5 -0
- package/src/css/primitives/text/types.ts +4 -0
- package/src/css/primitives/textArea/textArea.ts +1 -0
- package/src/css/primitives/textInput/textInput.ts +1 -0
- package/src/css/primitives/token/token.style.ts +37 -36
- package/src/css/primitives/tooltip/tooltip.ts +2 -0
- package/src/css/responsiveRules.ts +12 -19
- package/src/css/scopeClassName.ts +1 -0
- package/src/css/types.ts +115 -15
- package/src/css/util.ts +5 -0
- package/src/css/utils/srOnly/srOnly.ts +1 -0
- package/src/css/varNames.ts +230 -143
- package/src/css/vars.ts +53 -22
- package/src/theme/palette/constants.ts +2 -0
- package/src/theme/palette/types.ts +3 -0
- package/src/theme/types.ts +2 -6
- package/src/theme/v0/focusRing.ts +1 -3
- package/src/theme/v0/font.ts +6 -18
- package/src/theme/v0/layer.ts +1 -3
- package/src/theme/v0/shadow.ts +2 -6
- package/src/theme/v2/avatar.ts +1 -3
- package/src/theme/v2/color/_system.ts +1 -3
- package/src/theme/v2/color/avatar.ts +2 -6
- package/src/theme/v2/color/badge.ts +2 -6
- package/src/theme/v2/color/button.ts +3 -9
- package/src/theme/v2/color/color.ts +3 -9
- package/src/theme/v2/color/input.ts +3 -9
- package/src/theme/v2/color/kbd.ts +1 -3
- package/src/theme/v2/color/selectable.ts +2 -6
- package/src/theme/v2/color/state.ts +1 -3
- package/src/theme/v2/color/syntax.ts +1 -3
- package/src/theme/v2/input.ts +1 -3
- package/src/theme/v2/theme.ts +2 -6
- package/src/theme/v3/buildTheme_v3.ts +2 -1
- package/src/theme/v3/color/color.ts +6 -4
- package/src/theme/v3/color/renderColor.ts +4 -1
- package/src/theme/v3/{defaults.ts → defaultTokens.ts} +2 -2
- package/src/theme/v3/index.ts +1 -1
- package/src/theme/v3/resolveTokens.ts +18 -18
- package/src/ui/RootClassNames.tsx +44 -0
- package/src/ui/StyleTags.tsx +3 -1
- package/src/ui/_compat/helpers.ts +72 -0
- package/src/ui/_compat/index.ts +2 -6
- package/src/ui/_compat/studioTheme.ts +7 -0
- package/src/ui/_compat/theme/themeColorProvider.tsx +2 -6
- package/src/ui/_compat/theme/themeProvider.tsx +2 -6
- package/src/ui/_compat/theme/types.ts +1 -3
- package/src/ui/_compat/theme/useRootTheme.ts +1 -3
- package/src/ui/_compat/theme/useTheme.ts +2 -6
- package/src/ui/_compat/types.ts +0 -83
- package/src/ui/components/autocomplete/__workshop__/constrainedHeight.tsx +2 -2
- package/src/ui/components/autocomplete/autocomplete.tsx +86 -114
- package/src/ui/components/autocomplete/autocompleteOption.tsx +2 -0
- package/src/ui/components/autocomplete/types.ts +3 -8
- package/src/ui/components/breadcrumbs/breadcrumbs.tsx +27 -21
- package/src/ui/components/dialog/dialog.tsx +89 -291
- package/src/ui/components/dialog/dialogCard.tsx +183 -0
- package/src/ui/components/dialog/isTargetWithinScope.ts +14 -0
- package/src/ui/components/hotkeys/hotkeys.tsx +33 -15
- package/src/ui/components/menu/__workshop__/asComponent.tsx +6 -6
- package/src/ui/components/menu/menu.tsx +27 -33
- package/src/ui/components/menu/menuButton.tsx +10 -14
- package/src/ui/components/menu/menuDivider.tsx +25 -13
- package/src/ui/components/menu/menuGroup.tsx +34 -26
- package/src/ui/components/menu/menuItem.tsx +51 -40
- package/src/ui/components/skeleton/codeSkeleton.tsx +53 -0
- package/src/ui/components/skeleton/headingSkeleton.tsx +52 -0
- package/src/ui/components/skeleton/index.ts +3 -0
- package/src/ui/components/skeleton/labelSkeleton.tsx +51 -0
- package/src/ui/components/skeleton/skeleton.tsx +39 -16
- package/src/ui/components/skeleton/textSkeleton.tsx +31 -110
- package/src/ui/components/tab/tab.tsx +23 -19
- package/src/ui/components/tab/tabList.tsx +34 -33
- package/src/ui/components/tab/tabPanel.tsx +25 -19
- package/src/ui/components/toast/toast.tsx +21 -16
- package/src/ui/components/toast/toastLayer.tsx +28 -10
- package/src/ui/components/toast/toastProvider.tsx +2 -6
- package/src/ui/components/toast/types.ts +2 -6
- package/src/ui/components/toast/useToast.ts +1 -3
- package/src/ui/components/tree/tree.tsx +194 -187
- package/src/ui/components/tree/treeGroup.tsx +25 -5
- package/src/ui/components/tree/treeItem.tsx +35 -23
- package/src/ui/hooks/useClickOutside.ts +2 -6
- package/src/ui/hooks/useClickOutsideEvent.ts +3 -9
- package/src/ui/index.ts +1 -0
- package/src/ui/primitives/_selectable/selectable.tsx +33 -20
- package/src/ui/primitives/avatar/avatar.tsx +28 -31
- package/src/ui/primitives/avatar/avatarCounter.tsx +33 -25
- package/src/ui/primitives/avatar/avatarStack.tsx +31 -24
- package/src/ui/primitives/avatar/types.ts +2 -0
- package/src/ui/primitives/badge/__workshop__/props.tsx +1 -9
- package/src/ui/primitives/badge/__workshop__/tones.tsx +1 -6
- package/src/ui/primitives/badge/badge.tsx +33 -32
- package/src/ui/primitives/badge/types.ts +2 -1
- package/src/ui/primitives/box/box.tsx +59 -29
- package/src/ui/primitives/button/__workshop__/sanityUploadButton.tsx +3 -3
- package/src/ui/primitives/button/__workshop__/uploadButton.tsx +2 -1
- package/src/ui/primitives/button/button.test.tsx +1 -15
- package/src/ui/primitives/button/button.tsx +63 -70
- package/src/ui/primitives/card/__workshop__/asComponent.tsx +3 -3
- package/src/ui/primitives/card/card.tsx +22 -22
- package/src/ui/primitives/card/cardProvider.tsx +2 -0
- package/src/ui/primitives/checkbox/checkbox.tsx +26 -15
- package/src/ui/primitives/code/code.tsx +24 -22
- package/src/ui/primitives/container/container.tsx +26 -15
- package/src/ui/primitives/flex/flex.tsx +21 -19
- package/src/ui/primitives/grid/grid.tsx +21 -16
- package/src/ui/primitives/heading/heading.tsx +42 -19
- package/src/ui/primitives/inline/inline.tsx +26 -23
- package/src/ui/primitives/kbd/kbd.tsx +25 -23
- package/src/ui/primitives/label/label.tsx +29 -26
- package/src/ui/primitives/popover/popover.tsx +293 -271
- package/src/ui/primitives/popover/popoverCard.tsx +122 -120
- package/src/ui/primitives/radio/radio.tsx +30 -14
- package/src/ui/primitives/select/select.tsx +24 -16
- package/src/ui/primitives/spinner/animatedSpinnerIcon.tsx +4 -2
- package/src/ui/primitives/spinner/spinner.tsx +24 -12
- package/src/ui/primitives/stack/stack.tsx +27 -18
- package/src/ui/primitives/switch/switch.tsx +31 -14
- package/src/ui/primitives/text/text.tsx +30 -24
- package/src/ui/primitives/textArea/textArea.tsx +33 -18
- package/src/ui/primitives/textInput/textInput.tsx +28 -40
- package/src/ui/primitives/tooltip/constants.ts +1 -1
- package/src/ui/primitives/tooltip/tooltip.tsx +85 -61
- package/src/ui/primitives/tooltip/tooltipCard.tsx +89 -82
- package/src/ui/primitives/types.ts +1 -3
- package/src/ui/types/avatar.ts +3 -6
- package/src/ui/types/badge.ts +1 -3
- package/src/ui/types/button.ts +1 -3
- package/src/ui/types/card.ts +1 -3
- package/src/ui/types/dialog.ts +1 -3
- package/src/ui/types/props.ts +20 -10
- package/src/ui/utils/arrow/arrow.tsx +43 -25
- package/src/ui/utils/boundaryElement/boundaryElementProvider.tsx +2 -6
- package/src/ui/utils/boundaryElement/types.ts +1 -3
- package/src/ui/utils/boundaryElement/useBoundaryElement.ts +1 -3
- package/src/ui/utils/elementQuery/elementQuery.tsx +43 -19
- package/src/ui/utils/errorBoundary.tsx +2 -0
- package/src/ui/utils/index.ts +0 -1
- package/src/ui/utils/layer/layer.tsx +23 -93
- package/src/ui/utils/layer/layerCard.tsx +92 -0
- package/src/ui/utils/layer/layerProvider.tsx +2 -6
- package/src/ui/utils/layer/useLayer.ts +1 -3
- package/src/ui/utils/portal/portal.ts +2 -6
- package/src/ui/utils/portal/portalProvider.tsx +2 -6
- package/src/ui/utils/portal/types.ts +1 -3
- package/src/ui/utils/portal/usePortal.ts +1 -3
- package/src/ui/utils/srOnly/srOnly.tsx +25 -20
- package/src/ui/utils/virtualList/virtualList.tsx +69 -50
- package/src/css/compile/compilePalette.ts +0 -27
- package/src/css/compile/compileRule.ts +0 -97
- package/src/css/compile/compileRules.test.ts +0 -36
- package/src/css/compile/compileRules.ts +0 -43
- package/src/css/compile/compileSystem.ts +0 -10
- package/src/css/compile/compileTheme_v3.ts +0 -401
- package/src/css/compile/types.ts +0 -6
- package/src/css/components/breadcrumbs/rules.ts +0 -25
- package/src/css/components/dialog/rules.ts +0 -78
- package/src/css/components/skeleton/rules.ts +0 -113
- package/src/css/components/toast/rules.ts +0 -18
- package/src/css/components/tree/rules.ts +0 -168
- package/src/css/primitives/_selectable/_contants.ts +0 -11
- package/src/css/primitives/card/_constants.ts +0 -13
- package/src/css/primitives/popover/rules.ts +0 -5
- package/src/css/primitives/spinner/rules.ts +0 -21
- package/src/css/primitives/token/rules.ts +0 -45
- package/src/ui/utils/conditionalWrapper/conditionalWrapper.tsx +0 -23
- package/src/ui/utils/conditionalWrapper/index.ts +0 -1
|
@@ -3,10 +3,12 @@ import {composeClassNames} from '../../composeClassNames'
|
|
|
3
3
|
import {_input, _inputPresentation} from '../_input'
|
|
4
4
|
import {SelectStyleProps} from './types'
|
|
5
5
|
|
|
6
|
+
/** @public */
|
|
6
7
|
export function select(props: SelectStyleProps): string | undefined {
|
|
7
8
|
return composeClassNames(_comp('select'), _input(props))
|
|
8
9
|
}
|
|
9
10
|
|
|
11
|
+
/** @public */
|
|
10
12
|
export function selectPresentation(): string | undefined {
|
|
11
13
|
return composeClassNames(_comp('select-presentation'), _inputPresentation())
|
|
12
14
|
}
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import {_comp} from '../../_comp'
|
|
2
2
|
|
|
3
|
+
/** @public */
|
|
3
4
|
export function spinner(): string | undefined {
|
|
4
5
|
return _comp('spinner')
|
|
5
6
|
}
|
|
6
7
|
|
|
8
|
+
/** @public */
|
|
7
9
|
export function animatedSpinnerIcon(): string | undefined {
|
|
8
10
|
return _comp('animated-spinner-icon')
|
|
9
11
|
}
|
|
@@ -1,21 +1,26 @@
|
|
|
1
1
|
import {_comp} from '../../_comp'
|
|
2
2
|
|
|
3
|
+
/** @public */
|
|
3
4
|
export function _switch(): string | undefined {
|
|
4
5
|
return _comp('switch')
|
|
5
6
|
}
|
|
6
7
|
|
|
8
|
+
/** @public */
|
|
7
9
|
export function _switchElement(): string | undefined {
|
|
8
10
|
return _comp('switch-element')
|
|
9
11
|
}
|
|
10
12
|
|
|
13
|
+
/** @public */
|
|
11
14
|
export function _switchPresentation(): string | undefined {
|
|
12
15
|
return _comp('switch-presentation')
|
|
13
16
|
}
|
|
14
17
|
|
|
18
|
+
/** @public */
|
|
15
19
|
export function _switchThumb(): string | undefined {
|
|
16
20
|
return _comp('switch-thumb')
|
|
17
21
|
}
|
|
18
22
|
|
|
23
|
+
/** @public */
|
|
19
24
|
export function _switchTrack(): string | undefined {
|
|
20
25
|
return _comp('switch-track')
|
|
21
26
|
}
|
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
import {FlexItemStyleProps, FontStyleProps} from '../../aspects'
|
|
2
2
|
import {ResponsiveProp} from '../../types'
|
|
3
3
|
|
|
4
|
+
/** @public */
|
|
4
5
|
export type TextSize = number
|
|
5
6
|
|
|
6
7
|
/** @public */
|
|
7
8
|
export interface TextStyleProps extends FlexItemStyleProps, FontStyleProps {
|
|
9
|
+
/**
|
|
10
|
+
* @deprecated Will be removed in next major version
|
|
11
|
+
*/
|
|
8
12
|
accent?: boolean
|
|
9
13
|
muted?: boolean
|
|
10
14
|
size?: ResponsiveProp<TextSize>
|
|
@@ -3,6 +3,7 @@ import {composeClassNames} from '../../composeClassNames'
|
|
|
3
3
|
import {_input} from '../_input'
|
|
4
4
|
import {TextAreaStyleProps} from './types'
|
|
5
5
|
|
|
6
|
+
/** @public */
|
|
6
7
|
export function textArea(props: TextAreaStyleProps): string | undefined {
|
|
7
8
|
return composeClassNames(_comp('text-area'), _input(props))
|
|
8
9
|
}
|
|
@@ -3,6 +3,7 @@ import {composeClassNames} from '../../composeClassNames'
|
|
|
3
3
|
import {_input} from '../_input'
|
|
4
4
|
import {TextInputStyleProps} from './types'
|
|
5
5
|
|
|
6
|
+
/** @public */
|
|
6
7
|
export function textInput(props: TextInputStyleProps): string | undefined {
|
|
7
8
|
return composeClassNames(_input(props), _comp('text-input'))
|
|
8
9
|
}
|
|
@@ -1,47 +1,48 @@
|
|
|
1
1
|
import {Style, StyleRules} from '../../types'
|
|
2
|
+
import {vars} from '../../vars'
|
|
2
3
|
|
|
3
4
|
const primitive: StyleRules = {
|
|
4
5
|
'.token': {
|
|
5
6
|
'_prefix': false,
|
|
6
7
|
|
|
7
8
|
'@nest': {
|
|
8
|
-
'&.atrule': {color:
|
|
9
|
-
'&.attr-name': {color:
|
|
10
|
-
'&.attr-value': {color:
|
|
11
|
-
'&.attribute': {color:
|
|
12
|
-
'&.boolean': {color:
|
|
13
|
-
'&.builtin': {color:
|
|
14
|
-
'&.cdata': {color:
|
|
15
|
-
'&.char': {color:
|
|
16
|
-
'&.class': {color:
|
|
17
|
-
'&.class-name': {color:
|
|
18
|
-
'&.comment': {color:
|
|
19
|
-
'&.constant': {color:
|
|
20
|
-
'&.deleted': {color:
|
|
21
|
-
'&.doctype': {color:
|
|
22
|
-
'&.entity': {color:
|
|
23
|
-
'&.function': {color:
|
|
24
|
-
'&.hexcode': {color:
|
|
25
|
-
'&.id': {color:
|
|
26
|
-
'&.important': {color:
|
|
27
|
-
'&.inserted': {color:
|
|
28
|
-
'&.keyword': {color:
|
|
29
|
-
'&.number': {color:
|
|
30
|
-
'&.operator': {color:
|
|
31
|
-
'&.prolog': {color:
|
|
32
|
-
'&.property': {color:
|
|
33
|
-
'&.pseudo-class': {color:
|
|
34
|
-
'&.pseudo-element': {color:
|
|
35
|
-
'&.punctuation': {color:
|
|
9
|
+
'&.atrule': {color: vars.color.code.token.atrule},
|
|
10
|
+
'&.attr-name': {color: vars.color.code.token.attrName},
|
|
11
|
+
'&.attr-value': {color: vars.color.code.token.attrValue},
|
|
12
|
+
'&.attribute': {color: vars.color.code.token.attribute},
|
|
13
|
+
'&.boolean': {color: vars.color.code.token.boolean},
|
|
14
|
+
'&.builtin': {color: vars.color.code.token.builtin},
|
|
15
|
+
'&.cdata': {color: vars.color.code.token.cdata},
|
|
16
|
+
'&.char': {color: vars.color.code.token.char},
|
|
17
|
+
'&.class': {color: vars.color.code.token.class},
|
|
18
|
+
'&.class-name': {color: vars.color.code.token.className},
|
|
19
|
+
'&.comment': {color: vars.color.code.token.comment},
|
|
20
|
+
'&.constant': {color: vars.color.code.token.constant},
|
|
21
|
+
'&.deleted': {color: vars.color.code.token.deleted},
|
|
22
|
+
'&.doctype': {color: vars.color.code.token.doctype},
|
|
23
|
+
'&.entity': {color: vars.color.code.token.entity},
|
|
24
|
+
'&.function': {color: vars.color.code.token.function},
|
|
25
|
+
'&.hexcode': {color: vars.color.code.token.hexcode},
|
|
26
|
+
'&.id': {color: vars.color.code.token.id},
|
|
27
|
+
'&.important': {color: vars.color.code.token.important},
|
|
28
|
+
'&.inserted': {color: vars.color.code.token.inserted},
|
|
29
|
+
'&.keyword': {color: vars.color.code.token.keyword},
|
|
30
|
+
'&.number': {color: vars.color.code.token.number},
|
|
31
|
+
'&.operator': {color: vars.color.code.token.operator},
|
|
32
|
+
'&.prolog': {color: vars.color.code.token.prolog},
|
|
33
|
+
'&.property': {color: vars.color.code.token.property},
|
|
34
|
+
'&.pseudo-class': {color: vars.color.code.token.pseudoClass},
|
|
35
|
+
'&.pseudo-element': {color: vars.color.code.token.pseudoElement},
|
|
36
|
+
'&.punctuation': {color: vars.color.code.token.punctuation},
|
|
36
37
|
'&.attr-value &:not(.attr-equals).punctuation': {color: 'inherit'},
|
|
37
|
-
'&.regex': {color:
|
|
38
|
-
'&.selector': {color:
|
|
39
|
-
'&.string': {color:
|
|
40
|
-
'&.symbol': {color:
|
|
41
|
-
'&.tag': {color:
|
|
42
|
-
'&.unit': {color:
|
|
43
|
-
'&.url': {color:
|
|
44
|
-
'&.variable': {color:
|
|
38
|
+
'&.regex': {color: vars.color.code.token.regex},
|
|
39
|
+
'&.selector': {color: vars.color.code.token.selector},
|
|
40
|
+
'&.string': {color: vars.color.code.token.string},
|
|
41
|
+
'&.symbol': {color: vars.color.code.token.symbol},
|
|
42
|
+
'&.tag': {color: vars.color.code.token.tag},
|
|
43
|
+
'&.unit': {color: vars.color.code.token.unit},
|
|
44
|
+
'&.url': {color: vars.color.code.token.url},
|
|
45
|
+
'&.variable': {color: vars.color.code.token.variable},
|
|
45
46
|
},
|
|
46
47
|
},
|
|
47
48
|
}
|
|
@@ -1,25 +1,18 @@
|
|
|
1
|
+
import {BREAKPOINTS} from './constants'
|
|
1
2
|
import {type Properties, type Rules} from './types'
|
|
2
3
|
|
|
3
4
|
export function responsiveRules(className: string, props: Properties): Rules {
|
|
4
|
-
|
|
5
|
+
const rules: Rules = {
|
|
5
6
|
[className]: props,
|
|
6
|
-
[`_1:${className}`]: {
|
|
7
|
-
'@media': {'screen and (min-width: 360px)': props},
|
|
8
|
-
},
|
|
9
|
-
[`_2:${className}`]: {
|
|
10
|
-
'@media': {'screen and (min-width: 600px)': props},
|
|
11
|
-
},
|
|
12
|
-
[`_3:${className}`]: {
|
|
13
|
-
'@media': {'screen and (min-width: 900px)': props},
|
|
14
|
-
},
|
|
15
|
-
[`_4:${className}`]: {
|
|
16
|
-
'@media': {'screen and (min-width: 1200px)': props},
|
|
17
|
-
},
|
|
18
|
-
[`_5:${className}`]: {
|
|
19
|
-
'@media': {'screen and (min-width: 1800px)': props},
|
|
20
|
-
},
|
|
21
|
-
[`_6:${className}`]: {
|
|
22
|
-
'@media': {'screen and (min-width: 2400px)': props},
|
|
23
|
-
},
|
|
24
7
|
}
|
|
8
|
+
|
|
9
|
+
for (const [index, width] of Object.entries(BREAKPOINTS)) {
|
|
10
|
+
rules[`_${index}:${className}`] = {
|
|
11
|
+
'@media': {
|
|
12
|
+
[`screen and (min-width: ${width}px)`]: props,
|
|
13
|
+
},
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
return rules
|
|
25
18
|
}
|
package/src/css/types.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import {ColorTintKey} from '@sanity/color'
|
|
1
2
|
import {
|
|
2
3
|
type AvatarSize,
|
|
3
4
|
type ContainerWidth,
|
|
@@ -58,7 +59,7 @@ export type ThemeVarName =
|
|
|
58
59
|
| `--card-border-width`
|
|
59
60
|
| `--card-focus-ring-offset`
|
|
60
61
|
| `--card-focus-ring-width`
|
|
61
|
-
| `--shadow-outline`
|
|
62
|
+
| `--card-shadow-outline`
|
|
62
63
|
| `--container-${ContainerWidth}`
|
|
63
64
|
| `--font-code-family`
|
|
64
65
|
| `--font-code-feature-settings`
|
|
@@ -127,8 +128,8 @@ export type ThemeVarName =
|
|
|
127
128
|
| `--shadow-${Shadow}-penumbra`
|
|
128
129
|
| `--shadow-${Shadow}-ambient`
|
|
129
130
|
|
|
131
|
+
/** @public */
|
|
130
132
|
export type ColorCardVarName =
|
|
131
|
-
| `--color-${Scheme}-${CardTone}-accent-fg`
|
|
132
133
|
| `--color-${Scheme}-${CardTone}-avatar-${AvatarColor}-bg`
|
|
133
134
|
| `--color-${Scheme}-${CardTone}-avatar-${AvatarColor}-fg`
|
|
134
135
|
| `--color-${Scheme}-${CardTone}-backdrop`
|
|
@@ -182,8 +183,8 @@ export type ColorCardVarName =
|
|
|
182
183
|
| `--color-${Scheme}-${CardTone}-skeleton-from`
|
|
183
184
|
| `--color-${Scheme}-${CardTone}-skeleton-to`
|
|
184
185
|
|
|
186
|
+
/** @public */
|
|
185
187
|
export type ColorCardToneScopedVarName =
|
|
186
|
-
| `--color-${CardTone}-accent-fg`
|
|
187
188
|
| `--color-${CardTone}-avatar-${AvatarColor}-bg`
|
|
188
189
|
| `--color-${CardTone}-avatar-${AvatarColor}-fg`
|
|
189
190
|
| `--color-${CardTone}-backdrop`
|
|
@@ -239,7 +240,6 @@ export type ColorCardToneScopedVarName =
|
|
|
239
240
|
|
|
240
241
|
/** @public */
|
|
241
242
|
export type CardScopedVarName =
|
|
242
|
-
| `--color-accent-fg`
|
|
243
243
|
| `--color-avatar-bg`
|
|
244
244
|
| `--color-avatar-fg`
|
|
245
245
|
| `--color-avatar-${AvatarColor}-bg`
|
|
@@ -325,12 +325,14 @@ export type CardScopedVarName =
|
|
|
325
325
|
| `--padding-bottom`
|
|
326
326
|
| `--padding-left`
|
|
327
327
|
|
|
328
|
+
/** @public */
|
|
328
329
|
export type AvatarScopedVarName =
|
|
329
330
|
| `--avatar-bg-color`
|
|
330
331
|
| `--avatar-fg-color`
|
|
331
332
|
| `--avatar-distance`
|
|
332
333
|
| `--avatar-size`
|
|
333
334
|
|
|
335
|
+
/** @public */
|
|
334
336
|
export type LegacyCardScopedVarName =
|
|
335
337
|
// legacy
|
|
336
338
|
| `--card-accent-fg-color`
|
|
@@ -370,6 +372,7 @@ export type LegacyCardScopedVarName =
|
|
|
370
372
|
export type ElementColorVariantScopedVarName =
|
|
371
373
|
`--color-${ElementColorVariant}-${ElementColorVariantKey}`
|
|
372
374
|
|
|
375
|
+
/** @public */
|
|
373
376
|
export type ButtonScopedVarName = '--button-box-shadow'
|
|
374
377
|
|
|
375
378
|
/** @public */
|
|
@@ -496,15 +499,13 @@ export interface ColorElementVarNames {
|
|
|
496
499
|
}
|
|
497
500
|
}
|
|
498
501
|
|
|
502
|
+
/** @public */
|
|
499
503
|
export interface ColorVariantVarNames
|
|
500
504
|
extends ColorElementVarNames,
|
|
501
505
|
Record<ElementTone, ColorElementVarNames> {}
|
|
502
506
|
|
|
503
507
|
/** @public */
|
|
504
508
|
export interface ColorCardVarNames {
|
|
505
|
-
accent: {
|
|
506
|
-
fg: VarName
|
|
507
|
-
}
|
|
508
509
|
avatar: Record<AvatarColor, ColorAvatarColorVarNames>
|
|
509
510
|
backdrop: VarName
|
|
510
511
|
code: {
|
|
@@ -576,10 +577,8 @@ export interface ColorCardVarNames {
|
|
|
576
577
|
/** @public */
|
|
577
578
|
export type ColorSchemeVarNames = Record<CardTone, ColorCardVarNames>
|
|
578
579
|
|
|
580
|
+
/** @public */
|
|
579
581
|
export interface ScopedColorVarNames extends Omit<ColorCardVarNames, 'avatar'> {
|
|
580
|
-
accent: {
|
|
581
|
-
fg: VarName
|
|
582
|
-
}
|
|
583
582
|
avatar: Record<AvatarColor, ColorAvatarColorVarNames> & ColorAvatarColorVarNames
|
|
584
583
|
bg: VarName
|
|
585
584
|
border: VarName
|
|
@@ -602,14 +601,30 @@ export interface FontSizeVarNames {
|
|
|
602
601
|
iconSize: VarName
|
|
603
602
|
}
|
|
604
603
|
|
|
604
|
+
/** @public */
|
|
605
605
|
export interface FontVarNames<Size extends number> {
|
|
606
606
|
family: VarName
|
|
607
|
+
featureSettings: VarName
|
|
607
608
|
sizes: Record<Size, FontSizeVarNames>
|
|
608
|
-
|
|
609
|
+
weights: Record<FontWeight, VarName>
|
|
609
610
|
}
|
|
610
611
|
|
|
611
612
|
/** @public */
|
|
612
613
|
export interface VarNames {
|
|
614
|
+
button: {
|
|
615
|
+
border: {
|
|
616
|
+
width: VarName
|
|
617
|
+
}
|
|
618
|
+
focusRing: {
|
|
619
|
+
offset: VarName
|
|
620
|
+
width: VarName
|
|
621
|
+
}
|
|
622
|
+
}
|
|
623
|
+
card: {
|
|
624
|
+
shadow: {
|
|
625
|
+
outline: VarName
|
|
626
|
+
}
|
|
627
|
+
}
|
|
613
628
|
color: Record<Scheme, ColorSchemeVarNames> &
|
|
614
629
|
ScopedColorVarNames &
|
|
615
630
|
Record<CardTone, ColorCardVarNames>
|
|
@@ -630,17 +645,85 @@ export interface VarNames {
|
|
|
630
645
|
text: FontVarNames<FontTextSize>
|
|
631
646
|
}
|
|
632
647
|
input: {
|
|
648
|
+
border: {
|
|
649
|
+
width: VarName
|
|
650
|
+
}
|
|
651
|
+
|
|
652
|
+
checkbox: {
|
|
653
|
+
focusRing: {
|
|
654
|
+
offset: VarName
|
|
655
|
+
width: VarName
|
|
656
|
+
}
|
|
657
|
+
size: VarName
|
|
658
|
+
}
|
|
659
|
+
|
|
660
|
+
radio: {
|
|
661
|
+
focusRing: {
|
|
662
|
+
offset: VarName
|
|
663
|
+
width: VarName
|
|
664
|
+
}
|
|
665
|
+
markSize: VarName
|
|
666
|
+
size: VarName
|
|
667
|
+
}
|
|
668
|
+
|
|
669
|
+
select: {
|
|
670
|
+
focusRing: {
|
|
671
|
+
offset: VarName
|
|
672
|
+
width: VarName
|
|
673
|
+
}
|
|
674
|
+
}
|
|
675
|
+
|
|
676
|
+
switch: {
|
|
677
|
+
focusRing: {
|
|
678
|
+
offset: VarName
|
|
679
|
+
width: VarName
|
|
680
|
+
}
|
|
681
|
+
height: VarName
|
|
682
|
+
padding: VarName
|
|
683
|
+
|
|
684
|
+
transitionDurationMs: VarName
|
|
685
|
+
transitionTimingFunction: VarName
|
|
686
|
+
width: VarName
|
|
687
|
+
}
|
|
688
|
+
|
|
689
|
+
text: {
|
|
690
|
+
focusRing: {
|
|
691
|
+
offset: VarName
|
|
692
|
+
width: VarName
|
|
693
|
+
}
|
|
694
|
+
}
|
|
695
|
+
|
|
633
696
|
fontSize: VarName
|
|
634
697
|
lineHeight: VarName
|
|
635
698
|
letterSpacing: VarName
|
|
636
699
|
ascenderHeight: VarName
|
|
637
700
|
descenderHeight: VarName
|
|
638
|
-
// capHeight: CSSVarName
|
|
639
701
|
gap: VarName
|
|
640
702
|
padding: VarName
|
|
641
703
|
}
|
|
642
704
|
radius: Record<Radius, VarName>
|
|
705
|
+
shadow: Record<
|
|
706
|
+
Shadow,
|
|
707
|
+
{
|
|
708
|
+
umbra: VarName
|
|
709
|
+
penumbra: VarName
|
|
710
|
+
ambient: VarName
|
|
711
|
+
}
|
|
712
|
+
>
|
|
643
713
|
space: Record<Space, VarName>
|
|
714
|
+
|
|
715
|
+
// color
|
|
716
|
+
black: VarName
|
|
717
|
+
white: VarName
|
|
718
|
+
gray: Record<ColorTintKey, VarName>
|
|
719
|
+
blue: Record<ColorTintKey, VarName>
|
|
720
|
+
purple: Record<ColorTintKey, VarName>
|
|
721
|
+
magenta: Record<ColorTintKey, VarName>
|
|
722
|
+
red: Record<ColorTintKey, VarName>
|
|
723
|
+
orange: Record<ColorTintKey, VarName>
|
|
724
|
+
yellow: Record<ColorTintKey, VarName>
|
|
725
|
+
green: Record<ColorTintKey, VarName>
|
|
726
|
+
cyan: Record<ColorTintKey, VarName>
|
|
644
727
|
}
|
|
645
728
|
|
|
646
729
|
/** @public */
|
|
@@ -684,9 +767,6 @@ export interface ColorVariantVars extends Record<ElementTone, ColorElementVars>,
|
|
|
684
767
|
|
|
685
768
|
/** @public */
|
|
686
769
|
export interface ColorCardVars {
|
|
687
|
-
accent: {
|
|
688
|
-
fg: CSSVar
|
|
689
|
-
}
|
|
690
770
|
avatar: ColorAvatarVars
|
|
691
771
|
backdrop: CSSVar
|
|
692
772
|
code: {
|
|
@@ -779,6 +859,7 @@ export interface ColorAvatarColorVars {
|
|
|
779
859
|
// eslint-disable-next-line @typescript-eslint/no-empty-object-type
|
|
780
860
|
export interface ColorSchemeVars extends Record<CardTone, ColorCardVars> {}
|
|
781
861
|
|
|
862
|
+
/** @public */
|
|
782
863
|
export interface ScopedColorVars extends Omit<ColorCardVars, 'avatar'> {
|
|
783
864
|
avatar: ColorAvatarVars & ColorAvatarColorVars
|
|
784
865
|
bg: CSSVar
|
|
@@ -817,6 +898,11 @@ export interface Vars {
|
|
|
817
898
|
size: CSSVar
|
|
818
899
|
sizes: Record<AvatarSize, {distance: CSSVar; size: CSSVar}>
|
|
819
900
|
}
|
|
901
|
+
card: {
|
|
902
|
+
shadow: {
|
|
903
|
+
outline: CSSVar
|
|
904
|
+
}
|
|
905
|
+
}
|
|
820
906
|
color: {
|
|
821
907
|
dark: ColorSchemeVars
|
|
822
908
|
light: ColorSchemeVars
|
|
@@ -848,5 +934,19 @@ export interface Vars {
|
|
|
848
934
|
}
|
|
849
935
|
}
|
|
850
936
|
radius: Record<Radius, CSSVar>
|
|
937
|
+
shadow: Record<Shadow, {umbra: CSSVar; penumbra: CSSVar; ambient: CSSVar}>
|
|
851
938
|
space: Record<Space, CSSVar>
|
|
939
|
+
|
|
940
|
+
// color
|
|
941
|
+
black: CSSVar
|
|
942
|
+
white: CSSVar
|
|
943
|
+
gray: Record<ColorTintKey, CSSVar>
|
|
944
|
+
blue: Record<ColorTintKey, CSSVar>
|
|
945
|
+
purple: Record<ColorTintKey, CSSVar>
|
|
946
|
+
magenta: Record<ColorTintKey, CSSVar>
|
|
947
|
+
red: Record<ColorTintKey, CSSVar>
|
|
948
|
+
orange: Record<ColorTintKey, CSSVar>
|
|
949
|
+
yellow: Record<ColorTintKey, CSSVar>
|
|
950
|
+
green: Record<ColorTintKey, CSSVar>
|
|
951
|
+
cyan: Record<ColorTintKey, CSSVar>
|
|
852
952
|
}
|
package/src/css/util.ts
CHANGED
|
@@ -1,25 +1,30 @@
|
|
|
1
1
|
import {type ThemeBoxShadow} from '@sanity/ui/theme'
|
|
2
2
|
|
|
3
|
+
/** @internal */
|
|
3
4
|
export function isRecord(value: unknown): value is Record<string, unknown> {
|
|
4
5
|
return value !== null && typeof value === 'object' && !Array.isArray(value)
|
|
5
6
|
}
|
|
6
7
|
|
|
8
|
+
/** @internal */
|
|
7
9
|
export function isArray(value: unknown): value is unknown[] {
|
|
8
10
|
return Array.isArray(value)
|
|
9
11
|
}
|
|
10
12
|
|
|
13
|
+
/** @internal */
|
|
11
14
|
export function rem(value: number): string {
|
|
12
15
|
if (value === 0) return '0'
|
|
13
16
|
|
|
14
17
|
return `${value / 16}rem`
|
|
15
18
|
}
|
|
16
19
|
|
|
20
|
+
/** @internal */
|
|
17
21
|
export function px(value: number): string {
|
|
18
22
|
if (value === 0) return '0'
|
|
19
23
|
|
|
20
24
|
return `${value}px`
|
|
21
25
|
}
|
|
22
26
|
|
|
27
|
+
/** @internal */
|
|
23
28
|
export function toBoxShadow(value: ThemeBoxShadow | undefined): string {
|
|
24
29
|
if (!value) return 'none'
|
|
25
30
|
|