@sanity/ui 2.0.0-alpha.6 → 2.0.0-alpha.7

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sanity/ui",
3
- "version": "2.0.0-alpha.6",
3
+ "version": "2.0.0-alpha.7",
4
4
  "sideEffects": false,
5
5
  "types": "./dist/index.d.ts",
6
6
  "source": "./src/index.ts",
@@ -34,7 +34,7 @@ export function MenuGroup(
34
34
  const {
35
35
  as = 'button',
36
36
  children,
37
- fontSize,
37
+ fontSize = 1,
38
38
  icon,
39
39
  onClick,
40
40
  padding = 3,
@@ -176,28 +176,24 @@ export function MenuGroup(
176
176
  tabIndex={-1}
177
177
  type={as === 'button' ? 'button' : undefined}
178
178
  >
179
- <Box padding={padding}>
180
- <Flex>
181
- {icon && (
182
- <Text size={fontSize}>
183
- {isValidElement(icon) && icon}
184
- {isValidElementType(icon) && createElement(icon)}
185
- </Text>
186
- )}
187
-
188
- <Box flex={1} marginLeft={icon ? space : undefined}>
189
- <Text size={fontSize} textOverflow="ellipsis">
190
- {text}
191
- </Text>
192
- </Box>
193
-
194
- <Box marginLeft={space}>
195
- <Text size={fontSize}>
196
- <ChevronRightIcon />
197
- </Text>
198
- </Box>
199
- </Flex>
200
- </Box>
179
+ <Flex gap={space} padding={padding}>
180
+ {icon && (
181
+ <Text size={fontSize}>
182
+ {isValidElement(icon) && icon}
183
+ {isValidElementType(icon) && createElement(icon)}
184
+ </Text>
185
+ )}
186
+
187
+ <Box flex={1}>
188
+ <Text size={fontSize} textOverflow="ellipsis" weight="medium">
189
+ {text}
190
+ </Text>
191
+ </Box>
192
+
193
+ <Text size={fontSize}>
194
+ <ChevronRightIcon />
195
+ </Text>
196
+ </Flex>
201
197
  </Selectable>
202
198
  </Popover>
203
199
  )
@@ -122,7 +122,7 @@ export const MenuItem = forwardRef(function MenuItem(
122
122
  forwardedAs={as}
123
123
  $radius={useArrayProp(radius)}
124
124
  $padding={useArrayProp(0)}
125
- $tone={tone}
125
+ $tone={disabled ? 'default' : tone}
126
126
  $scheme={scheme}
127
127
  disabled={disabled}
128
128
  onClick={handleClick}
@@ -134,43 +134,34 @@ export const MenuItem = forwardRef(function MenuItem(
134
134
  type={as === 'button' ? 'button' : undefined}
135
135
  >
136
136
  {(icon || text || iconRight) && (
137
- <Box as="span" {...paddingProps}>
138
- <Flex as="span">
139
- {icon && (
140
- <Text size={fontSize}>
141
- {isValidElement(icon) && icon}
142
- {isValidElementType(icon) && createElement(icon)}
143
- </Text>
144
- )}
137
+ <Flex as="span" gap={space} align="center" {...paddingProps}>
138
+ {icon && (
139
+ <Text size={fontSize}>
140
+ {isValidElement(icon) && icon}
141
+ {isValidElementType(icon) && createElement(icon)}
142
+ </Text>
143
+ )}
145
144
 
146
- {text && (
147
- <Box
148
- flex={1}
149
- marginLeft={icon ? space : undefined}
150
- marginRight={iconRight ? space : undefined}
151
- >
152
- <Text size={fontSize} textOverflow="ellipsis">
153
- {text}
154
- </Text>
155
- </Box>
156
- )}
145
+ {text && (
146
+ <Box flex={1}>
147
+ <Text size={fontSize} textOverflow="ellipsis" weight="medium">
148
+ {text}
149
+ </Text>
150
+ </Box>
151
+ )}
157
152
 
158
- {hotkeys && (
159
- <Box marginLeft={space} style={{marginTop: -4, marginBottom: -4}}>
160
- <Hotkeys fontSize={fontSize} keys={hotkeys} />
161
- </Box>
162
- )}
153
+ {hotkeys && (
154
+ <Hotkeys fontSize={fontSize} keys={hotkeys} style={{marginTop: -4, marginBottom: -4}} />
155
+ )}
163
156
 
164
- {iconRight && (
165
- <Text size={fontSize}>
166
- {isValidElement(iconRight) && iconRight}
167
- {isValidElementType(iconRight) && createElement(iconRight)}
168
- </Text>
169
- )}
170
- </Flex>
171
- </Box>
157
+ {iconRight && (
158
+ <Text size={fontSize}>
159
+ {isValidElement(iconRight) && iconRight}
160
+ {isValidElementType(iconRight) && createElement(iconRight)}
161
+ </Text>
162
+ )}
163
+ </Flex>
172
164
  )}
173
-
174
165
  {children && (
175
166
  <Box as="span" {...paddingProps}>
176
167
  {children}
@@ -1,9 +1,7 @@
1
1
  import {css} from 'styled-components'
2
2
  import {ThemeProps} from '../../styles'
3
3
  import {
4
- _colorVarStyleActive,
5
4
  _colorVarStyleHover,
6
- _colorVarStyleSelected,
7
5
  _selectableVarStyle,
8
6
  _selectableVarStyleDisabled,
9
7
  } from '../../styles/colorVars'
@@ -47,7 +45,7 @@ export function selectableColorStyle(
47
45
 
48
46
  return css`
49
47
  ${$tone !== 'default' && createCssVars($scheme, theme.sanity.color.tones, $tone)}
50
- ${_selectableVarStyle()}
48
+ ${_selectableVarStyle($tone)}
51
49
 
52
50
  background-color: ${cssVars.mutable['bg-color']};
53
51
  color: ${cssVars[$tone]['text-secondary']};
@@ -61,12 +59,12 @@ export function selectableColorStyle(
61
59
 
62
60
  &:not(:disabled) {
63
61
  &[aria-pressed='true'] {
64
- ${_colorVarStyleActive()}
62
+ ${_colorVarStyleHover()}
65
63
  }
66
64
 
67
65
  &[data-selected],
68
66
  &[aria-selected='true'] > & {
69
- ${_colorVarStyleSelected()}
67
+ ${_colorVarStyleHover()}
70
68
  }
71
69
 
72
70
  @media (hover: hover) {
@@ -77,7 +75,7 @@ export function selectableColorStyle(
77
75
  }
78
76
 
79
77
  &:active {
80
- ${_colorVarStyleActive()}
78
+ ${_colorVarStyleHover()}
81
79
  }
82
80
  }
83
81
  }
@@ -92,11 +90,11 @@ export function selectableColorStyle(
92
90
 
93
91
  &:not([data-disabled]) {
94
92
  &[data-pressed] {
95
- ${_colorVarStyleActive()}
93
+ ${_colorVarStyleHover()}
96
94
  }
97
95
 
98
96
  &[data-selected] {
99
- ${_colorVarStyleSelected()}
97
+ ${_colorVarStyleHover()}
100
98
  }
101
99
 
102
100
  @media (hover: hover) {
@@ -105,9 +103,8 @@ export function selectableColorStyle(
105
103
  &:hover {
106
104
  ${_colorVarStyleHover()}
107
105
  }
108
-
109
106
  &:active {
110
- ${_colorVarStyleActive()}
107
+ ${_colorVarStyleHover()}
111
108
  }
112
109
  }
113
110
  }
@@ -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 {Label} from '../label'
7
+ import {Text} from '../text'
8
8
  import {ResponsiveRadiusProps} from '../types'
9
9
  import {badgeStyle} from './styles'
10
10
  import {BadgeStyleProps} from './types'
@@ -51,7 +51,9 @@ export const Badge = forwardRef(function Badge(
51
51
  padding={useArrayProp(padding)}
52
52
  ref={ref}
53
53
  >
54
- <Label size={fontSize}>{children}</Label>
54
+ <Text size={fontSize} weight="medium">
55
+ {children}
56
+ </Text>
55
57
  </Root>
56
58
  )
57
59
  })
@@ -1,3 +1,4 @@
1
+ import {mutableCardVariables} from '../../theme/lib/theme/color/cssVariables/cardVariables'
1
2
  import {cssVars} from '../../theme/lib/theme/color/cssVariables/createCssVars'
2
3
  import {CSSObject} from '../../types/styled'
3
4
  import {BadgeStyleProps} from './types'
@@ -6,9 +7,8 @@ export function badgeStyle(props: BadgeStyleProps): CSSObject {
6
7
  const {$mode, $tone} = props
7
8
 
8
9
  return {
9
- // backgroundColor: color.enabled.bg,
10
10
  backgroundColor: $mode === 'outline' ? cssVars[$tone]['bg-base'] : cssVars[$tone]['bg-tint'],
11
- color: cssVars[$tone]['text-secondary'],
11
+ [mutableCardVariables['fg-color']]: cssVars[$tone]['text-secondary'],
12
12
  boxShadow: $mode === 'outline' ? `inset 0 0 0 1px ${cssVars[$tone]['border-base']}` : undefined,
13
13
  cursor: 'default',
14
14
 
@@ -1,4 +1,4 @@
1
- import {cssVars} from '../../theme'
1
+ import {ThemeColorToneKey, cssVars} from '../../theme'
2
2
  import {mutableCardVariables} from '../../theme/lib/theme/color/cssVariables/cardVariables'
3
3
  import {getToneCssVar} from '../../theme/lib/theme/color/cssVariables/tones'
4
4
  import {CSSObject} from '../../types/styled'
@@ -14,8 +14,8 @@ export function _colorVarStyleDisabled(checkered = false): CSSObject {
14
14
  [getToneCssVar('default', 'text-code')]: cssVars.default['text-secondary'],
15
15
  [getToneCssVar('default', 'text-primary')]: cssVars.default['text-secondary'],
16
16
 
17
- [mutableCardVariables['fg-color']]: cssVars.primary['text-inactive'],
18
- [mutableCardVariables['muted-fg-color']]: cssVars.primary['text-inactive'],
17
+ [mutableCardVariables['fg-color']]: cssVars.primary['text-secondary'],
18
+ [mutableCardVariables['muted-fg-color']]: cssVars.primary['text-secondary'],
19
19
  [mutableCardVariables['icon-color']]: cssVars.primary['border-base'],
20
20
  [mutableCardVariables['accent-color']]: cssVars.primary['base-bg-card'],
21
21
  [mutableCardVariables['bg-color']]: cssVars.primary['bg-tint'],
@@ -46,6 +46,7 @@ export function _colorVarStyleSelected(): CSSObject {
46
46
  export function _colorVarStyleHover(): CSSObject {
47
47
  return {
48
48
  [mutableCardVariables['bg-color']]: cssVars.default['bg-base-hover'],
49
+ [getToneCssVar('default', 'bg-tint')]: cssVars.default['bg-base-active'],
49
50
  }
50
51
  }
51
52
 
@@ -63,10 +64,11 @@ export function _colorVarStyleActive(): CSSObject {
63
64
  * @internal
64
65
  * Selectable needs to redefine bg-color and fg-color
65
66
  */
66
- export function _selectableVarStyle(): CSSObject {
67
+ export function _selectableVarStyle(tone: ThemeColorToneKey): CSSObject {
67
68
  return {
68
69
  [mutableCardVariables['bg-color']]: 'inherit',
69
- [mutableCardVariables['fg-color']]: cssVars.default['text-secondary'],
70
+ [mutableCardVariables['fg-color']]:
71
+ tone === 'default' ? cssVars.default['text-primary'] : cssVars.default['text-secondary'],
70
72
  }
71
73
  }
72
74
 
@@ -39,10 +39,10 @@ describe('css variables', () => {
39
39
  '--default-border-accent-inverted': '#ffffff',
40
40
  '--default-base-bg-card': '#ffffff',
41
41
  '--default-base-bg-raw': '#ffffff',
42
- '--default-base-shadow-outline-color': 'rgba(120,129,145,0.4)',
43
- '--default-base-shadow-umbra-color': 'rgba(120,129,145,0.2)',
44
- '--default-base-shadow-penumbra-color': 'rgba(120,129,145,0.14)',
45
- '--default-base-shadow-ambient-color': 'rgba(120,129,145,0.12)',
42
+ '--default-base-shadow-outline-color': 'rgba(120,129,145,0.2)',
43
+ '--default-base-shadow-umbra-color': 'rgba(120,129,145,0.1)',
44
+ '--default-base-shadow-penumbra-color': 'rgba(120,129,145,0.07)',
45
+ '--default-base-shadow-ambient-color': 'rgba(120,129,145,0.06)',
46
46
  '--default-base-text-color': '#ffffff',
47
47
  '--default-skeleton-from': '#f3f4f6',
48
48
  '--default-skeleton-to': 'rgba(249,249,250,0.5)',
@@ -69,10 +69,10 @@ describe('css variables', () => {
69
69
  '--transparent-border-accent-inverted': '#ffffff',
70
70
  '--transparent-base-bg-card': '#f9f9fa',
71
71
  '--transparent-base-bg-raw': '#ffffff',
72
- '--transparent-base-shadow-outline-color': 'rgba(120,129,145,0.4)',
73
- '--transparent-base-shadow-umbra-color': 'rgba(120,129,145,0.2)',
74
- '--transparent-base-shadow-penumbra-color': 'rgba(120,129,145,0.14)',
75
- '--transparent-base-shadow-ambient-color': 'rgba(120,129,145,0.12)',
72
+ '--transparent-base-shadow-outline-color': 'rgba(120,129,145,0.2)',
73
+ '--transparent-base-shadow-umbra-color': 'rgba(120,129,145,0.1)',
74
+ '--transparent-base-shadow-penumbra-color': 'rgba(120,129,145,0.07)',
75
+ '--transparent-base-shadow-ambient-color': 'rgba(120,129,145,0.06)',
76
76
  '--transparent-base-text-color': '#ffffff',
77
77
  '--transparent-skeleton-from': '#f3f4f6',
78
78
  '--transparent-skeleton-to': 'rgba(249,249,250,0.5)',
@@ -99,10 +99,10 @@ describe('css variables', () => {
99
99
  '--primary-border-accent-inverted': '#ffffff',
100
100
  '--primary-base-bg-card': '#f9f9fa',
101
101
  '--primary-base-bg-raw': '#ffffff',
102
- '--primary-base-shadow-outline-color': 'rgba(120,129,145,0.4)',
103
- '--primary-base-shadow-umbra-color': 'rgba(120,129,145,0.2)',
104
- '--primary-base-shadow-penumbra-color': 'rgba(120,129,145,0.14)',
105
- '--primary-base-shadow-ambient-color': 'rgba(120,129,145,0.12)',
102
+ '--primary-base-shadow-outline-color': 'rgba(120,129,145,0.2)',
103
+ '--primary-base-shadow-umbra-color': 'rgba(120,129,145,0.1)',
104
+ '--primary-base-shadow-penumbra-color': 'rgba(120,129,145,0.07)',
105
+ '--primary-base-shadow-ambient-color': 'rgba(120,129,145,0.06)',
106
106
  '--primary-base-text-color': '#ffffff',
107
107
  '--primary-skeleton-from': '#f3f4f6',
108
108
  '--primary-skeleton-to': 'rgba(249,249,250,0.5)',
@@ -129,10 +129,10 @@ describe('css variables', () => {
129
129
  '--positive-border-accent-inverted': '#ffffff',
130
130
  '--positive-base-bg-card': '#ebfdff',
131
131
  '--positive-base-bg-raw': '#ffffff',
132
- '--positive-base-shadow-outline-color': 'rgba(14,207,241,0.4)',
133
- '--positive-base-shadow-umbra-color': 'rgba(14,207,241,0.2)',
134
- '--positive-base-shadow-penumbra-color': 'rgba(14,207,241,0.14)',
135
- '--positive-base-shadow-ambient-color': 'rgba(14,207,241,0.12)',
132
+ '--positive-base-shadow-outline-color': 'rgba(14,207,241,0.2)',
133
+ '--positive-base-shadow-umbra-color': 'rgba(14,207,241,0.1)',
134
+ '--positive-base-shadow-penumbra-color': 'rgba(14,207,241,0.07)',
135
+ '--positive-base-shadow-ambient-color': 'rgba(14,207,241,0.06)',
136
136
  '--positive-base-text-color': '#ffffff',
137
137
  '--positive-skeleton-from': '#d2fcfe',
138
138
  '--positive-skeleton-to': 'rgba(235,253,255,0.5)',
@@ -159,10 +159,10 @@ describe('css variables', () => {
159
159
  '--caution-border-accent-inverted': '#ffffff',
160
160
  '--caution-base-bg-card': '#fffdf0',
161
161
  '--caution-base-bg-raw': '#ffffff',
162
- '--caution-base-shadow-outline-color': 'rgba(243,188,22,0.4)',
163
- '--caution-base-shadow-umbra-color': 'rgba(243,188,22,0.2)',
164
- '--caution-base-shadow-penumbra-color': 'rgba(243,188,22,0.14)',
165
- '--caution-base-shadow-ambient-color': 'rgba(243,188,22,0.12)',
162
+ '--caution-base-shadow-outline-color': 'rgba(243,188,22,0.2)',
163
+ '--caution-base-shadow-umbra-color': 'rgba(243,188,22,0.1)',
164
+ '--caution-base-shadow-penumbra-color': 'rgba(243,188,22,0.07)',
165
+ '--caution-base-shadow-ambient-color': 'rgba(243,188,22,0.06)',
166
166
  '--caution-base-text-color': '#ffffff',
167
167
  '--caution-skeleton-from': '#fef7cd',
168
168
  '--caution-skeleton-to': 'rgba(255,253,240,0.5)',
@@ -189,10 +189,10 @@ describe('css variables', () => {
189
189
  '--critical-border-accent-inverted': '#ffffff',
190
190
  '--critical-base-bg-card': '#fff5f5',
191
191
  '--critical-base-bg-raw': '#ffffff',
192
- '--critical-base-shadow-outline-color': 'rgba(236,70,54,0.4)',
193
- '--critical-base-shadow-umbra-color': 'rgba(236,70,54,0.2)',
194
- '--critical-base-shadow-penumbra-color': 'rgba(236,70,54,0.14)',
195
- '--critical-base-shadow-ambient-color': 'rgba(236,70,54,0.12)',
192
+ '--critical-base-shadow-outline-color': 'rgba(236,70,54,0.2)',
193
+ '--critical-base-shadow-umbra-color': 'rgba(236,70,54,0.1)',
194
+ '--critical-base-shadow-penumbra-color': 'rgba(236,70,54,0.07)',
195
+ '--critical-base-shadow-ambient-color': 'rgba(236,70,54,0.06)',
196
196
  '--critical-base-text-color': '#ffffff',
197
197
  '--critical-skeleton-from': '#fee8e7',
198
198
  '--critical-skeleton-to': 'rgba(255,245,245,0.5)',
@@ -112,22 +112,22 @@ const defaultTints: Record<ThemeColorSchemeKey, ColorTintsDictionary> = {
112
112
  'base-shadow-outline-color': {
113
113
  type: 'colorWithOpacity',
114
114
  tint: '500',
115
- opacity: 0.4,
115
+ opacity: 0.2,
116
116
  },
117
117
  'base-shadow-umbra-color': {
118
118
  type: 'colorWithOpacity',
119
119
  tint: '500',
120
- opacity: 0.2,
120
+ opacity: 0.1,
121
121
  },
122
122
  'base-shadow-penumbra-color': {
123
123
  type: 'colorWithOpacity',
124
124
  tint: '500',
125
- opacity: 0.14,
125
+ opacity: 0.07,
126
126
  },
127
127
  'base-shadow-ambient-color': {
128
128
  type: 'colorWithOpacity',
129
129
  tint: '500',
130
- opacity: 0.12,
130
+ opacity: 0.06,
131
131
  },
132
132
  'skeleton-from': '100',
133
133
  'skeleton-to': {
@@ -39,7 +39,7 @@ export const studioTheme: RootTheme = {
39
39
  shadows: [
40
40
  null,
41
41
  {umbra: [0, 0, 0, 0], penumbra: [0, 0, 0, 0], ambient: [0, 0, 0, 0]},
42
- {umbra: [0, 3, 5, -1], penumbra: [0, 6, 10, 0], ambient: [0, 1, 18, 0]},
42
+ {umbra: [0, 3, 5, -2], penumbra: [0, 6, 10, 0], ambient: [0, 1, 18, 1]},
43
43
  {umbra: [0, 7, 8, -4], penumbra: [0, 12, 17, 2], ambient: [0, 5, 22, 4]},
44
44
  {umbra: [0, 9, 11, -5], penumbra: [0, 18, 28, 2], ambient: [0, 7, 34, 6]},
45
45
  {umbra: [0, 11, 15, -7], penumbra: [0, 24, 38, 3], ambient: [0, 9, 46, 8]},