@sanity/ui 5.0.0-alpha.16 → 5.0.0-alpha.18

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": "5.0.0-alpha.16",
3
+ "version": "5.0.0-alpha.18",
4
4
  "description": "Sanity UI Library",
5
5
  "keywords": [
6
6
  "components",
@@ -48,7 +48,7 @@
48
48
  }
49
49
  },
50
50
  "dependencies": {
51
- "@sanity-labs/design-tokens": "0.0.2-alpha.7",
51
+ "@sanity-labs/design-tokens": "0.0.2-alpha.9",
52
52
  "@sanity/icons": "^5.2.1",
53
53
  "clsx": "^2.1.1",
54
54
  "comment-json": "^5.0.0",
@@ -46,7 +46,13 @@ export function Button<T extends ElementType = 'button'>({
46
46
  {...rest}
47
47
  >
48
48
  {loading && (
49
- <Flex position="absolute" inset={0} alignItems="center" justifyContent="center">
49
+ <Flex
50
+ position="absolute"
51
+ inset={0}
52
+ alignItems="center"
53
+ justifyContent="center"
54
+ data-ui="Button-Spinner"
55
+ >
50
56
  <Spinner />
51
57
  </Flex>
52
58
  )}
@@ -1,72 +1,84 @@
1
+ /**
2
+ * Button defaults
3
+ */
1
4
  .sui-Button {
5
+ --background-color: hsl(from var(--backdrop) h s l / var(--opacity-high));
6
+ --foreground-color: var(--foreground-high);
7
+ --hover-blend-color: var(--gray-500);
2
8
  background: var(--background-color);
3
9
  box-shadow: inset 0 0 0 1px var(--border-color, transparent);
4
10
  color: var(--foreground-color);
5
11
  text-decoration: none;
6
- transition: var(--hover-transition);
12
+ transition: var(--hover-transition), transform 100ms linear;
7
13
  appearance: none;
8
14
  }
9
15
 
10
16
  .sui-Button:hover {
11
17
  background: color-mix(
12
18
  in srgb,
13
- var(--tone-500) 12%,
14
- var(--background-color)
15
- );
16
- }
17
-
18
- .sui-Button.sui-button-level-primary:hover {
19
- background: color-mix(
20
- in srgb,
21
- var(--tone-950) 12%,
19
+ var(--hover-blend-color) 12%,
22
20
  var(--background-color)
23
21
  );
24
22
  }
25
23
 
26
- .sui-Button[class*='sui-tone']:disabled {
27
- --background-color: var(--inert-background);
28
- --foreground-color: var(--inert-foreground);
29
- --border-color: transparent;
30
- pointer-events: none;
31
- }
32
-
33
24
  .sui-Button:focus-visible {
34
25
  outline: var(--focus-outline);
35
26
  outline-offset: var(--focus-offset);
36
27
  }
37
28
 
29
+ .sui-Button:active {
30
+ transform: scale(0.975);
31
+ }
32
+
38
33
  .sui-Button :is([data-sanity-icon], .sui-Spinner, .sui-Text) {
39
34
  color: inherit;
40
35
  }
41
36
 
42
- .sui-Button > .sui-Flex + * {
37
+ .sui-Button > [data-ui="Button-Spinner"] + * {
43
38
  opacity: 0;
44
39
  }
45
40
 
41
+ /**
42
+ * Disabled
43
+ */
44
+ .sui-Button[class*='sui-tone']:disabled {
45
+ --background-color: var(--inert-background);
46
+ --foreground-color: var(--inert-foreground);
47
+ --border-color: transparent;
48
+ pointer-events: none;
49
+ }
50
+
51
+ /**
52
+ * Primary
53
+ */
46
54
  .sui-button-level-primary {
47
55
  --background-color: var(--background-high-emphasized);
48
56
  --foreground-color: var(--foreground-low-emphasized);
57
+ --hover-blend-color: light-dark(var(--gray-950), var(--gray-50));
49
58
  }
50
59
 
51
60
  .sui-button-level-primary.sui-tone-critical {
52
61
  --background-color: var(--background-low-emphasized);
62
+ --hover-blend-color: light-dark(var(--red-950), var(--red-50));
53
63
  }
54
64
 
65
+ /**
66
+ * Secondary
67
+ */
55
68
  .sui-button-level-secondary {
56
- --background-color: var(--background-high);
57
- --foreground-color: var(--foreground-high);
58
69
  --border-color: var(--separator-low)
59
70
  }
60
71
 
61
72
  .sui-button-level-secondary.sui-tone-critical {
73
+ --background-color: var(--background-low);
62
74
  --foreground-color: var(--foreground-low);
75
+ --hover-blend-color: var(--red-500);
63
76
  }
64
77
 
65
- .sui-button-level-tertiary {
66
- --background-color: transparent;
67
- --foreground-color: var(--foreground-high);
68
- }
69
-
78
+ /**
79
+ * Tertiary
80
+ */
70
81
  .sui-button-level-tertiary.sui-tone-critical {
71
82
  --foreground-color: var(--foreground-low);
83
+ --hover-blend-color: var(--red-500);
72
84
  }
@@ -10,7 +10,7 @@ const cardClassName = suffixClassName('sui-Card')
10
10
  /** @public */
11
11
  export function Card<T extends ElementType = 'div'>({
12
12
  density = 'regular',
13
- tone = 'neutral',
13
+ tone = 'default',
14
14
  ...props
15
15
  }: CardProps<T> & Omit<ComponentPropsWithRef<T>, keyof CardProps<T>>) {
16
16
  const {as, children, className, style, ...rest} = getProps({density, tone, ...props}, cardProps)
@@ -2,13 +2,14 @@ import {borderProps} from '../../props/border'
2
2
  import {gapProps} from '../../props/gap'
3
3
  import {type MarginProps, marginProps} from '../../props/margin'
4
4
  import {paddingProps} from '../../props/padding'
5
- import {type ToneProps, toneProps} from '../../props/tone'
5
+ import {toneWithDefaultProps, type ToneWithDefaultProps} from '../../props/tone'
6
6
  import {DENSITY, type Density} from '../../types/Density'
7
7
  import {type PropDef} from '../../types/PropDef'
8
8
  import {type Responsive} from '../../types/Responsive'
9
9
 
10
10
  /** @public */
11
- export interface CardProps<T extends React.ElementType = 'div'> extends MarginProps, ToneProps {
11
+ export interface CardProps<T extends React.ElementType = 'div'>
12
+ extends MarginProps, ToneWithDefaultProps {
12
13
  /**
13
14
  * HTML element or component to render.
14
15
  */
@@ -53,6 +54,6 @@ export const cardProps: Record<string, PropDef> = {
53
54
  },
54
55
  },
55
56
  } satisfies PropDef<Density>,
56
- ...toneProps,
57
+ ...toneWithDefaultProps,
57
58
  ...marginProps,
58
59
  }
@@ -1,4 +1,4 @@
1
1
  .sui-Indicator[class*='sui-tone'] {
2
- --indicator-background: var(--tone-500);
2
+ --indicator-background: var(--separator-high);
3
3
  background-color: var(--indicator-background);
4
4
  }
@@ -15,6 +15,7 @@ export function Spinner({size = 2, ...props}: SpinnerProps) {
15
15
  return (
16
16
  <Icon
17
17
  icon={SpinnerIcon}
18
+ size={size}
18
19
  className={clsx(spinnerClassName, className)}
19
20
  style={style}
20
21
  data-ui="Spinner"
@@ -3,5 +3,4 @@
3
3
  @import './field-sizing.css';
4
4
  @import './text-overflow.css';
5
5
  @import './text-trim.css';
6
- @import './tone.css';
7
6
  @import './top-anchor.css';
@@ -1,7 +1,4 @@
1
1
  :root {
2
- --backdrop: light-dark(var(--white), var(--black));
3
- --brand-background: #eb5228;
4
- --brand-foreground: var(--black);
5
2
  --placeholder-opacity: 0.64;
6
3
  --overlay-opacity: var(--opacity-mid);
7
4
  /* State */
@@ -15,8 +12,8 @@
15
12
  --focus-outline: 2px solid var(--blue-500);
16
13
  --focus-offset: 2px;
17
14
  --hover-lightness-delta: 0.125;
18
- --hover-transition: border-color 100ms linear, background-color 100ms linear;
19
- --inert-background: light-dark(var(--gray-50), var(--gray-950));
15
+ --hover-transition: border-color 100ms linear, background-color 100ms linear, transform 100ms linear;
16
+ --inert-background: light-dark(var(--gray-50), var(--gray-800));
20
17
  --inert-foreground: light-dark(var(--gray-400), var(--gray-600));
21
18
  --fade-in-transition:
22
19
  opacity 200ms cubic-bezier(0.34, 1.2, 0.64, 1),
@@ -1,12 +1,16 @@
1
+ /* Untoned surface */
1
2
  :root {
2
- /* Default surface */
3
+ --backdrop: light-dark(var(--white), var(--black));
3
4
  --background-high: light-dark(var(--gray-100), var(--gray-900));
4
5
  --background-high-emphasized: light-dark(var(--gray-800), var(--gray-200));
5
6
  --background-low: light-dark(var(--gray-50), var(--gray-950));
6
7
  --background-low-emphasized: light-dark(var(--gray-600), var(--gray-400));
8
+ --brand-background: #eb5228;
9
+ --brand-foreground: var(--black);
7
10
  --separator-high: light-dark(var(--gray-400), var(--gray-600));
8
11
  --separator-low: rgb(from var(--separator-high) r g b / var(--opacity-low));
9
12
  --foreground-high: light-dark(var(--gray-800), var(--gray-200));
13
+ /* This property stable across all tones */
10
14
  --foreground-high-emphasized: light-dark(var(--white), var(--black));
11
15
  --foreground-low: light-dark(var(--gray-600), var(--gray-400));
12
16
  --foreground-low-emphasized: light-dark(var(--gray-100), var(--gray-900));
@@ -14,16 +18,76 @@
14
18
  --form-element-text: var(--regular) 13px / 1.15 var(--sans);
15
19
  }
16
20
 
17
- [class*='sui-tone'] {
18
- /* Toned surface */
19
- --background-high: var(--tone-100);
20
- --background-high-emphasized: var(--tone-800);
21
- --background-low: var(--tone-50);
22
- --background-low-emphasized: var(--tone-600);
23
- --separator-high: var(--tone-400);
21
+ /* Default tone mirrors untoned surface except for backgrounds */
22
+ .sui-tone-default {
23
+ --background-high: var(--backdrop);
24
+ --background-high-emphasized: var(--backdrop);
25
+ --background-low: var(--backdrop);
26
+ --background-low-emphasized: var(--backdrop);
27
+ --separator-high: light-dark(var(--gray-400), var(--gray-600));
28
+ --separator-low: rgb(from var(--separator-high) r g b / var(--opacity-low));
29
+ --foreground-high: light-dark(var(--gray-800), var(--gray-200));
30
+ --foreground-low: light-dark(var(--gray-600), var(--gray-400));
31
+ --foreground-low-emphasized: light-dark(var(--gray-100), var(--gray-900));
32
+ }
33
+
34
+ /* Toned surfaces */
35
+ .sui-tone-neutral {
36
+ --background-high: light-dark(var(--gray-100), var(--gray-900));
37
+ --background-high-emphasized: light-dark(var(--gray-800), var(--gray-200));
38
+ --background-low: light-dark(var(--gray-50), var(--gray-950));
39
+ --background-low-emphasized: light-dark(var(--gray-600), var(--gray-400));
40
+ --separator-high: light-dark(var(--gray-400), var(--gray-600));
41
+ --separator-low: rgb(from var(--separator-high) r g b / var(--opacity-low));
42
+ --foreground-high: light-dark(var(--gray-800), var(--gray-200));
43
+ --foreground-low: light-dark(var(--gray-600), var(--gray-400));
44
+ --foreground-low-emphasized: light-dark(var(--gray-100), var(--gray-900));
45
+ }
46
+
47
+ .sui-tone-suggest {
48
+ --background-high: light-dark(var(--purple-100), var(--purple-900));
49
+ --background-high-emphasized: light-dark(var(--purple-800), var(--purple-200));
50
+ --background-low: light-dark(var(--purple-50), var(--purple-950));
51
+ --background-low-emphasized: light-dark(var(--purple-600), var(--purple-400));
52
+ --separator-high: light-dark(var(--purple-400), var(--purple-600));
53
+ --separator-low: rgb(from var(--separator-high) r g b / var(--opacity-low));
54
+ --foreground-high: light-dark(var(--purple-800), var(--purple-200));
55
+ --foreground-low: light-dark(var(--purple-600), var(--purple-400));
56
+ --foreground-low-emphasized: light-dark(var(--purple-100), var(--purple-900));
57
+ }
58
+
59
+ .sui-tone-positive {
60
+ --background-high: light-dark(var(--green-100), var(--green-900));
61
+ --background-high-emphasized: light-dark(var(--green-800), var(--green-200));
62
+ --background-low: light-dark(var(--green-50), var(--green-950));
63
+ --background-low-emphasized: light-dark(var(--green-600), var(--green-400));
64
+ --separator-high: light-dark(var(--green-400), var(--green-600));
65
+ --separator-low: rgb(from var(--separator-high) r g b / var(--opacity-low));
66
+ --foreground-high: light-dark(var(--green-800), var(--green-200));
67
+ --foreground-low: light-dark(var(--green-600), var(--green-400));
68
+ --foreground-low-emphasized: light-dark(var(--green-100), var(--green-900));
69
+ }
70
+
71
+ .sui-tone-caution {
72
+ --background-high: light-dark(var(--yellow-100), var(--yellow-900));
73
+ --background-high-emphasized: light-dark(var(--yellow-800), var(--yellow-200));
74
+ --background-low: light-dark(var(--yellow-50), var(--yellow-950));
75
+ --background-low-emphasized: light-dark(var(--yellow-600), var(--yellow-400));
76
+ --separator-high: light-dark(var(--yellow-400), var(--yellow-600));
77
+ --separator-low: rgb(from var(--separator-high) r g b / var(--opacity-low));
78
+ --foreground-high: light-dark(var(--yellow-800), var(--yellow-200));
79
+ --foreground-low: light-dark(var(--yellow-600), var(--yellow-400));
80
+ --foreground-low-emphasized: light-dark(var(--yellow-100), var(--yellow-900));
81
+ }
82
+
83
+ .sui-tone-critical {
84
+ --background-high: light-dark(var(--red-100), var(--red-900));
85
+ --background-high-emphasized: light-dark(var(--red-800), var(--red-200));
86
+ --background-low: light-dark(var(--red-50), var(--red-950));
87
+ --background-low-emphasized: light-dark(var(--red-600), var(--red-400));
88
+ --separator-high: light-dark(var(--red-400), var(--red-600));
24
89
  --separator-low: rgb(from var(--separator-high) r g b / var(--opacity-low));
25
- --foreground-high: var(--tone-800);
26
- --foreground-high-emphasized: var(--tone-0);
27
- --foreground-low: var(--tone-600);
28
- --foreground-low-emphasized: var(--tone-100);
90
+ --foreground-high: light-dark(var(--red-800), var(--red-200));
91
+ --foreground-low: light-dark(var(--red-600), var(--red-400));
92
+ --foreground-low-emphasized: light-dark(var(--red-100), var(--red-900));
29
93
  }
@@ -8,14 +8,14 @@ import {type OverflowProps, overflowProps} from './overflow'
8
8
  import {type PaddingProps, paddingProps} from './padding'
9
9
  import {type PositionProps, positionProps} from './position'
10
10
  import {type ShadowProps, shadowProps} from './shadow'
11
- import {type ToneProps, toneProps} from './tone'
11
+ import {toneWithDefaultProps, type ToneWithDefaultProps} from './tone'
12
12
  import {type WidthProps, widthProps} from './width'
13
13
  import {type ZIndexProps, zIndexProps} from './zIndex'
14
14
 
15
15
  /** @public */
16
16
  export interface LayoutProps
17
17
  extends
18
- ToneProps,
18
+ ToneWithDefaultProps,
19
19
  WidthProps,
20
20
  HeightProps,
21
21
  MarginProps,
@@ -29,7 +29,7 @@ export interface LayoutProps
29
29
  ShadowProps {}
30
30
 
31
31
  export const layoutProps: Record<string, PropDef> = {
32
- ...toneProps,
32
+ ...toneWithDefaultProps,
33
33
  ...widthProps,
34
34
  ...heightProps,
35
35
  ...marginProps,
package/src/props/tone.ts CHANGED
@@ -1,8 +1,7 @@
1
1
  import {type PropDef} from '../types/PropDef'
2
- import {TONE, type Tone} from '../types/Tone'
2
+ import {TONE_WITH_DEFAULT, TONE, type ToneWithDefault, type Tone} from '../types/Tone'
3
3
 
4
4
  export type ToneProps = {
5
- /** CSS **background-color** property */
6
5
  tone?: Tone
7
6
  }
8
7
 
@@ -13,3 +12,15 @@ export const toneProps: Record<string, PropDef> = {
13
12
  values: TONE,
14
13
  },
15
14
  }
15
+
16
+ export type ToneWithDefaultProps = {
17
+ tone?: ToneWithDefault
18
+ }
19
+
20
+ export const toneWithDefaultProps: Record<string, PropDef> = {
21
+ tone: {
22
+ type: 'union',
23
+ className: 'tone',
24
+ values: TONE_WITH_DEFAULT,
25
+ },
26
+ }
package/src/types/Tone.ts CHANGED
@@ -1,3 +1,5 @@
1
1
  export const TONE = ['neutral', 'positive', 'suggest', 'caution', 'critical'] as const
2
+ export const TONE_WITH_DEFAULT = ['default', ...TONE]
2
3
  /** @public */
3
4
  export type Tone = (typeof TONE)[number]
5
+ export type ToneWithDefault = (typeof TONE_WITH_DEFAULT)[number]
package/src/version.ts CHANGED
@@ -1,3 +1,3 @@
1
1
  // This file is generated by scripts/write-version.js. Do not edit.
2
- export const VERSION = '500alpha16'
3
- export const HASH = 'd73bbc'
2
+ export const VERSION = '500alpha18'
3
+ export const HASH = '0fb084'
@@ -1,75 +0,0 @@
1
- [class*='sui-tone'] {
2
- /* All .sui-tone classes use white and black for tone-0/-1000 */
3
- --tone-0: light-dark(var(--white), var(--black));
4
- --tone-1000: light-dark(var(--black), var(--white));
5
- }
6
-
7
- .sui-tone-neutral {
8
- --tone-50: light-dark(var(--gray-50), var(--gray-950));
9
- --tone-100: light-dark(var(--gray-100), var(--gray-900));
10
- --tone-200: light-dark(var(--gray-200), var(--gray-800));
11
- --tone-300: light-dark(var(--gray-300), var(--gray-700));
12
- --tone-400: light-dark(var(--gray-400), var(--gray-600));
13
- --tone-500: light-dark(var(--gray-500), var(--gray-500));
14
- --tone-600: light-dark(var(--gray-600), var(--gray-400));
15
- --tone-700: light-dark(var(--gray-700), var(--gray-300));
16
- --tone-800: light-dark(var(--gray-800), var(--gray-200));
17
- --tone-900: light-dark(var(--gray-900), var(--gray-100));
18
- --tone-950: light-dark(var(--gray-950), var(--gray-50));
19
- }
20
-
21
- .sui-tone-suggest {
22
- --tone-50: light-dark(var(--purple-50), var(--purple-950));
23
- --tone-100: light-dark(var(--purple-100), var(--purple-900));
24
- --tone-200: light-dark(var(--purple-200), var(--purple-800));
25
- --tone-300: light-dark(var(--purple-300), var(--purple-700));
26
- --tone-400: light-dark(var(--purple-400), var(--purple-600));
27
- --tone-500: light-dark(var(--purple-500), var(--purple-500));
28
- --tone-600: light-dark(var(--purple-600), var(--purple-400));
29
- --tone-700: light-dark(var(--purple-700), var(--purple-300));
30
- --tone-800: light-dark(var(--purple-800), var(--purple-200));
31
- --tone-900: light-dark(var(--purple-900), var(--purple-100));
32
- --tone-950: light-dark(var(--purple-950), var(--purple-50));
33
- }
34
-
35
- .sui-tone-positive {
36
- --tone-50: light-dark(var(--green-50), var(--green-950));
37
- --tone-100: light-dark(var(--green-100), var(--green-900));
38
- --tone-200: light-dark(var(--green-200), var(--green-800));
39
- --tone-300: light-dark(var(--green-300), var(--green-700));
40
- --tone-400: light-dark(var(--green-400), var(--green-600));
41
- --tone-500: light-dark(var(--green-500), var(--green-500));
42
- --tone-600: light-dark(var(--green-600), var(--green-400));
43
- --tone-700: light-dark(var(--green-700), var(--green-300));
44
- --tone-800: light-dark(var(--green-800), var(--green-200));
45
- --tone-900: light-dark(var(--green-900), var(--green-100));
46
- --tone-950: light-dark(var(--green-950), var(--green-50));
47
- }
48
-
49
- .sui-tone-caution {
50
- --tone-50: light-dark(var(--yellow-50), var(--yellow-950));
51
- --tone-100: light-dark(var(--yellow-100), var(--yellow-900));
52
- --tone-200: light-dark(var(--yellow-200), var(--yellow-800));
53
- --tone-300: light-dark(var(--yellow-300), var(--yellow-700));
54
- --tone-400: light-dark(var(--yellow-400), var(--yellow-600));
55
- --tone-500: light-dark(var(--yellow-500), var(--yellow-500));
56
- --tone-600: light-dark(var(--yellow-600), var(--yellow-400));
57
- --tone-700: light-dark(var(--yellow-700), var(--yellow-300));
58
- --tone-800: light-dark(var(--yellow-800), var(--yellow-200));
59
- --tone-900: light-dark(var(--yellow-900), var(--yellow-100));
60
- --tone-950: light-dark(var(--yellow-950), var(--yellow-50));
61
- }
62
-
63
- .sui-tone-critical {
64
- --tone-50: light-dark(var(--red-50), var(--red-950));
65
- --tone-100: light-dark(var(--red-100), var(--red-900));
66
- --tone-200: light-dark(var(--red-200), var(--red-800));
67
- --tone-300: light-dark(var(--red-300), var(--red-700));
68
- --tone-400: light-dark(var(--red-400), var(--red-600));
69
- --tone-500: light-dark(var(--red-500), var(--red-500));
70
- --tone-600: light-dark(var(--red-600), var(--red-400));
71
- --tone-700: light-dark(var(--red-700), var(--red-300));
72
- --tone-800: light-dark(var(--red-800), var(--red-200));
73
- --tone-900: light-dark(var(--red-900), var(--red-100));
74
- --tone-950: light-dark(var(--red-950), var(--red-50));
75
- }