@sanity/ui 2.0.0-alpha.4 → 2.0.0-alpha.6
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 -1
- package/dist/index.d.ts +294 -407
- package/dist/index.esm.js +794 -2148
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +795 -2147
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/src/components/dialog/dialog.tsx +3 -3
- package/src/components/dialog/styles.ts +3 -4
- package/src/components/menu/__workshop__/closableMenuButton.tsx +2 -2
- package/src/components/menu/menuDivider.ts +2 -1
- package/src/components/menu/menuGroup.tsx +3 -0
- package/src/components/menu/menuItem.tsx +6 -3
- package/src/components/skeleton/styles.ts +8 -7
- package/src/components/tree/style.ts +19 -20
- package/src/primitives/_selectable/style.ts +27 -21
- 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 +5 -7
- package/src/primitives/avatar/types.ts +14 -0
- package/src/primitives/badge/styles.ts +7 -8
- package/src/primitives/box/__workshop__/responsive.tsx +2 -2
- package/src/primitives/button/button.tsx +2 -2
- package/src/primitives/button/styles.ts +82 -16
- package/src/primitives/card/__workshop__/selected.tsx +8 -9
- package/src/primitives/card/card.tsx +43 -7
- package/src/primitives/card/styles.ts +30 -22
- package/src/primitives/card/types.ts +3 -1
- package/src/primitives/checkbox/styles.ts +20 -20
- 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 +2 -1
- package/src/primitives/label/styles.ts +3 -2
- package/src/primitives/popover/popoverArrow.tsx +3 -2
- package/src/primitives/popover/popoverCard.tsx +6 -2
- package/src/primitives/radio/styles.ts +15 -15
- package/src/primitives/select/styles.ts +20 -22
- package/src/primitives/switch/styles.ts +13 -13
- package/src/primitives/text/__workshop__/colored.tsx +10 -11
- package/src/primitives/text/styles.ts +10 -9
- package/src/primitives/textArea/textArea.tsx +8 -12
- package/src/primitives/textInput/textInput.tsx +13 -13
- package/src/primitives/tooltip/__workshop__/props.tsx +20 -3
- package/src/primitives/tooltip/tooltipArrow.tsx +3 -2
- package/src/styles/border/borderStyle.ts +2 -1
- package/src/styles/colorVars/colorVarsStyle.ts +71 -32
- package/src/styles/focusRing/index.ts +6 -4
- package/src/styles/input/textInputStyle.ts +76 -93
- package/src/styles/margin/marginsStyle.test.ts +1 -2
- package/src/styles/padding/paddingStyle.test.ts +1 -2
- 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/color/cssVariables/cardVariables.ts +92 -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 +2 -12
- package/src/theme/lib/theme/color/types.ts +6 -37
- package/src/theme/studioTheme/color.ts +2 -641
- package/src/theme/studioTheme/helpers.ts +15 -1
- package/src/theme/studioTheme/theme.ts +8 -2
- package/src/theme/themeColorProvider.tsx +2 -0
- package/src/theme/themeProvider.tsx +27 -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 +2 -4
- 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 -30
- 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 -63
- package/src/theme/lib/theme/color/defaults.ts +0 -390
- 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 -28
- 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
- package/src/theme/studioTheme/tints.ts +0 -152
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sanity/ui",
|
|
3
|
-
"version": "2.0.0-alpha.
|
|
3
|
+
"version": "2.0.0-alpha.6",
|
|
4
4
|
"sideEffects": false,
|
|
5
5
|
"types": "./dist/index.d.ts",
|
|
6
6
|
"source": "./src/index.ts",
|
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
},
|
|
53
53
|
"dependencies": {
|
|
54
54
|
"@floating-ui/react-dom": "2.0.0",
|
|
55
|
-
"@sanity/color": "3.0.0-beta.
|
|
55
|
+
"@sanity/color": "3.0.0-beta.5",
|
|
56
56
|
"@sanity/icons": "^2.4.1",
|
|
57
57
|
"csstype": "^3.1.2",
|
|
58
58
|
"framer-motion": "^10.16.2",
|
|
@@ -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, useTheme} from '../../theme'
|
|
14
|
+
import {ThemeColorSchemeKey, cssVars, 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(Card)<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 ${cssVars.default['border-base']};
|
|
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 ${cssVars.default['border-base']};
|
|
168
168
|
width: auto;
|
|
169
169
|
opacity: ${(props) => (props.$isContentScrollable && !props.$hasScrolledToBottom ? 1 : 0)};
|
|
170
170
|
transition: opacity 200ms ease-in;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import {_responsive, ThemeProps} from '../../styles'
|
|
2
|
+
import {cssVars} from '../../theme'
|
|
2
3
|
import {DialogPosition} from '../../types'
|
|
3
4
|
import {CSSObject} from '../../types/styled'
|
|
4
5
|
|
|
@@ -9,9 +10,7 @@ export interface ResponsiveDialogPositionStyleProps {
|
|
|
9
10
|
$position: DialogPosition[]
|
|
10
11
|
}
|
|
11
12
|
|
|
12
|
-
export function dialogStyle(
|
|
13
|
-
const color = theme.sanity.color.base
|
|
14
|
-
|
|
13
|
+
export function dialogStyle(): CSSObject {
|
|
15
14
|
return {
|
|
16
15
|
'&:not([hidden])': {
|
|
17
16
|
display: 'flex',
|
|
@@ -24,7 +23,7 @@ export function dialogStyle({theme}: ThemeProps): CSSObject {
|
|
|
24
23
|
alignItems: 'center',
|
|
25
24
|
justifyContent: 'center',
|
|
26
25
|
outline: 'none',
|
|
27
|
-
background:
|
|
26
|
+
background: cssVars.default['base-shadow-umbra-color'],
|
|
28
27
|
}
|
|
29
28
|
}
|
|
30
29
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import {AddIcon} from '@sanity/icons'
|
|
2
|
-
import {Box, Button, Menu, MenuButton, MenuButtonProps, MenuItem, Stack} from '@sanity/ui'
|
|
2
|
+
import {Box, Button, Menu, MenuButton, MenuButtonProps, MenuItem, Stack, cssVars} 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 ${cssVars.default['border-base']}`}}>
|
|
27
27
|
<Button
|
|
28
28
|
icon={AddIcon}
|
|
29
29
|
onClick={() => {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import styled from 'styled-components'
|
|
2
|
+
import {cssVars} from '../../theme'
|
|
2
3
|
|
|
3
4
|
/**
|
|
4
5
|
* @public
|
|
@@ -6,6 +7,6 @@ import styled from 'styled-components'
|
|
|
6
7
|
export const MenuDivider = styled.hr`
|
|
7
8
|
height: 1px;
|
|
8
9
|
border: 0;
|
|
9
|
-
background:
|
|
10
|
+
background: ${cssVars.default['border-base']};
|
|
10
11
|
margin: 0;
|
|
11
12
|
`
|
|
@@ -4,6 +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 {useToneContext} from '../../theme/toneContext/useToneContext'
|
|
7
8
|
import {Radius, SelectableTone} from '../../types'
|
|
8
9
|
import {Menu} from './menu'
|
|
9
10
|
import {useMenu} from './useMenu'
|
|
@@ -44,6 +45,7 @@ export function MenuGroup(
|
|
|
44
45
|
tone = 'default',
|
|
45
46
|
...restProps
|
|
46
47
|
} = props
|
|
48
|
+
const {scheme} = useToneContext()
|
|
47
49
|
const menu = useMenu()
|
|
48
50
|
const {
|
|
49
51
|
activeElement,
|
|
@@ -166,6 +168,7 @@ export function MenuGroup(
|
|
|
166
168
|
data-selected={!withinMenu && active ? '' : undefined}
|
|
167
169
|
$radius={useArrayProp(radius)}
|
|
168
170
|
$tone={tone}
|
|
171
|
+
$scheme={scheme}
|
|
169
172
|
onClick={handleClick}
|
|
170
173
|
onKeyDown={handleKeyDown}
|
|
171
174
|
onMouseEnter={handleMouseEnter}
|
|
@@ -12,7 +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 {
|
|
15
|
+
import {ThemeColorToneKey} from '../../theme'
|
|
16
|
+
import {useToneContext} from '../../theme/toneContext/useToneContext'
|
|
16
17
|
import {Hotkeys} from '../hotkeys'
|
|
17
18
|
import {useMenu} from './useMenu'
|
|
18
19
|
|
|
@@ -29,7 +30,7 @@ export interface MenuItemProps extends ResponsivePaddingProps, ResponsiveRadiusP
|
|
|
29
30
|
selected?: boolean
|
|
30
31
|
space?: number | number[]
|
|
31
32
|
text?: React.ReactNode
|
|
32
|
-
tone?:
|
|
33
|
+
tone?: ThemeColorToneKey
|
|
33
34
|
}
|
|
34
35
|
|
|
35
36
|
/**
|
|
@@ -44,7 +45,7 @@ export const MenuItem = forwardRef(function MenuItem(
|
|
|
44
45
|
as = 'button',
|
|
45
46
|
children,
|
|
46
47
|
disabled,
|
|
47
|
-
fontSize =
|
|
48
|
+
fontSize = 1,
|
|
48
49
|
hotkeys,
|
|
49
50
|
icon,
|
|
50
51
|
iconRight,
|
|
@@ -64,6 +65,7 @@ export const MenuItem = forwardRef(function MenuItem(
|
|
|
64
65
|
tone = 'default',
|
|
65
66
|
...restProps
|
|
66
67
|
} = props
|
|
68
|
+
const {scheme} = useToneContext()
|
|
67
69
|
const menu = useMenu()
|
|
68
70
|
const {
|
|
69
71
|
activeElement,
|
|
@@ -121,6 +123,7 @@ export const MenuItem = forwardRef(function MenuItem(
|
|
|
121
123
|
$radius={useArrayProp(radius)}
|
|
122
124
|
$padding={useArrayProp(0)}
|
|
123
125
|
$tone={tone}
|
|
126
|
+
$scheme={scheme}
|
|
124
127
|
disabled={disabled}
|
|
125
128
|
onClick={handleClick}
|
|
126
129
|
onMouseEnter={onItemMouseEnter}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import {css, keyframes} from 'styled-components'
|
|
2
|
+
import {cssVars} from '../../theme'
|
|
2
3
|
|
|
3
4
|
const keyframe = keyframes`
|
|
4
5
|
0% {
|
|
@@ -12,11 +13,11 @@ const keyframe = keyframes`
|
|
|
12
13
|
const animation = css`
|
|
13
14
|
background-image: linear-gradient(
|
|
14
15
|
to right,
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
16
|
+
${cssVars.default['skeleton-from']},
|
|
17
|
+
${cssVars.default['skeleton-to']},
|
|
18
|
+
${cssVars.default['skeleton-from']},
|
|
19
|
+
${cssVars.default['skeleton-from']},
|
|
20
|
+
${cssVars.default['skeleton-from']}
|
|
20
21
|
);
|
|
21
22
|
background-position: 100%;
|
|
22
23
|
background-size: 200% 100%;
|
|
@@ -40,11 +41,11 @@ export const skeletonStyle = css<{$animated: boolean; $visible: boolean}>`
|
|
|
40
41
|
$animated
|
|
41
42
|
? animation
|
|
42
43
|
: css`
|
|
43
|
-
background-color:
|
|
44
|
+
background-color: ${cssVars.default['skeleton-from']};
|
|
44
45
|
`}
|
|
45
46
|
}
|
|
46
47
|
|
|
47
48
|
@media screen and (prefers-reduced-motion: reduce) {
|
|
48
|
-
background-color:
|
|
49
|
+
background-color: ${cssVars.default['skeleton-from']};
|
|
49
50
|
}
|
|
50
51
|
`
|
|
@@ -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,21 @@
|
|
|
1
1
|
import {css} from 'styled-components'
|
|
2
2
|
import {ThemeProps} from '../../styles'
|
|
3
|
-
import {
|
|
4
|
-
|
|
3
|
+
import {
|
|
4
|
+
_colorVarStyleActive,
|
|
5
|
+
_colorVarStyleHover,
|
|
6
|
+
_colorVarStyleSelected,
|
|
7
|
+
_selectableVarStyle,
|
|
8
|
+
_selectableVarStyleDisabled,
|
|
9
|
+
} from '../../styles/colorVars'
|
|
10
|
+
|
|
11
|
+
import {ThemeColorSchemeKey, ThemeColorToneKey, createCssVars, cssVars} from '../../theme'
|
|
5
12
|
|
|
6
13
|
/**
|
|
7
14
|
* @internal
|
|
8
15
|
*/
|
|
9
16
|
export interface SelectableStyleProps {
|
|
10
|
-
$tone:
|
|
17
|
+
$tone: ThemeColorToneKey
|
|
18
|
+
$scheme: ThemeColorSchemeKey
|
|
11
19
|
}
|
|
12
20
|
|
|
13
21
|
export function selectableBaseStyle(): ReturnType<typeof css> {
|
|
@@ -35,43 +43,41 @@ export function selectableBaseStyle(): ReturnType<typeof css> {
|
|
|
35
43
|
export function selectableColorStyle(
|
|
36
44
|
props: SelectableStyleProps & ThemeProps,
|
|
37
45
|
): ReturnType<typeof css> {
|
|
38
|
-
const {$tone,
|
|
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
|
|
46
|
+
const {theme, $tone, $scheme} = props
|
|
42
47
|
|
|
43
48
|
return css`
|
|
44
|
-
${
|
|
49
|
+
${$tone !== 'default' && createCssVars($scheme, theme.sanity.color.tones, $tone)}
|
|
50
|
+
${_selectableVarStyle()}
|
|
45
51
|
|
|
46
|
-
background-color:
|
|
47
|
-
color:
|
|
52
|
+
background-color: ${cssVars.mutable['bg-color']};
|
|
53
|
+
color: ${cssVars[$tone]['text-secondary']};
|
|
48
54
|
outline: none;
|
|
49
55
|
|
|
50
|
-
/* &:is(button) */
|
|
56
|
+
/* &:is(button) - Looks like a button in default mode */
|
|
51
57
|
&[data-as='button'] {
|
|
52
58
|
&:disabled {
|
|
53
|
-
${
|
|
59
|
+
${_selectableVarStyleDisabled()}
|
|
54
60
|
}
|
|
55
61
|
|
|
56
62
|
&:not(:disabled) {
|
|
57
63
|
&[aria-pressed='true'] {
|
|
58
|
-
${
|
|
64
|
+
${_colorVarStyleActive()}
|
|
59
65
|
}
|
|
60
66
|
|
|
61
67
|
&[data-selected],
|
|
62
68
|
&[aria-selected='true'] > & {
|
|
63
|
-
${
|
|
69
|
+
${_colorVarStyleSelected()}
|
|
64
70
|
}
|
|
65
71
|
|
|
66
72
|
@media (hover: hover) {
|
|
67
73
|
&:not([data-selected]) {
|
|
68
74
|
&[data-hovered],
|
|
69
75
|
&:hover {
|
|
70
|
-
${
|
|
76
|
+
${_colorVarStyleHover()}
|
|
71
77
|
}
|
|
72
78
|
|
|
73
79
|
&:active {
|
|
74
|
-
${
|
|
80
|
+
${_colorVarStyleActive()}
|
|
75
81
|
}
|
|
76
82
|
}
|
|
77
83
|
}
|
|
@@ -81,27 +87,27 @@ export function selectableColorStyle(
|
|
|
81
87
|
/* &:is(a) */
|
|
82
88
|
&[data-as='a'] {
|
|
83
89
|
&[data-disabled] {
|
|
84
|
-
${
|
|
90
|
+
${_selectableVarStyleDisabled()}
|
|
85
91
|
}
|
|
86
92
|
|
|
87
93
|
&:not([data-disabled]) {
|
|
88
94
|
&[data-pressed] {
|
|
89
|
-
${
|
|
95
|
+
${_colorVarStyleActive()}
|
|
90
96
|
}
|
|
91
97
|
|
|
92
98
|
&[data-selected] {
|
|
93
|
-
${
|
|
99
|
+
${_colorVarStyleSelected()}
|
|
94
100
|
}
|
|
95
101
|
|
|
96
102
|
@media (hover: hover) {
|
|
97
103
|
&:not([data-selected]) {
|
|
98
104
|
&[data-hovered],
|
|
99
105
|
&:hover {
|
|
100
|
-
${
|
|
106
|
+
${_colorVarStyleHover()}
|
|
101
107
|
}
|
|
102
108
|
|
|
103
109
|
&:active {
|
|
104
|
-
${
|
|
110
|
+
${_colorVarStyleActive()}
|
|
105
111
|
}
|
|
106
112
|
}
|
|
107
113
|
}
|
|
@@ -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
|
|
|
@@ -64,7 +65,7 @@ export function avatarRootStyle(props: AvatarRootStyleProps & ThemeProps): CSSOb
|
|
|
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'
|
|
@@ -1,16 +1,15 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {cssVars} from '../../theme/lib/theme/color/cssVariables/createCssVars'
|
|
2
2
|
import {CSSObject} from '../../types/styled'
|
|
3
3
|
import {BadgeStyleProps} from './types'
|
|
4
4
|
|
|
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
|
|
5
|
+
export function badgeStyle(props: BadgeStyleProps): CSSObject {
|
|
6
|
+
const {$mode, $tone} = props
|
|
9
7
|
|
|
10
8
|
return {
|
|
11
|
-
backgroundColor: color.enabled.bg,
|
|
12
|
-
|
|
13
|
-
|
|
9
|
+
// backgroundColor: color.enabled.bg,
|
|
10
|
+
backgroundColor: $mode === 'outline' ? cssVars[$tone]['bg-base'] : cssVars[$tone]['bg-tint'],
|
|
11
|
+
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
|
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'
|
|
@@ -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: ${cssVars.mutable['bg-color']};
|
|
53
53
|
border-radius: inherit;
|
|
54
54
|
z-index: 1;
|
|
55
55
|
box-shadow: inherit;
|