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

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.8",
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
 
@@ -0,0 +1,7 @@
1
+ /**
2
+ * @internal
3
+ * @deprecated Use studioTheme instead.
4
+ */
5
+ export function createColorTheme(): null {
6
+ return null
7
+ }
@@ -0,0 +1 @@
1
+ export * from './createColorTheme'