@sanity/ui 1.8.3 → 2.0.0-alpha.10
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 +3 -0
- package/dist/index.d.ts +339 -415
- package/dist/index.esm.js +5374 -2489
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +5375 -2487
- package/dist/index.js.map +1 -1
- package/package.json +21 -3
- package/src/components/autocomplete/autocomplete.tsx +2 -1
- package/src/components/dialog/constants.ts +4 -0
- package/src/components/dialog/dialog.tsx +89 -27
- package/src/components/dialog/styles.ts +3 -4
- package/src/components/hotkeys/hotkeys.tsx +2 -1
- package/src/components/menu/__workshop__/closableMenuButton.tsx +2 -2
- package/src/components/menu/menuButton.tsx +2 -2
- package/src/components/menu/menuDivider.ts +2 -1
- package/src/components/menu/menuGroup.tsx +24 -25
- package/src/components/menu/menuItem.tsx +31 -37
- package/src/components/skeleton/styles.ts +8 -7
- package/src/components/tab/tab.tsx +2 -1
- package/src/components/tree/style.ts +19 -20
- package/src/primitives/_selectable/style.ts +25 -23
- package/src/primitives/avatar/avatar.tsx +8 -3
- package/src/primitives/avatar/avatarCounter.tsx +5 -4
- package/src/primitives/avatar/spotColors.ts +53 -0
- package/src/primitives/avatar/styles.ts +6 -8
- package/src/primitives/avatar/types.ts +14 -0
- package/src/primitives/badge/badge.tsx +5 -3
- package/src/primitives/badge/styles.ts +7 -8
- package/src/primitives/box/__workshop__/responsive.tsx +2 -2
- package/src/primitives/button/__workshop__/sanityUploadButton.tsx +1 -2
- package/src/primitives/button/button.tsx +8 -9
- package/src/primitives/button/styles.ts +100 -17
- package/src/primitives/card/__workshop__/selected.tsx +8 -9
- package/src/primitives/card/card.tsx +43 -7
- package/src/primitives/card/styles.ts +31 -24
- package/src/primitives/card/types.ts +3 -1
- package/src/primitives/checkbox/checkbox.tsx +1 -0
- package/src/primitives/checkbox/styles.ts +53 -23
- package/src/primitives/code/code.tsx +15 -3
- package/src/primitives/code/styles.ts +51 -42
- package/src/primitives/heading/styles.ts +6 -5
- package/src/primitives/kbd/kbd.tsx +7 -6
- package/src/primitives/label/styles.ts +3 -2
- package/src/primitives/popover/popoverArrow.tsx +3 -2
- package/src/primitives/popover/popoverCard.tsx +8 -4
- package/src/primitives/radio/radio.tsx +1 -0
- package/src/primitives/radio/styles.ts +26 -13
- package/src/primitives/select/select.tsx +3 -2
- package/src/primitives/select/styles.ts +22 -24
- package/src/primitives/switch/__workshop__/props.tsx +4 -4
- package/src/primitives/switch/styles.ts +19 -12
- package/src/primitives/text/__workshop__/colored.tsx +10 -11
- package/src/primitives/text/styles.ts +10 -8
- package/src/primitives/textArea/textArea.tsx +8 -12
- package/src/primitives/textInput/textInput.tsx +15 -14
- package/src/primitives/tooltip/__workshop__/props.tsx +20 -3
- package/src/primitives/tooltip/tooltip.tsx +2 -2
- package/src/primitives/tooltip/tooltipArrow.tsx +3 -2
- package/src/primitives/types.ts +3 -2
- package/src/styles/border/borderStyle.ts +2 -1
- package/src/styles/colorVars/colorVarsStyle.ts +73 -30
- package/src/styles/focusRing/index.ts +8 -4
- package/src/styles/input/textInputStyle.ts +78 -94
- package/src/styles/margin/marginsStyle.test.ts +1 -2
- package/src/styles/padding/paddingStyle.test.ts +1 -2
- package/src/styles/radius/radiusStyle.ts +14 -4
- package/src/styles/radius/types.ts +3 -1
- package/src/styles/shadow/shadowStyle.ts +5 -5
- package/src/theme/__workshop__/color.tsx +2 -2
- package/src/theme/__workshop__/index.ts +0 -5
- package/src/theme/lib/color-fns/blend/multiply.ts +2 -2
- package/src/theme/lib/color-fns/blend/screen.ts +2 -2
- package/src/theme/lib/color-fns/convert.ts +15 -1
- package/src/theme/lib/color-fns/parse.ts +7 -3
- package/src/theme/lib/color-fns/types.ts +11 -0
- package/src/theme/lib/theme/avatar.ts +3 -0
- package/src/theme/lib/theme/color/_legacy/createColorTheme.ts +7 -0
- package/src/theme/lib/theme/color/_legacy/index.ts +1 -0
- package/src/theme/lib/theme/color/_legacy/legacyColor.ts +3997 -0
- package/src/theme/lib/theme/color/cssVariables/cardVariables.ts +88 -0
- package/src/theme/lib/theme/color/cssVariables/createCssVars.ts +31 -0
- package/src/theme/lib/theme/color/cssVariables/cssVars.test.ts +262 -0
- package/src/theme/lib/theme/color/cssVariables/index.ts +1 -0
- package/src/theme/lib/theme/color/cssVariables/tints.ts +312 -0
- package/src/theme/lib/theme/color/cssVariables/tones.ts +67 -0
- package/src/theme/lib/theme/color/cssVariables/utils.test.ts +15 -0
- package/src/theme/lib/theme/color/cssVariables/utils.ts +9 -0
- package/src/theme/lib/theme/color/index.ts +3 -12
- package/src/theme/lib/theme/color/types.ts +6 -37
- package/src/theme/lib/theme/input.ts +11 -0
- package/src/theme/lib/theme/theme.ts +7 -1
- package/src/theme/studioTheme/color.ts +6 -633
- package/src/theme/studioTheme/fonts.ts +3 -3
- package/src/theme/studioTheme/helpers.ts +15 -1
- package/src/theme/studioTheme/theme.ts +26 -6
- package/src/theme/themeColorProvider.tsx +2 -0
- package/src/theme/themeProvider.tsx +28 -8
- package/src/theme/toneContext/toneContext.ts +12 -0
- package/src/theme/toneContext/toneProvider.tsx +31 -0
- package/src/theme/toneContext/types.ts +10 -0
- package/src/theme/toneContext/useToneContext.tsx +26 -0
- package/src/theme/types.ts +10 -4
- package/src/types/index.ts +1 -0
- package/src/types/radius.ts +4 -0
- package/src/utils/elementQuery/__workshop__/customMedia.tsx +4 -3
- package/src/theme/__workshop__/canvas.tsx +0 -395
- package/src/theme/lib/theme/color/_generic/index.ts +0 -1
- package/src/theme/lib/theme/color/_generic/types.ts +0 -29
- package/src/theme/lib/theme/color/base/index.ts +0 -1
- package/src/theme/lib/theme/color/base/types.ts +0 -19
- package/src/theme/lib/theme/color/button/createButtonModes.ts +0 -20
- package/src/theme/lib/theme/color/button/createButtonTones.ts +0 -52
- package/src/theme/lib/theme/color/button/index.ts +0 -1
- package/src/theme/lib/theme/color/button/types.ts +0 -44
- package/src/theme/lib/theme/color/card/createCardStates.ts +0 -58
- package/src/theme/lib/theme/color/card/index.ts +0 -1
- package/src/theme/lib/theme/color/card/types.ts +0 -18
- package/src/theme/lib/theme/color/color.test.ts +0 -62
- package/src/theme/lib/theme/color/defaults.ts +0 -382
- package/src/theme/lib/theme/color/factory.ts +0 -138
- package/src/theme/lib/theme/color/input/createInputModes.ts +0 -84
- package/src/theme/lib/theme/color/input/index.ts +0 -1
- package/src/theme/lib/theme/color/input/types.ts +0 -27
- package/src/theme/lib/theme/color/muted/createMuted.ts +0 -56
- package/src/theme/lib/theme/color/muted/index.ts +0 -1
- package/src/theme/lib/theme/color/muted/types.ts +0 -24
- package/src/theme/lib/theme/color/selectable/createSelectableTones.ts +0 -73
- package/src/theme/lib/theme/color/selectable/index.ts +0 -1
- package/src/theme/lib/theme/color/selectable/types.ts +0 -29
- package/src/theme/lib/theme/color/solid/createSolidTones.ts +0 -56
- package/src/theme/lib/theme/color/solid/index.ts +0 -1
- package/src/theme/lib/theme/color/solid/types.ts +0 -24
- package/src/theme/lib/theme/color/spot/createSpot.ts +0 -21
- package/src/theme/lib/theme/color/spot/index.ts +0 -1
- package/src/theme/lib/theme/color/spot/types.ts +0 -28
- package/src/theme/lib/theme/color/syntax/index.ts +0 -1
- package/src/theme/lib/theme/color/syntax/types.ts +0 -41
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
import {css} from 'styled-components'
|
|
2
2
|
import {rem, ThemeProps} from '../../styles'
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
_colorVarStyleActive,
|
|
5
|
+
_colorVarStyleHover,
|
|
6
|
+
_colorVarStyleSelected,
|
|
7
|
+
} from '../../styles/colorVars'
|
|
8
|
+
import {cssVars} from '../../theme'
|
|
9
|
+
import {cardVariables} from '../../theme/lib/theme/color/cssVariables/cardVariables'
|
|
4
10
|
|
|
5
11
|
export function treeItemRootStyle(): ReturnType<typeof css> {
|
|
6
12
|
return css`
|
|
@@ -29,34 +35,28 @@ export function treeItemRootStyle(): ReturnType<typeof css> {
|
|
|
29
35
|
`
|
|
30
36
|
}
|
|
31
37
|
|
|
32
|
-
export function treeItemRootColorStyle(
|
|
33
|
-
const {theme} = props
|
|
34
|
-
const $tone = 'default'
|
|
35
|
-
const {base, muted, selectable} = theme.sanity.color
|
|
36
|
-
// @todo: remove use of `muted` here
|
|
37
|
-
const tone = selectable ? selectable[$tone] || selectable.default : muted[$tone] || muted.default
|
|
38
|
-
|
|
38
|
+
export function treeItemRootColorStyle(): ReturnType<typeof css> {
|
|
39
39
|
return css`
|
|
40
40
|
/* <div role="none"><a data-ui="TreeItem__box" role="treeitem" tabIndex="0"></div> */
|
|
41
41
|
&[role='none'] {
|
|
42
42
|
& > [role='treeitem'] {
|
|
43
|
-
${
|
|
43
|
+
${cardVariables}
|
|
44
44
|
|
|
45
|
-
background-color
|
|
45
|
+
background-color:${cssVars.mutable['bg-color']};
|
|
46
46
|
color: var(--treeitem-fg-color);
|
|
47
47
|
}
|
|
48
48
|
|
|
49
49
|
&[data-selected] > [role='treeitem'] {
|
|
50
|
-
${
|
|
50
|
+
${_colorVarStyleActive()}
|
|
51
51
|
}
|
|
52
52
|
|
|
53
53
|
@media (hover: hover) {
|
|
54
54
|
&:not([data-selected]) > [role='treeitem']:not(:focus):hover {
|
|
55
|
-
${
|
|
55
|
+
${_colorVarStyleHover()}
|
|
56
56
|
}
|
|
57
57
|
|
|
58
58
|
& > [role='treeitem']:focus {
|
|
59
|
-
${
|
|
59
|
+
${_colorVarStyleSelected()}
|
|
60
60
|
}
|
|
61
61
|
}
|
|
62
62
|
}
|
|
@@ -64,23 +64,22 @@ export function treeItemRootColorStyle(props: ThemeProps): ReturnType<typeof css
|
|
|
64
64
|
/* <div role="treeitem" tabIndex="0"><div data-ui="TreeItem__box"></div> */
|
|
65
65
|
&[role='treeitem'] {
|
|
66
66
|
& > [data-ui='TreeItem__box'] {
|
|
67
|
-
${
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
color: var(--card-fg-color);
|
|
67
|
+
${cardVariables}
|
|
68
|
+
background-color: ${cssVars.mutable['bg-color']};
|
|
69
|
+
color: ${cssVars.mutable['fg-color']};
|
|
71
70
|
}
|
|
72
71
|
|
|
73
72
|
&[data-selected] > [data-ui='TreeItem__box'] {
|
|
74
|
-
${
|
|
73
|
+
${_colorVarStyleActive()}
|
|
75
74
|
}
|
|
76
75
|
|
|
77
76
|
@media (hover: hover) {
|
|
78
77
|
&:not([data-selected]):not(:focus) > [data-ui='TreeItem__box']:hover {
|
|
79
|
-
${
|
|
78
|
+
${_colorVarStyleHover()}
|
|
80
79
|
}
|
|
81
80
|
|
|
82
81
|
&:focus > [data-ui='TreeItem__box'] {
|
|
83
|
-
${
|
|
82
|
+
${_colorVarStyleSelected()}
|
|
84
83
|
}
|
|
85
84
|
}
|
|
86
85
|
}
|
|
@@ -1,13 +1,19 @@
|
|
|
1
1
|
import {css} from 'styled-components'
|
|
2
2
|
import {ThemeProps} from '../../styles'
|
|
3
|
-
import {
|
|
4
|
-
|
|
3
|
+
import {
|
|
4
|
+
_colorVarStyleHover,
|
|
5
|
+
_selectableVarStyle,
|
|
6
|
+
_selectableVarStyleDisabled,
|
|
7
|
+
} from '../../styles/colorVars'
|
|
8
|
+
|
|
9
|
+
import {ThemeColorSchemeKey, ThemeColorToneKey, createCssVars, cssVars} from '../../theme'
|
|
5
10
|
|
|
6
11
|
/**
|
|
7
12
|
* @internal
|
|
8
13
|
*/
|
|
9
14
|
export interface SelectableStyleProps {
|
|
10
|
-
$tone:
|
|
15
|
+
$tone: ThemeColorToneKey
|
|
16
|
+
$scheme: ThemeColorSchemeKey
|
|
11
17
|
}
|
|
12
18
|
|
|
13
19
|
export function selectableBaseStyle(): ReturnType<typeof css> {
|
|
@@ -22,7 +28,6 @@ export function selectableBaseStyle(): ReturnType<typeof css> {
|
|
|
22
28
|
font: inherit;
|
|
23
29
|
text-align: inherit;
|
|
24
30
|
border: 0;
|
|
25
|
-
width: -webkit-fill-available;
|
|
26
31
|
width: stretch;
|
|
27
32
|
}
|
|
28
33
|
|
|
@@ -36,43 +41,41 @@ export function selectableBaseStyle(): ReturnType<typeof css> {
|
|
|
36
41
|
export function selectableColorStyle(
|
|
37
42
|
props: SelectableStyleProps & ThemeProps,
|
|
38
43
|
): ReturnType<typeof css> {
|
|
39
|
-
const {$tone,
|
|
40
|
-
const {base, muted, selectable} = theme.sanity.color
|
|
41
|
-
// @todo: remove use of `muted` here
|
|
42
|
-
const tone = selectable ? selectable[$tone] || selectable.default : muted[$tone] || muted.default
|
|
44
|
+
const {theme, $tone, $scheme} = props
|
|
43
45
|
|
|
44
46
|
return css`
|
|
45
|
-
${
|
|
47
|
+
${$tone !== 'default' && createCssVars($scheme, theme.sanity.color.tones, $tone)}
|
|
48
|
+
${_selectableVarStyle($tone)}
|
|
46
49
|
|
|
47
|
-
background-color:
|
|
48
|
-
color:
|
|
50
|
+
background-color: ${cssVars.mutable['bg-color']};
|
|
51
|
+
color: ${cssVars[$tone]['text-secondary']};
|
|
49
52
|
outline: none;
|
|
50
53
|
|
|
51
|
-
/* &:is(button) */
|
|
54
|
+
/* &:is(button) - Looks like a button in default mode */
|
|
52
55
|
&[data-as='button'] {
|
|
53
56
|
&:disabled {
|
|
54
|
-
${
|
|
57
|
+
${_selectableVarStyleDisabled()}
|
|
55
58
|
}
|
|
56
59
|
|
|
57
60
|
&:not(:disabled) {
|
|
58
61
|
&[aria-pressed='true'] {
|
|
59
|
-
${
|
|
62
|
+
${_colorVarStyleHover()}
|
|
60
63
|
}
|
|
61
64
|
|
|
62
65
|
&[data-selected],
|
|
63
66
|
&[aria-selected='true'] > & {
|
|
64
|
-
${
|
|
67
|
+
${_colorVarStyleHover()}
|
|
65
68
|
}
|
|
66
69
|
|
|
67
70
|
@media (hover: hover) {
|
|
68
71
|
&:not([data-selected]) {
|
|
69
72
|
&[data-hovered],
|
|
70
73
|
&:hover {
|
|
71
|
-
${
|
|
74
|
+
${_colorVarStyleHover()}
|
|
72
75
|
}
|
|
73
76
|
|
|
74
77
|
&:active {
|
|
75
|
-
${
|
|
78
|
+
${_colorVarStyleHover()}
|
|
76
79
|
}
|
|
77
80
|
}
|
|
78
81
|
}
|
|
@@ -82,27 +85,26 @@ export function selectableColorStyle(
|
|
|
82
85
|
/* &:is(a) */
|
|
83
86
|
&[data-as='a'] {
|
|
84
87
|
&[data-disabled] {
|
|
85
|
-
${
|
|
88
|
+
${_selectableVarStyleDisabled()}
|
|
86
89
|
}
|
|
87
90
|
|
|
88
91
|
&:not([data-disabled]) {
|
|
89
92
|
&[data-pressed] {
|
|
90
|
-
${
|
|
93
|
+
${_colorVarStyleHover()}
|
|
91
94
|
}
|
|
92
95
|
|
|
93
96
|
&[data-selected] {
|
|
94
|
-
${
|
|
97
|
+
${_colorVarStyleHover()}
|
|
95
98
|
}
|
|
96
99
|
|
|
97
100
|
@media (hover: hover) {
|
|
98
101
|
&:not([data-selected]) {
|
|
99
102
|
&[data-hovered],
|
|
100
103
|
&:hover {
|
|
101
|
-
${
|
|
104
|
+
${_colorVarStyleHover()}
|
|
102
105
|
}
|
|
103
|
-
|
|
104
106
|
&:active {
|
|
105
|
-
${
|
|
107
|
+
${_colorVarStyleHover()}
|
|
106
108
|
}
|
|
107
109
|
}
|
|
108
110
|
}
|
|
@@ -2,10 +2,14 @@ import {forwardRef, useCallback, useEffect, useId, useMemo, useState} from 'reac
|
|
|
2
2
|
import ReactIs from 'react-is'
|
|
3
3
|
import styled from 'styled-components'
|
|
4
4
|
import {useArrayProp} from '../../hooks'
|
|
5
|
-
import {
|
|
5
|
+
import {useTheme} from '../../theme'
|
|
6
|
+
|
|
7
|
+
import {useToneContext} from '../../theme/toneContext/useToneContext'
|
|
6
8
|
import {AvatarPosition, AvatarSize, AvatarStatus} from '../../types'
|
|
7
9
|
import {Text} from '../text'
|
|
10
|
+
import {spotColor} from './spotColors'
|
|
8
11
|
import {avatarStyle, responsiveAvatarSizeStyle} from './styles'
|
|
12
|
+
import {ThemeColorSpotKey} from './types'
|
|
9
13
|
|
|
10
14
|
/**
|
|
11
15
|
* @public
|
|
@@ -63,9 +67,10 @@ export const Avatar = forwardRef(function Avatar(
|
|
|
63
67
|
const as = ReactIs.isValidElementType(asProp) ? asProp : 'div'
|
|
64
68
|
const size = useArrayProp(sizeProp)
|
|
65
69
|
const theme = useTheme()
|
|
66
|
-
const
|
|
70
|
+
const {scheme} = useToneContext()
|
|
71
|
+
|
|
72
|
+
const color = spotColor[colorKey][scheme].hex
|
|
67
73
|
|
|
68
|
-
// @todo: remove this
|
|
69
74
|
const avatarSize = theme.sanity.avatar.sizes[size[0]] || theme.sanity.avatar.sizes[0]
|
|
70
75
|
const _sizeRem = avatarSize.size
|
|
71
76
|
const _radius = _sizeRem / 2
|
|
@@ -3,6 +3,7 @@ import styled, {css} from 'styled-components'
|
|
|
3
3
|
import {EMPTY_RECORD} from '../../constants'
|
|
4
4
|
import {useArrayProp} from '../../hooks'
|
|
5
5
|
import {rem, _responsive, ThemeProps} from '../../styles'
|
|
6
|
+
import {cssVars} from '../../theme'
|
|
6
7
|
import {AvatarSize} from '../../types'
|
|
7
8
|
import {Text} from '../text'
|
|
8
9
|
|
|
@@ -32,11 +33,11 @@ function _avatarCounterBaseStyle(props: ThemeProps) {
|
|
|
32
33
|
box-sizing: border-box;
|
|
33
34
|
user-select: none;
|
|
34
35
|
color: inherit;
|
|
35
|
-
color:
|
|
36
|
-
background:
|
|
36
|
+
color: ${cssVars.mutable['fg-color']};
|
|
37
|
+
background: ${cssVars.mutable['bg-color']};
|
|
37
38
|
box-shadow:
|
|
38
|
-
0 0 0 1px
|
|
39
|
-
inset 0 0 0 1.5px
|
|
39
|
+
0 0 0 1px ${cssVars.mutable['bg-color']},
|
|
40
|
+
inset 0 0 0 1.5px ${cssVars.default['border-base']});
|
|
40
41
|
padding: 0 ${rem(theme.sanity.space[2])};
|
|
41
42
|
|
|
42
43
|
&:not([hidden]) {
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import {
|
|
2
|
+
gray,
|
|
3
|
+
blue,
|
|
4
|
+
purple,
|
|
5
|
+
magenta,
|
|
6
|
+
red,
|
|
7
|
+
orange,
|
|
8
|
+
yellow,
|
|
9
|
+
green,
|
|
10
|
+
cyan,
|
|
11
|
+
ColorTint,
|
|
12
|
+
} from '@sanity/color'
|
|
13
|
+
import {ThemeColorSchemeKey} from '../../theme'
|
|
14
|
+
import {ThemeColorSpotKey} from './types'
|
|
15
|
+
|
|
16
|
+
export const spotColor: Record<ThemeColorSpotKey, Record<ThemeColorSchemeKey, ColorTint>> = {
|
|
17
|
+
gray: {
|
|
18
|
+
dark: gray['400'],
|
|
19
|
+
light: gray['500'],
|
|
20
|
+
},
|
|
21
|
+
blue: {
|
|
22
|
+
dark: blue['400'],
|
|
23
|
+
light: blue['500'],
|
|
24
|
+
},
|
|
25
|
+
purple: {
|
|
26
|
+
dark: purple['400'],
|
|
27
|
+
light: purple['500'],
|
|
28
|
+
},
|
|
29
|
+
magenta: {
|
|
30
|
+
dark: magenta['400'],
|
|
31
|
+
light: magenta['500'],
|
|
32
|
+
},
|
|
33
|
+
red: {
|
|
34
|
+
dark: red['400'],
|
|
35
|
+
light: red['500'],
|
|
36
|
+
},
|
|
37
|
+
orange: {
|
|
38
|
+
dark: orange['400'],
|
|
39
|
+
light: orange['500'],
|
|
40
|
+
},
|
|
41
|
+
yellow: {
|
|
42
|
+
dark: yellow['400'],
|
|
43
|
+
light: yellow['500'],
|
|
44
|
+
},
|
|
45
|
+
green: {
|
|
46
|
+
dark: green['400'],
|
|
47
|
+
light: green['500'],
|
|
48
|
+
},
|
|
49
|
+
cyan: {
|
|
50
|
+
dark: cyan['400'],
|
|
51
|
+
light: cyan['500'],
|
|
52
|
+
},
|
|
53
|
+
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import {rem, _responsive, ThemeProps} from '../../styles'
|
|
2
2
|
import {focusRingStyle} from '../../styles/internal'
|
|
3
|
+
import {cssVars} from '../../theme/lib/theme/color/cssVariables/createCssVars'
|
|
3
4
|
import {CSSObject} from '../../types/styled'
|
|
4
5
|
import {AvatarRootStyleProps, ResponsiveAvatarSizeStyleProps} from './types'
|
|
5
6
|
|
|
@@ -57,14 +58,14 @@ function avatarArrowStyle(): CSSObject {
|
|
|
57
58
|
|
|
58
59
|
export function avatarRootStyle(props: AvatarRootStyleProps & ThemeProps): CSSObject {
|
|
59
60
|
const {$color, theme} = props
|
|
60
|
-
const {focusRing} = theme.sanity
|
|
61
|
+
const {focusRing} = theme.sanity.avatar
|
|
61
62
|
|
|
62
63
|
return {
|
|
63
64
|
backgroundColor: $color,
|
|
64
65
|
position: 'relative',
|
|
65
66
|
boxSizing: 'border-box',
|
|
66
67
|
userSelect: 'none',
|
|
67
|
-
boxShadow:
|
|
68
|
+
boxShadow: `0 0 0 1px ${cssVars.mutable['bg-color']}`,
|
|
68
69
|
|
|
69
70
|
'&[data-status="inactive"]': {
|
|
70
71
|
opacity: 0.5,
|
|
@@ -123,14 +124,11 @@ export function responsiveAvatarSizeStyle(
|
|
|
123
124
|
})
|
|
124
125
|
}
|
|
125
126
|
|
|
126
|
-
export function avatarInitialsStyle(
|
|
127
|
-
const {theme} = props
|
|
128
|
-
const {base} = theme.sanity.color
|
|
129
|
-
|
|
127
|
+
export function avatarInitialsStyle(): CSSObject {
|
|
130
128
|
return {
|
|
131
129
|
width: '100%',
|
|
132
130
|
height: '100%',
|
|
133
|
-
color:
|
|
131
|
+
color: cssVars.default['text-primary'],
|
|
134
132
|
alignItems: 'center',
|
|
135
133
|
justifyContent: 'center',
|
|
136
134
|
textTransform: 'uppercase',
|
|
@@ -146,7 +144,7 @@ export function avatarInitialsStyle(props: ThemeProps): CSSObject {
|
|
|
146
144
|
function avatarBgStrokeStyle(): CSSObject {
|
|
147
145
|
return {
|
|
148
146
|
strokeWidth: '4px',
|
|
149
|
-
stroke: '
|
|
147
|
+
stroke: cssVars.mutable['bg-color'],
|
|
150
148
|
}
|
|
151
149
|
}
|
|
152
150
|
|
|
@@ -13,3 +13,17 @@ export interface AvatarRootStyleProps {
|
|
|
13
13
|
export interface ResponsiveAvatarSizeStyleProps {
|
|
14
14
|
$size: AvatarSize[]
|
|
15
15
|
}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* @public
|
|
19
|
+
*/
|
|
20
|
+
export type ThemeColorSpotKey =
|
|
21
|
+
| 'gray'
|
|
22
|
+
| 'blue'
|
|
23
|
+
| 'purple'
|
|
24
|
+
| 'magenta'
|
|
25
|
+
| 'red'
|
|
26
|
+
| 'orange'
|
|
27
|
+
| 'yellow'
|
|
28
|
+
| 'green'
|
|
29
|
+
| 'cyan'
|
|
@@ -4,7 +4,7 @@ import {useArrayProp} from '../../hooks'
|
|
|
4
4
|
import {responsiveRadiusStyle, ResponsiveRadiusStyleProps} from '../../styles/internal'
|
|
5
5
|
import {BadgeMode, BadgeTone} from '../../types'
|
|
6
6
|
import {Box, BoxProps} from '../box'
|
|
7
|
-
import {
|
|
7
|
+
import {Text} from '../text'
|
|
8
8
|
import {ResponsiveRadiusProps} from '../types'
|
|
9
9
|
import {badgeStyle} from './styles'
|
|
10
10
|
import {BadgeStyleProps} from './types'
|
|
@@ -33,7 +33,7 @@ export const Badge = forwardRef(function Badge(
|
|
|
33
33
|
) {
|
|
34
34
|
const {
|
|
35
35
|
children,
|
|
36
|
-
fontSize,
|
|
36
|
+
fontSize = 1,
|
|
37
37
|
mode = 'default',
|
|
38
38
|
padding = 1,
|
|
39
39
|
radius = 2,
|
|
@@ -51,7 +51,9 @@ export const Badge = forwardRef(function Badge(
|
|
|
51
51
|
padding={useArrayProp(padding)}
|
|
52
52
|
ref={ref}
|
|
53
53
|
>
|
|
54
|
-
<
|
|
54
|
+
<Text size={fontSize} weight="medium">
|
|
55
|
+
{children}
|
|
56
|
+
</Text>
|
|
55
57
|
</Root>
|
|
56
58
|
)
|
|
57
59
|
})
|
|
@@ -1,16 +1,15 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {mutableCardVariables} from '../../theme/lib/theme/color/cssVariables/cardVariables'
|
|
2
|
+
import {cssVars} from '../../theme/lib/theme/color/cssVariables/createCssVars'
|
|
2
3
|
import {CSSObject} from '../../types/styled'
|
|
3
4
|
import {BadgeStyleProps} from './types'
|
|
4
5
|
|
|
5
|
-
export function badgeStyle(props: BadgeStyleProps
|
|
6
|
-
const {$mode, $tone
|
|
7
|
-
const palette = theme.sanity.color[$mode === 'outline' ? 'muted' : 'solid']
|
|
8
|
-
const color = palette[$tone] || palette.default
|
|
6
|
+
export function badgeStyle(props: BadgeStyleProps): CSSObject {
|
|
7
|
+
const {$mode, $tone} = props
|
|
9
8
|
|
|
10
9
|
return {
|
|
11
|
-
backgroundColor:
|
|
12
|
-
color:
|
|
13
|
-
boxShadow: `inset 0 0 0 1px ${
|
|
10
|
+
backgroundColor: $mode === 'outline' ? cssVars[$tone]['bg-base'] : cssVars[$tone]['bg-tint'],
|
|
11
|
+
[mutableCardVariables['fg-color']]: cssVars[$tone]['text-secondary'],
|
|
12
|
+
boxShadow: $mode === 'outline' ? `inset 0 0 0 1px ${cssVars[$tone]['border-base']}` : undefined,
|
|
14
13
|
cursor: 'default',
|
|
15
14
|
|
|
16
15
|
'&:not([hidden])': {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {Box, Text} from '@sanity/ui'
|
|
1
|
+
import {Box, Text, cssVars} from '@sanity/ui'
|
|
2
2
|
|
|
3
3
|
export default function ResponsiveStory() {
|
|
4
4
|
return (
|
|
@@ -9,7 +9,7 @@ export default function ResponsiveStory() {
|
|
|
9
9
|
flex={[1, 2, 3, 4, 5, 6, 7]}
|
|
10
10
|
padding={3}
|
|
11
11
|
sizing={['content', 'border', 'content', 'border', 'content', 'border', 'content']}
|
|
12
|
-
style={{outline:
|
|
12
|
+
style={{outline: `1px solid ${cssVars.default['border-base']}`}}
|
|
13
13
|
>
|
|
14
14
|
<Text align="center" muted>
|
|
15
15
|
This is a box with responsive props
|
|
@@ -4,7 +4,7 @@ import styled from 'styled-components'
|
|
|
4
4
|
|
|
5
5
|
const SanityUploadButton = styled(Button).attrs({forwardedAs: 'label'})`
|
|
6
6
|
& input {
|
|
7
|
-
appearance: none;
|
|
7
|
+
-webkit-appearance: none;
|
|
8
8
|
overflow: hidden;
|
|
9
9
|
overflow: clip;
|
|
10
10
|
top: 0;
|
|
@@ -14,7 +14,6 @@ const SanityUploadButton = styled(Button).attrs({forwardedAs: 'label'})`
|
|
|
14
14
|
opacity: 0;
|
|
15
15
|
position: absolute;
|
|
16
16
|
max-width: 0;
|
|
17
|
-
width: -webkit-fill-available;
|
|
18
17
|
width: stretch;
|
|
19
18
|
}
|
|
20
19
|
|
|
@@ -4,7 +4,7 @@ import styled from 'styled-components'
|
|
|
4
4
|
import {useArrayProp} from '../../hooks'
|
|
5
5
|
import {ThemeProps} from '../../styles'
|
|
6
6
|
import {responsiveRadiusStyle, ResponsiveRadiusStyleProps} from '../../styles/internal'
|
|
7
|
-
import {useTheme} from '../../theme'
|
|
7
|
+
import {cssVars, useTheme} from '../../theme'
|
|
8
8
|
import {ButtonMode, ButtonTextAlign, ButtonTone, FlexJustify} from '../../types'
|
|
9
9
|
import {Box} from '../box'
|
|
10
10
|
import {Flex} from '../flex'
|
|
@@ -30,6 +30,7 @@ export interface ButtonProps extends ResponsivePaddingProps, ResponsiveRadiusPro
|
|
|
30
30
|
selected?: boolean
|
|
31
31
|
space?: number | number[]
|
|
32
32
|
textAlign?: ButtonTextAlign
|
|
33
|
+
muted?: boolean
|
|
33
34
|
text?: React.ReactNode
|
|
34
35
|
tone?: ButtonTone
|
|
35
36
|
type?: 'button' | 'reset' | 'submit'
|
|
@@ -48,7 +49,7 @@ const LoadingBox = styled.div`
|
|
|
48
49
|
display: flex;
|
|
49
50
|
align-items: center;
|
|
50
51
|
justify-content: center;
|
|
51
|
-
background-color:
|
|
52
|
+
background-color: ${cssVars.mutable['bg-color']};
|
|
52
53
|
border-radius: inherit;
|
|
53
54
|
z-index: 1;
|
|
54
55
|
box-shadow: inherit;
|
|
@@ -64,7 +65,7 @@ export const Button = forwardRef(function Button(
|
|
|
64
65
|
const {
|
|
65
66
|
children,
|
|
66
67
|
disabled,
|
|
67
|
-
fontSize,
|
|
68
|
+
fontSize = 1,
|
|
68
69
|
icon,
|
|
69
70
|
iconRight,
|
|
70
71
|
justify: justifyProp = 'center',
|
|
@@ -84,6 +85,7 @@ export const Button = forwardRef(function Button(
|
|
|
84
85
|
textAlign,
|
|
85
86
|
tone = 'default',
|
|
86
87
|
type = 'button',
|
|
88
|
+
muted = false,
|
|
87
89
|
...restProps
|
|
88
90
|
} = props
|
|
89
91
|
|
|
@@ -135,7 +137,7 @@ export const Button = forwardRef(function Button(
|
|
|
135
137
|
|
|
136
138
|
{(icon || text || iconRight) && (
|
|
137
139
|
<Box as="span" {...boxProps}>
|
|
138
|
-
<Flex as="span" justify={justify}>
|
|
140
|
+
<Flex as="span" justify={justify} gap={space}>
|
|
139
141
|
{icon && (
|
|
140
142
|
<Text size={fontSize}>
|
|
141
143
|
{isValidElement(icon) && icon}
|
|
@@ -144,12 +146,9 @@ export const Button = forwardRef(function Button(
|
|
|
144
146
|
)}
|
|
145
147
|
|
|
146
148
|
{text && (
|
|
147
|
-
<Box
|
|
148
|
-
flex={iconRight ? 1 : undefined}
|
|
149
|
-
marginLeft={icon ? space : undefined}
|
|
150
|
-
marginRight={iconRight ? space : undefined}
|
|
151
|
-
>
|
|
149
|
+
<Box flex={iconRight ? 1 : undefined}>
|
|
152
150
|
<Text
|
|
151
|
+
muted={muted}
|
|
153
152
|
align={textAlign}
|
|
154
153
|
size={fontSize}
|
|
155
154
|
textOverflow="ellipsis"
|