@sanity/ui 2.0.0-alpha.10 → 2.0.0-alpha.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/index.cjs.mjs +0 -2
- package/dist/index.d.ts +404 -281
- package/dist/index.esm.js +2305 -5015
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +2332 -5044
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/components/dialog/dialog.tsx +3 -3
- package/src/components/dialog/styles.ts +4 -3
- package/src/components/menu/__workshop__/closableMenuButton.tsx +2 -2
- package/src/components/menu/menuDivider.ts +1 -2
- package/src/components/menu/menuGroup.tsx +2 -2
- package/src/components/menu/menuItem.tsx +4 -4
- package/src/components/skeleton/styles.ts +7 -8
- package/src/components/tree/style.ts +20 -19
- package/src/primitives/_selectable/style.ts +21 -25
- package/src/primitives/avatar/avatar.tsx +3 -8
- package/src/primitives/avatar/avatarCounter.tsx +4 -5
- package/src/primitives/avatar/styles.ts +7 -5
- package/src/primitives/avatar/types.ts +0 -14
- package/src/primitives/badge/styles.ts +8 -7
- package/src/primitives/box/__workshop__/responsive.tsx +2 -2
- package/src/primitives/button/button.tsx +2 -2
- package/src/primitives/button/styles.ts +16 -82
- package/src/primitives/card/__workshop__/selected.tsx +9 -8
- package/src/primitives/card/card.tsx +8 -43
- package/src/primitives/card/styles.ts +22 -30
- package/src/primitives/card/types.ts +1 -3
- package/src/primitives/checkbox/styles.ts +20 -20
- package/src/primitives/code/code.tsx +3 -15
- package/src/primitives/code/styles.ts +42 -51
- package/src/primitives/heading/styles.ts +5 -6
- package/src/primitives/kbd/kbd.tsx +1 -2
- package/src/primitives/label/styles.ts +2 -3
- package/src/primitives/popover/popoverArrow.tsx +2 -3
- package/src/primitives/popover/popoverCard.tsx +2 -6
- package/src/primitives/radio/styles.ts +15 -15
- package/src/primitives/select/styles.ts +22 -20
- package/src/primitives/switch/styles.ts +13 -13
- package/src/primitives/text/__workshop__/colored.tsx +11 -10
- package/src/primitives/text/styles.ts +9 -10
- package/src/primitives/textArea/textArea.tsx +11 -7
- package/src/primitives/textInput/textInput.tsx +12 -12
- package/src/primitives/tooltip/__workshop__/props.tsx +3 -20
- package/src/primitives/tooltip/tooltipArrow.tsx +2 -3
- package/src/styles/border/borderStyle.ts +1 -2
- package/src/styles/colorVars/colorVarsStyle.ts +32 -73
- package/src/styles/focusRing/index.ts +4 -6
- package/src/styles/input/textInputStyle.ts +93 -76
- package/src/styles/margin/marginsStyle.test.ts +2 -1
- package/src/styles/padding/paddingStyle.test.ts +2 -1
- package/src/styles/shadow/shadowStyle.ts +5 -5
- package/src/theme/__workshop__/canvas.tsx +395 -0
- package/src/theme/__workshop__/color.tsx +2 -2
- package/src/theme/__workshop__/index.ts +5 -0
- package/src/theme/lib/theme/color/_generic/index.ts +1 -0
- package/src/theme/lib/theme/color/_generic/types.ts +30 -0
- package/src/theme/lib/theme/color/base/index.ts +1 -0
- package/src/theme/lib/theme/color/base/types.ts +19 -0
- package/src/theme/lib/theme/color/button/createButtonModes.ts +20 -0
- package/src/theme/lib/theme/color/button/createButtonTones.ts +52 -0
- package/src/theme/lib/theme/color/button/index.ts +1 -0
- package/src/theme/lib/theme/color/button/types.ts +44 -0
- package/src/theme/lib/theme/color/card/createCardStates.ts +58 -0
- package/src/theme/lib/theme/color/card/index.ts +1 -0
- package/src/theme/lib/theme/color/card/types.ts +18 -0
- package/src/theme/lib/theme/color/color.test.ts +63 -0
- package/src/theme/lib/theme/color/defaults.ts +390 -0
- package/src/theme/lib/theme/color/factory.ts +138 -0
- package/src/theme/lib/theme/color/index.ts +12 -3
- package/src/theme/lib/theme/color/input/createInputModes.ts +84 -0
- package/src/theme/lib/theme/color/input/index.ts +1 -0
- package/src/theme/lib/theme/color/input/types.ts +28 -0
- package/src/theme/lib/theme/color/muted/createMuted.ts +56 -0
- package/src/theme/lib/theme/color/muted/index.ts +1 -0
- package/src/theme/lib/theme/color/muted/types.ts +24 -0
- package/src/theme/lib/theme/color/selectable/createSelectableTones.ts +73 -0
- package/src/theme/lib/theme/color/selectable/index.ts +1 -0
- package/src/theme/lib/theme/color/selectable/types.ts +29 -0
- package/src/theme/lib/theme/color/solid/createSolidTones.ts +56 -0
- package/src/theme/lib/theme/color/solid/index.ts +1 -0
- package/src/theme/lib/theme/color/solid/types.ts +24 -0
- package/src/theme/lib/theme/color/spot/createSpot.ts +21 -0
- package/src/theme/lib/theme/color/spot/index.ts +1 -0
- package/src/theme/lib/theme/color/spot/types.ts +28 -0
- package/src/theme/lib/theme/color/syntax/index.ts +1 -0
- package/src/theme/lib/theme/color/syntax/types.ts +41 -0
- package/src/theme/lib/theme/color/types.ts +37 -6
- package/src/theme/studioTheme/color.ts +661 -6
- package/src/theme/studioTheme/theme.ts +2 -8
- package/src/theme/{lib/theme/color/cssVariables → studioTheme}/tints.ts +2 -2
- package/src/theme/themeColorProvider.tsx +0 -2
- package/src/theme/themeProvider.tsx +8 -28
- package/src/theme/types.ts +4 -2
- package/src/utils/elementQuery/__workshop__/customMedia.tsx +3 -4
- package/src/primitives/avatar/spotColors.ts +0 -53
- package/src/theme/lib/theme/color/cssVariables/cardVariables.ts +0 -88
- package/src/theme/lib/theme/color/cssVariables/createCssVars.ts +0 -31
- package/src/theme/lib/theme/color/cssVariables/cssVars.test.ts +0 -262
- package/src/theme/lib/theme/color/cssVariables/index.ts +0 -1
- package/src/theme/lib/theme/color/cssVariables/tones.ts +0 -67
- package/src/theme/lib/theme/color/cssVariables/utils.test.ts +0 -15
- package/src/theme/lib/theme/color/cssVariables/utils.ts +0 -9
- package/src/theme/toneContext/toneContext.ts +0 -12
- package/src/theme/toneContext/toneProvider.tsx +0 -31
- package/src/theme/toneContext/types.ts +0 -10
- package/src/theme/toneContext/useToneContext.tsx +0 -26
package/package.json
CHANGED
|
@@ -11,7 +11,7 @@ import {useArrayProp, useClickOutside, useForwardedRef, useGlobalKeyDown} from '
|
|
|
11
11
|
import {Box, Button, Card, CardProps, Container, Flex, Text} from '../../primitives'
|
|
12
12
|
import {ResponsivePaddingProps, ResponsiveWidthProps} from '../../primitives/types'
|
|
13
13
|
import {responsivePaddingStyle, ResponsivePaddingStyleProps} from '../../styles/internal'
|
|
14
|
-
import {ThemeColorSchemeKey,
|
|
14
|
+
import {ThemeColorSchemeKey, useTheme} from '../../theme'
|
|
15
15
|
import {DialogPosition, Radius} from '../../types'
|
|
16
16
|
import {Layer, LayerProps, Portal, useBoundaryElement, useLayer, usePortal} from '../../utils'
|
|
17
17
|
import {BORDER_OFFSET_X} from './constants'
|
|
@@ -139,7 +139,7 @@ const DialogHeader = styled(Box)<DialogHeaderProps>`
|
|
|
139
139
|
left: ${BORDER_OFFSET_X}px;
|
|
140
140
|
right: ${BORDER_OFFSET_X}px;
|
|
141
141
|
bottom: -1px;
|
|
142
|
-
border-bottom: 1px solid
|
|
142
|
+
border-bottom: 1px solid var(--card-border-color);
|
|
143
143
|
width: auto;
|
|
144
144
|
opacity: ${(props) => (props.$isContentScrollable && props.$hasScrolledFromTop ? 1 : 0)};
|
|
145
145
|
transition: opacity 200ms ease-in;
|
|
@@ -164,7 +164,7 @@ const DialogFooter = styled(Box)<DialogFooterProps>`
|
|
|
164
164
|
left: ${BORDER_OFFSET_X}px;
|
|
165
165
|
right: ${BORDER_OFFSET_X}px;
|
|
166
166
|
top: -1px;
|
|
167
|
-
border-top: 1px solid
|
|
167
|
+
border-top: 1px solid var(--card-border-color);
|
|
168
168
|
width: auto;
|
|
169
169
|
opacity: ${(props) => (props.$isContentScrollable && !props.$hasScrolledToBottom ? 1 : 0)};
|
|
170
170
|
transition: opacity 200ms ease-in;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import {_responsive, ThemeProps} from '../../styles'
|
|
2
|
-
import {cssVars} from '../../theme'
|
|
3
2
|
import {DialogPosition} from '../../types'
|
|
4
3
|
import {CSSObject} from '../../types/styled'
|
|
5
4
|
|
|
@@ -10,7 +9,9 @@ export interface ResponsiveDialogPositionStyleProps {
|
|
|
10
9
|
$position: DialogPosition[]
|
|
11
10
|
}
|
|
12
11
|
|
|
13
|
-
export function dialogStyle(): CSSObject {
|
|
12
|
+
export function dialogStyle({theme}: ThemeProps): CSSObject {
|
|
13
|
+
const color = theme.sanity.color.base
|
|
14
|
+
|
|
14
15
|
return {
|
|
15
16
|
'&:not([hidden])': {
|
|
16
17
|
display: 'flex',
|
|
@@ -23,7 +24,7 @@ export function dialogStyle(): CSSObject {
|
|
|
23
24
|
alignItems: 'center',
|
|
24
25
|
justifyContent: 'center',
|
|
25
26
|
outline: 'none',
|
|
26
|
-
background:
|
|
27
|
+
background: color.shadow.umbra,
|
|
27
28
|
}
|
|
28
29
|
}
|
|
29
30
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import {AddIcon} from '@sanity/icons'
|
|
2
|
-
import {Box, Button, Menu, MenuButton, MenuButtonProps, MenuItem, Stack
|
|
2
|
+
import {Box, Button, Menu, MenuButton, MenuButtonProps, MenuItem, Stack} from '@sanity/ui'
|
|
3
3
|
import {useRef} from 'react'
|
|
4
4
|
|
|
5
5
|
const POPOVER_PROPS: MenuButtonProps['popover'] = {
|
|
@@ -23,7 +23,7 @@ export default function ClosableMenuButtonStory() {
|
|
|
23
23
|
<MenuItem text="Item 3" />
|
|
24
24
|
<MenuItem text="Item 4" />
|
|
25
25
|
</Stack>
|
|
26
|
-
<Stack padding={1} style={{borderTop:
|
|
26
|
+
<Stack padding={1} style={{borderTop: '1px solid var(--card-border-color)'}}>
|
|
27
27
|
<Button
|
|
28
28
|
icon={AddIcon}
|
|
29
29
|
onClick={() => {
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import styled from 'styled-components'
|
|
2
|
-
import {cssVars} from '../../theme'
|
|
3
2
|
|
|
4
3
|
/**
|
|
5
4
|
* @public
|
|
@@ -7,6 +6,6 @@ import {cssVars} from '../../theme'
|
|
|
7
6
|
export const MenuDivider = styled.hr`
|
|
8
7
|
height: 1px;
|
|
9
8
|
border: 0;
|
|
10
|
-
background:
|
|
9
|
+
background: var(--card-hairline-soft-color);
|
|
11
10
|
margin: 0;
|
|
12
11
|
`
|
|
@@ -4,7 +4,7 @@ import {isValidElementType} from 'react-is'
|
|
|
4
4
|
import {useArrayProp} from '../../hooks'
|
|
5
5
|
import {Box, Flex, Popover, PopoverProps, Text} from '../../primitives'
|
|
6
6
|
import {Selectable} from '../../primitives/_selectable'
|
|
7
|
-
import {
|
|
7
|
+
import {useRootTheme} from '../../theme'
|
|
8
8
|
import {Radius, SelectableTone} from '../../types'
|
|
9
9
|
import {Menu} from './menu'
|
|
10
10
|
import {useMenu} from './useMenu'
|
|
@@ -45,8 +45,8 @@ export function MenuGroup(
|
|
|
45
45
|
tone = 'default',
|
|
46
46
|
...restProps
|
|
47
47
|
} = props
|
|
48
|
-
const {scheme} = useToneContext()
|
|
49
48
|
const menu = useMenu()
|
|
49
|
+
const {scheme} = useRootTheme()
|
|
50
50
|
const {
|
|
51
51
|
activeElement,
|
|
52
52
|
mount,
|
|
@@ -12,8 +12,8 @@ import {useArrayProp, useForwardedRef} from '../../hooks'
|
|
|
12
12
|
import {Box, Flex, Text} from '../../primitives'
|
|
13
13
|
import {Selectable} from '../../primitives/_selectable'
|
|
14
14
|
import {ResponsivePaddingProps, ResponsiveRadiusProps} from '../../primitives/types'
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
15
|
+
import {useRootTheme} from '../../theme'
|
|
16
|
+
import {SelectableTone} from '../../types/selectable'
|
|
17
17
|
import {Hotkeys} from '../hotkeys'
|
|
18
18
|
import {useMenu} from './useMenu'
|
|
19
19
|
|
|
@@ -30,7 +30,7 @@ export interface MenuItemProps extends ResponsivePaddingProps, ResponsiveRadiusP
|
|
|
30
30
|
selected?: boolean
|
|
31
31
|
space?: number | number[]
|
|
32
32
|
text?: React.ReactNode
|
|
33
|
-
tone?:
|
|
33
|
+
tone?: SelectableTone
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
/**
|
|
@@ -65,7 +65,7 @@ export const MenuItem = forwardRef(function MenuItem(
|
|
|
65
65
|
tone = 'default',
|
|
66
66
|
...restProps
|
|
67
67
|
} = props
|
|
68
|
-
const {scheme} =
|
|
68
|
+
const {scheme} = useRootTheme()
|
|
69
69
|
const menu = useMenu()
|
|
70
70
|
const {
|
|
71
71
|
activeElement,
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import {css, keyframes} from 'styled-components'
|
|
2
|
-
import {cssVars} from '../../theme'
|
|
3
2
|
|
|
4
3
|
const keyframe = keyframes`
|
|
5
4
|
0% {
|
|
@@ -13,11 +12,11 @@ const keyframe = keyframes`
|
|
|
13
12
|
const animation = css`
|
|
14
13
|
background-image: linear-gradient(
|
|
15
14
|
to right,
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
15
|
+
var(--card-skeleton-color-from),
|
|
16
|
+
var(--card-skeleton-color-to),
|
|
17
|
+
var(--card-skeleton-color-from),
|
|
18
|
+
var(--card-skeleton-color-from),
|
|
19
|
+
var(--card-skeleton-color-from)
|
|
21
20
|
);
|
|
22
21
|
background-position: 100%;
|
|
23
22
|
background-size: 200% 100%;
|
|
@@ -41,11 +40,11 @@ export const skeletonStyle = css<{$animated: boolean; $visible: boolean}>`
|
|
|
41
40
|
$animated
|
|
42
41
|
? animation
|
|
43
42
|
: css`
|
|
44
|
-
background-color:
|
|
43
|
+
background-color: var(--card-skeleton-color-from);
|
|
45
44
|
`}
|
|
46
45
|
}
|
|
47
46
|
|
|
48
47
|
@media screen and (prefers-reduced-motion: reduce) {
|
|
49
|
-
background-color:
|
|
48
|
+
background-color: var(--card-skeleton-color-from);
|
|
50
49
|
}
|
|
51
50
|
`
|
|
@@ -1,12 +1,6 @@
|
|
|
1
1
|
import {css} from 'styled-components'
|
|
2
2
|
import {rem, ThemeProps} from '../../styles'
|
|
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'
|
|
3
|
+
import {_colorVarsStyle} from '../../styles/colorVars'
|
|
10
4
|
|
|
11
5
|
export function treeItemRootStyle(): ReturnType<typeof css> {
|
|
12
6
|
return css`
|
|
@@ -35,28 +29,34 @@ export function treeItemRootStyle(): ReturnType<typeof css> {
|
|
|
35
29
|
`
|
|
36
30
|
}
|
|
37
31
|
|
|
38
|
-
export function treeItemRootColorStyle(): ReturnType<typeof css> {
|
|
32
|
+
export function treeItemRootColorStyle(props: ThemeProps): ReturnType<typeof css> {
|
|
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
|
+
|
|
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
|
+
${_colorVarsStyle(base, tone.enabled)}
|
|
44
44
|
|
|
45
|
-
background-color
|
|
45
|
+
background-color: var(--card-bg-color);
|
|
46
46
|
color: var(--treeitem-fg-color);
|
|
47
47
|
}
|
|
48
48
|
|
|
49
49
|
&[data-selected] > [role='treeitem'] {
|
|
50
|
-
${
|
|
50
|
+
${_colorVarsStyle(base, tone.pressed)}
|
|
51
51
|
}
|
|
52
52
|
|
|
53
53
|
@media (hover: hover) {
|
|
54
54
|
&:not([data-selected]) > [role='treeitem']:not(:focus):hover {
|
|
55
|
-
${
|
|
55
|
+
${_colorVarsStyle(base, tone.hovered)}
|
|
56
56
|
}
|
|
57
57
|
|
|
58
58
|
& > [role='treeitem']:focus {
|
|
59
|
-
${
|
|
59
|
+
${_colorVarsStyle(base, tone.selected)}
|
|
60
60
|
}
|
|
61
61
|
}
|
|
62
62
|
}
|
|
@@ -64,22 +64,23 @@ export function treeItemRootColorStyle(): 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
|
-
color:
|
|
67
|
+
${_colorVarsStyle(base, tone.enabled)}
|
|
68
|
+
|
|
69
|
+
background-color: var(--card-bg-color);
|
|
70
|
+
color: var(--card-fg-color);
|
|
70
71
|
}
|
|
71
72
|
|
|
72
73
|
&[data-selected] > [data-ui='TreeItem__box'] {
|
|
73
|
-
${
|
|
74
|
+
${_colorVarsStyle(base, tone.pressed)}
|
|
74
75
|
}
|
|
75
76
|
|
|
76
77
|
@media (hover: hover) {
|
|
77
78
|
&:not([data-selected]):not(:focus) > [data-ui='TreeItem__box']:hover {
|
|
78
|
-
${
|
|
79
|
+
${_colorVarsStyle(base, tone.hovered)}
|
|
79
80
|
}
|
|
80
81
|
|
|
81
82
|
&:focus > [data-ui='TreeItem__box'] {
|
|
82
|
-
${
|
|
83
|
+
${_colorVarsStyle(base, tone.selected)}
|
|
83
84
|
}
|
|
84
85
|
}
|
|
85
86
|
}
|
|
@@ -1,19 +1,13 @@
|
|
|
1
1
|
import {css} from 'styled-components'
|
|
2
2
|
import {ThemeProps} from '../../styles'
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
_selectableVarStyle,
|
|
6
|
-
_selectableVarStyleDisabled,
|
|
7
|
-
} from '../../styles/colorVars'
|
|
8
|
-
|
|
9
|
-
import {ThemeColorSchemeKey, ThemeColorToneKey, createCssVars, cssVars} from '../../theme'
|
|
3
|
+
import {_colorVarsStyle} from '../../styles/colorVars'
|
|
4
|
+
import {SelectableTone} from '../../types/selectable'
|
|
10
5
|
|
|
11
6
|
/**
|
|
12
7
|
* @internal
|
|
13
8
|
*/
|
|
14
9
|
export interface SelectableStyleProps {
|
|
15
|
-
$tone:
|
|
16
|
-
$scheme: ThemeColorSchemeKey
|
|
10
|
+
$tone: SelectableTone
|
|
17
11
|
}
|
|
18
12
|
|
|
19
13
|
export function selectableBaseStyle(): ReturnType<typeof css> {
|
|
@@ -41,41 +35,43 @@ export function selectableBaseStyle(): ReturnType<typeof css> {
|
|
|
41
35
|
export function selectableColorStyle(
|
|
42
36
|
props: SelectableStyleProps & ThemeProps,
|
|
43
37
|
): ReturnType<typeof css> {
|
|
44
|
-
const {
|
|
38
|
+
const {$tone, theme} = props
|
|
39
|
+
const {base, muted, selectable} = theme.sanity.color
|
|
40
|
+
// @todo: remove use of `muted` here
|
|
41
|
+
const tone = selectable ? selectable[$tone] || selectable.default : muted[$tone] || muted.default
|
|
45
42
|
|
|
46
43
|
return css`
|
|
47
|
-
${
|
|
48
|
-
${_selectableVarStyle($tone)}
|
|
44
|
+
${_colorVarsStyle(base, tone.enabled)}
|
|
49
45
|
|
|
50
|
-
background-color:
|
|
51
|
-
color:
|
|
46
|
+
background-color: var(--card-bg-color);
|
|
47
|
+
color: var(--card-fg-color);
|
|
52
48
|
outline: none;
|
|
53
49
|
|
|
54
|
-
/* &:is(button)
|
|
50
|
+
/* &:is(button) */
|
|
55
51
|
&[data-as='button'] {
|
|
56
52
|
&:disabled {
|
|
57
|
-
${
|
|
53
|
+
${_colorVarsStyle(base, tone.disabled)}
|
|
58
54
|
}
|
|
59
55
|
|
|
60
56
|
&:not(:disabled) {
|
|
61
57
|
&[aria-pressed='true'] {
|
|
62
|
-
${
|
|
58
|
+
${_colorVarsStyle(base, tone.pressed)}
|
|
63
59
|
}
|
|
64
60
|
|
|
65
61
|
&[data-selected],
|
|
66
62
|
&[aria-selected='true'] > & {
|
|
67
|
-
${
|
|
63
|
+
${_colorVarsStyle(base, tone.selected)}
|
|
68
64
|
}
|
|
69
65
|
|
|
70
66
|
@media (hover: hover) {
|
|
71
67
|
&:not([data-selected]) {
|
|
72
68
|
&[data-hovered],
|
|
73
69
|
&:hover {
|
|
74
|
-
${
|
|
70
|
+
${_colorVarsStyle(base, tone.hovered)}
|
|
75
71
|
}
|
|
76
72
|
|
|
77
73
|
&:active {
|
|
78
|
-
${
|
|
74
|
+
${_colorVarsStyle(base, tone.pressed)}
|
|
79
75
|
}
|
|
80
76
|
}
|
|
81
77
|
}
|
|
@@ -85,26 +81,26 @@ export function selectableColorStyle(
|
|
|
85
81
|
/* &:is(a) */
|
|
86
82
|
&[data-as='a'] {
|
|
87
83
|
&[data-disabled] {
|
|
88
|
-
${
|
|
84
|
+
${_colorVarsStyle(base, tone.disabled)}
|
|
89
85
|
}
|
|
90
86
|
|
|
91
87
|
&:not([data-disabled]) {
|
|
92
88
|
&[data-pressed] {
|
|
93
|
-
${
|
|
89
|
+
${_colorVarsStyle(base, tone.pressed)}
|
|
94
90
|
}
|
|
95
91
|
|
|
96
92
|
&[data-selected] {
|
|
97
|
-
${
|
|
93
|
+
${_colorVarsStyle(base, tone.selected)}
|
|
98
94
|
}
|
|
99
95
|
|
|
100
96
|
@media (hover: hover) {
|
|
101
97
|
&:not([data-selected]) {
|
|
102
98
|
&[data-hovered],
|
|
103
99
|
&:hover {
|
|
104
|
-
${
|
|
100
|
+
${_colorVarsStyle(base, tone.hovered)}
|
|
105
101
|
}
|
|
106
102
|
&:active {
|
|
107
|
-
${
|
|
103
|
+
${_colorVarsStyle(base, tone.pressed)}
|
|
108
104
|
}
|
|
109
105
|
}
|
|
110
106
|
}
|
|
@@ -2,14 +2,10 @@ 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 {useTheme} from '../../theme'
|
|
6
|
-
|
|
7
|
-
import {useToneContext} from '../../theme/toneContext/useToneContext'
|
|
5
|
+
import {ThemeColorSpotKey, useTheme} from '../../theme'
|
|
8
6
|
import {AvatarPosition, AvatarSize, AvatarStatus} from '../../types'
|
|
9
7
|
import {Text} from '../text'
|
|
10
|
-
import {spotColor} from './spotColors'
|
|
11
8
|
import {avatarStyle, responsiveAvatarSizeStyle} from './styles'
|
|
12
|
-
import {ThemeColorSpotKey} from './types'
|
|
13
9
|
|
|
14
10
|
/**
|
|
15
11
|
* @public
|
|
@@ -67,10 +63,9 @@ export const Avatar = forwardRef(function Avatar(
|
|
|
67
63
|
const as = ReactIs.isValidElementType(asProp) ? asProp : 'div'
|
|
68
64
|
const size = useArrayProp(sizeProp)
|
|
69
65
|
const theme = useTheme()
|
|
70
|
-
const
|
|
71
|
-
|
|
72
|
-
const color = spotColor[colorKey][scheme].hex
|
|
66
|
+
const color = theme.sanity.color.spot[colorKey] || theme.sanity.color.spot.gray
|
|
73
67
|
|
|
68
|
+
// @todo: remove this
|
|
74
69
|
const avatarSize = theme.sanity.avatar.sizes[size[0]] || theme.sanity.avatar.sizes[0]
|
|
75
70
|
const _sizeRem = avatarSize.size
|
|
76
71
|
const _radius = _sizeRem / 2
|
|
@@ -3,7 +3,6 @@ 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'
|
|
7
6
|
import {AvatarSize} from '../../types'
|
|
8
7
|
import {Text} from '../text'
|
|
9
8
|
|
|
@@ -33,11 +32,11 @@ function _avatarCounterBaseStyle(props: ThemeProps) {
|
|
|
33
32
|
box-sizing: border-box;
|
|
34
33
|
user-select: none;
|
|
35
34
|
color: inherit;
|
|
36
|
-
color:
|
|
37
|
-
background:
|
|
35
|
+
color: var(--card-fg-color);
|
|
36
|
+
background: var(--card-bg-color);
|
|
38
37
|
box-shadow:
|
|
39
|
-
0 0 0 1px
|
|
40
|
-
inset 0 0 0 1.5px
|
|
38
|
+
0 0 0 1px var(--card-bg-color),
|
|
39
|
+
inset 0 0 0 1.5px var(--card-hairline-hard-color);
|
|
41
40
|
padding: 0 ${rem(theme.sanity.space[2])};
|
|
42
41
|
|
|
43
42
|
&:not([hidden]) {
|
|
@@ -1,6 +1,5 @@
|
|
|
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'
|
|
4
3
|
import {CSSObject} from '../../types/styled'
|
|
5
4
|
import {AvatarRootStyleProps, ResponsiveAvatarSizeStyleProps} from './types'
|
|
6
5
|
|
|
@@ -65,7 +64,7 @@ export function avatarRootStyle(props: AvatarRootStyleProps & ThemeProps): CSSOb
|
|
|
65
64
|
position: 'relative',
|
|
66
65
|
boxSizing: 'border-box',
|
|
67
66
|
userSelect: 'none',
|
|
68
|
-
boxShadow:
|
|
67
|
+
boxShadow: '0 0 0 1px var(--card-bg-color)',
|
|
69
68
|
|
|
70
69
|
'&[data-status="inactive"]': {
|
|
71
70
|
opacity: 0.5,
|
|
@@ -124,11 +123,14 @@ export function responsiveAvatarSizeStyle(
|
|
|
124
123
|
})
|
|
125
124
|
}
|
|
126
125
|
|
|
127
|
-
export function avatarInitialsStyle(): CSSObject {
|
|
126
|
+
export function avatarInitialsStyle(props: ThemeProps): CSSObject {
|
|
127
|
+
const {theme} = props
|
|
128
|
+
const {base} = theme.sanity.color
|
|
129
|
+
|
|
128
130
|
return {
|
|
129
131
|
width: '100%',
|
|
130
132
|
height: '100%',
|
|
131
|
-
color:
|
|
133
|
+
color: base.fg,
|
|
132
134
|
alignItems: 'center',
|
|
133
135
|
justifyContent: 'center',
|
|
134
136
|
textTransform: 'uppercase',
|
|
@@ -144,7 +146,7 @@ export function avatarInitialsStyle(): CSSObject {
|
|
|
144
146
|
function avatarBgStrokeStyle(): CSSObject {
|
|
145
147
|
return {
|
|
146
148
|
strokeWidth: '4px',
|
|
147
|
-
stroke:
|
|
149
|
+
stroke: 'var(--card-bg-color)',
|
|
148
150
|
}
|
|
149
151
|
}
|
|
150
152
|
|
|
@@ -13,17 +13,3 @@ 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'
|
|
@@ -1,15 +1,16 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {cssVars} from '../../theme/lib/theme/color/cssVariables/createCssVars'
|
|
1
|
+
import {ThemeProps} from '../../styles'
|
|
3
2
|
import {CSSObject} from '../../types/styled'
|
|
4
3
|
import {BadgeStyleProps} from './types'
|
|
5
4
|
|
|
6
|
-
export function badgeStyle(props: BadgeStyleProps): CSSObject {
|
|
7
|
-
const {$mode, $tone} = props
|
|
5
|
+
export function badgeStyle(props: BadgeStyleProps & ThemeProps): CSSObject {
|
|
6
|
+
const {$mode, $tone, theme} = props
|
|
7
|
+
const palette = theme.sanity.color[$mode === 'outline' ? 'muted' : 'solid']
|
|
8
|
+
const color = palette[$tone] || palette.default
|
|
8
9
|
|
|
9
10
|
return {
|
|
10
|
-
backgroundColor:
|
|
11
|
-
|
|
12
|
-
boxShadow:
|
|
11
|
+
backgroundColor: color.enabled.bg,
|
|
12
|
+
color: color.enabled.fg,
|
|
13
|
+
boxShadow: `inset 0 0 0 1px ${color.enabled.border}`,
|
|
13
14
|
cursor: 'default',
|
|
14
15
|
|
|
15
16
|
'&:not([hidden])': {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {Box, Text
|
|
1
|
+
import {Box, Text} 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 var(--card-border-color)'}}
|
|
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
|
import {useArrayProp} from '../../hooks'
|
|
5
5
|
import {ThemeProps} from '../../styles'
|
|
6
6
|
import {responsiveRadiusStyle, ResponsiveRadiusStyleProps} from '../../styles/internal'
|
|
7
|
-
import {
|
|
7
|
+
import {useTheme} from '../../theme'
|
|
8
8
|
import {ButtonMode, ButtonTextAlign, ButtonTone, FlexJustify} from '../../types'
|
|
9
9
|
import {Box} from '../box'
|
|
10
10
|
import {Flex} from '../flex'
|
|
@@ -49,7 +49,7 @@ const LoadingBox = styled.div`
|
|
|
49
49
|
display: flex;
|
|
50
50
|
align-items: center;
|
|
51
51
|
justify-content: center;
|
|
52
|
-
background-color:
|
|
52
|
+
background-color: var(--card-bg-color);
|
|
53
53
|
border-radius: inherit;
|
|
54
54
|
z-index: 1;
|
|
55
55
|
box-shadow: inherit;
|