@sanity-labs/ui-poc 0.0.1-alpha.0 → 0.0.1-alpha.10

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.
Files changed (98) hide show
  1. package/dist/components.css +32 -3
  2. package/dist/index.d.ts +217 -10
  3. package/dist/index.js +354 -28
  4. package/dist/index.js.map +1 -1
  5. package/dist/styles.css +1894 -1007
  6. package/dist/utilities.css +1995 -368
  7. package/package.json +10 -22
  8. package/src/components/box/Box.tsx +5 -15
  9. package/src/components/box/box.css +5 -0
  10. package/src/components/box/box.props.ts +11 -2
  11. package/src/components/card/Card.tsx +26 -0
  12. package/src/components/card/card.css +7 -0
  13. package/src/components/card/card.props.ts +45 -0
  14. package/src/components/divider/Divider.tsx +18 -0
  15. package/src/components/divider/divider.props.tsx +9 -0
  16. package/src/components/flex/Flex.tsx +6 -17
  17. package/src/components/flex/flex.css +5 -0
  18. package/src/components/flex/flex.props.ts +14 -4
  19. package/src/components/grid/Grid.tsx +6 -17
  20. package/src/components/grid/grid.css +5 -0
  21. package/src/components/grid/grid.props.ts +14 -4
  22. package/src/components/heading/Heading.tsx +39 -0
  23. package/src/components/heading/heading.css +9 -0
  24. package/src/components/heading/heading.props.ts +24 -0
  25. package/src/components/index.css +6 -0
  26. package/src/components/text/Text.tsx +3 -13
  27. package/src/components/text/text.css +9 -0
  28. package/src/components/text/text.props.ts +12 -2
  29. package/src/css/classes/dynamic/readme.md +3 -0
  30. package/src/css/{utilities → classes}/generic/display.css +0 -3
  31. package/src/css/{utilities → classes}/generic/flex.css +7 -7
  32. package/src/css/classes/generic/grid.css +7 -0
  33. package/src/css/{utilities → classes}/generic/index.css +0 -4
  34. package/src/css/classes/generic/readme.md +3 -0
  35. package/src/css/classes/index.css +4 -0
  36. package/src/css/classes/local/border.css +16 -0
  37. package/src/css/classes/local/index.css +3 -0
  38. package/src/css/classes/local/readme.md +3 -0
  39. package/src/css/classes/local/text-trim.css +39 -0
  40. package/src/css/classes/local/tone.css +48 -0
  41. package/src/css/{utilities/tokenized → classes/system}/index.css +1 -0
  42. package/src/css/classes/system/radius.css +10 -0
  43. package/src/css/classes/system/readme.md +3 -0
  44. package/src/css/global/font-face.css +20 -0
  45. package/src/css/global/index.css +2 -0
  46. package/src/css/global/reset.css +70 -0
  47. package/src/css/index.css +3 -4
  48. package/src/css/tokens/border.css +3 -0
  49. package/src/css/tokens/index.css +2 -0
  50. package/src/css/tokens/tone.css +30 -0
  51. package/src/index.ts +7 -1
  52. package/src/props/layout.ts +7 -1
  53. package/src/props/position.ts +0 -7
  54. package/src/props/shadow.ts +15 -0
  55. package/src/props/tone.ts +1 -2
  56. package/src/props/typography.ts +3 -1
  57. package/src/props/zIndex.ts +15 -0
  58. package/src/types/Density.ts +2 -0
  59. package/src/types/FontWeight.ts +1 -1
  60. package/src/types/Heading.ts +5 -0
  61. package/src/types/Overflow.ts +1 -1
  62. package/src/types/Position.ts +1 -1
  63. package/src/types/PropDef.ts +25 -4
  64. package/src/types/Radius.ts +1 -1
  65. package/src/types/Shadow.ts +2 -0
  66. package/src/types/Text.ts +1 -1
  67. package/src/types/TextAlign.ts +1 -1
  68. package/src/types/Tone.ts +9 -1
  69. package/src/utils/getProps.test.ts +22 -9
  70. package/src/utils/getProps.ts +74 -25
  71. package/src/css/global.css +0 -103
  72. package/src/css/utilities/generic/border.css +0 -11
  73. package/src/css/utilities/generic/grid.css +0 -7
  74. package/src/css/utilities/generic/text-muted.css +0 -2
  75. package/src/css/utilities/generic/text-trim.css +0 -38
  76. package/src/css/utilities/generic/tone.css +0 -34
  77. package/src/css/utilities/tokenized/radius.css +0 -8
  78. /package/src/css/{utilities → classes}/dynamic/flex-child.css +0 -0
  79. /package/src/css/{utilities → classes}/dynamic/grid-child.css +0 -0
  80. /package/src/css/{utilities → classes}/dynamic/grid-parent.css +0 -0
  81. /package/src/css/{utilities → classes}/dynamic/height.css +0 -0
  82. /package/src/css/{utilities → classes}/dynamic/index.css +0 -0
  83. /package/src/css/{utilities → classes}/dynamic/line-clamp.css +0 -0
  84. /package/src/css/{utilities → classes}/dynamic/width.css +0 -0
  85. /package/src/css/{utilities → classes}/dynamic/z-index.css +0 -0
  86. /package/src/css/{utilities → classes}/generic/overflow.css +0 -0
  87. /package/src/css/{utilities → classes}/generic/position.css +0 -0
  88. /package/src/css/{utilities → classes}/generic/text-align.css +0 -0
  89. /package/src/css/{utilities/tokenized → classes/system}/color.css +0 -0
  90. /package/src/css/{utilities/tokenized → classes/system}/container.css +0 -0
  91. /package/src/css/{utilities/tokenized → classes/system}/fontFamily.css +0 -0
  92. /package/src/css/{utilities/tokenized → classes/system}/fontWeight.css +0 -0
  93. /package/src/css/{utilities/tokenized → classes/system}/gap.css +0 -0
  94. /package/src/css/{utilities/tokenized → classes/system}/inset.css +0 -0
  95. /package/src/css/{utilities/tokenized → classes/system}/margin.css +0 -0
  96. /package/src/css/{utilities/tokenized → classes/system}/padding.css +0 -0
  97. /package/src/css/{utilities/tokenized → classes/system}/shadow.css +0 -0
  98. /package/src/css/{utilities/tokenized → classes/system}/typography.css +0 -0
@@ -1,9 +1,38 @@
1
1
  .sui-Box {
2
- display: block;
2
+ /* Box has no tone by default, therefore we set --tone-surface as transparent */
3
+ --tone-surface: transparent;
4
+ background-color: var(--tone-surface);
5
+ }
6
+ .sui-Card {
7
+ /* Card is always used with tone, therefore we can apply background and border colors
8
+ * by default without setting fallback custom properties.
9
+ * Note that border width/style is applied by .sui-border, used by default on Card */
10
+ background-color: var(--tone-surface);
11
+ border-color: var(--tone-separator);
3
12
  }
4
13
  .sui-Flex {
5
- display: flex;
14
+ /* Flex has no tone by default, therefore we set --tone-surface as transparent */
15
+ --tone-surface: transparent;
16
+ background-color: var(--tone-surface);
6
17
  }
7
18
  .sui-Grid {
8
- display: grid;
19
+ /* Grid has no tone by default, therefore we set --tone-surface as transparent */
20
+ --tone-surface: transparent;
21
+ background-color: var(--tone-surface);
22
+ }
23
+ .sui-Heading {
24
+ --tone-text-default: light-dark(var(--gray-800), var(--gray-200));
25
+ color: var(--tone-text, var(--tone-text-default));
26
+ }
27
+ .sui-Heading:where(.sui-text-muted) {
28
+ --tone-text-muted-default: light-dark(var(--gray-600), var(--gray-400));
29
+ color: var(--tone-text-muted, var(--tone-text-muted-default));
30
+ }
31
+ .sui-Text {
32
+ --tone-text-default: light-dark(var(--gray-800), var(--gray-200));
33
+ color: var(--tone-text, var(--tone-text-default));
34
+ }
35
+ .sui-Text:where(.sui-text-muted) {
36
+ --tone-text-muted-default: light-dark(var(--gray-600), var(--gray-400));
37
+ color: var(--tone-text-muted, var(--tone-text-muted-default));
9
38
  }
package/dist/index.d.ts CHANGED
@@ -1,6 +1,10 @@
1
1
  import {JSX} from 'react/jsx-runtime'
2
2
  import {default as React_2} from 'react'
3
3
 
4
+ declare const ALIGN_ITEMS: readonly ['baseline', 'center', 'flex-end', 'flex-start', 'stretch']
5
+
6
+ declare type AlignItems = (typeof ALIGN_ITEMS)[number]
7
+
4
8
  declare type BorderProps = {
5
9
  /** CSS **border** property */
6
10
  border?: Responsive<boolean>
@@ -17,22 +21,66 @@ declare type BorderProps = {
17
21
  }
18
22
 
19
23
  /** @public */
20
- export declare function Box<T extends React_2.ElementType = 'div'>(
21
- props: BoxProps<T> & Omit<React_2.ComponentPropsWithRef<T>, keyof BoxProps<T>>,
22
- ): JSX.Element
24
+ export declare function Box<T extends React_2.ElementType = 'div'>({
25
+ display,
26
+ ...props
27
+ }: BoxProps<T> & Omit<React_2.ComponentPropsWithRef<T>, keyof BoxProps<T>>): JSX.Element
23
28
 
24
29
  /** @public */
25
- export declare interface BoxProps<T extends React_2.ElementType> extends LayoutProps {
30
+ declare interface BoxProps<T extends React.ElementType> extends LayoutProps {
26
31
  /** Element to render */
27
32
  as?: T
28
33
  /** CSS **display** property */
29
34
  display?: Responsive<DisplayBlock>
30
35
  }
31
36
 
37
+ /** @public */
38
+ export declare function Card<T extends React_2.ElementType = 'div'>({
39
+ density,
40
+ tone,
41
+ ...props
42
+ }: CardProps<T> & Omit<React_2.ComponentPropsWithRef<T>, keyof CardProps<T>>): JSX.Element
43
+
44
+ /** @public */
45
+ declare interface CardProps<T extends React.ElementType> extends MarginProps, ToneProps {
46
+ /** Element to render */
47
+ as?: T
48
+ /** Composite prop for setting padding and border radius */
49
+ density?: Responsive<Density>
50
+ }
51
+
52
+ declare const DENSITY: readonly ['compact', 'regular', 'loose']
53
+
54
+ declare type Density = (typeof DENSITY)[number]
55
+
32
56
  declare const DISPLAY_BLOCK: readonly ['block', 'inline-block', 'none']
33
57
 
58
+ declare const DISPLAY_FLEX: readonly ['flex', 'inline-flex', 'none']
59
+
60
+ declare const DISPLAY_GRID: readonly ['grid', 'inline-grid', 'none']
61
+
34
62
  declare type DisplayBlock = (typeof DISPLAY_BLOCK)[number]
35
63
 
64
+ declare type DisplayFlex = (typeof DISPLAY_FLEX)[number]
65
+
66
+ declare type DisplayGrid = (typeof DISPLAY_GRID)[number]
67
+
68
+ /** @public */
69
+ export declare function Divider(props: DividerProps): JSX.Element
70
+
71
+ /** @public */
72
+ declare interface DividerProps extends React.ComponentProps<'hr'>, MarginProps {}
73
+
74
+ /** @public */
75
+ export declare function Flex<T extends React_2.ElementType = 'div'>({
76
+ display,
77
+ ...props
78
+ }: FlexProps<T> & Omit<React_2.ComponentPropsWithRef<T>, keyof FlexProps<T>>): JSX.Element
79
+
80
+ declare const FLEX_DIRECTION: readonly ['row', 'row-reverse', 'column', 'column-reverse']
81
+
82
+ declare const FLEX_WRAP: readonly ['wrap', 'wrap-reverse', 'nowrap']
83
+
36
84
  declare type FlexChildProps = {
37
85
  /** CSS **flex-basis** property */
38
86
  flexBasis?: Responsive<string>
@@ -42,6 +90,53 @@ declare type FlexChildProps = {
42
90
  flexShrink?: Responsive<number>
43
91
  }
44
92
 
93
+ declare type FlexDirection = (typeof FLEX_DIRECTION)[number]
94
+
95
+ declare type FlexParentProps = {
96
+ /** CSS **align-items** property */
97
+ alignItems?: Responsive<AlignItems>
98
+ /** CSS **justify-content** property */
99
+ justifyContent?: Responsive<JustifyContent>
100
+ /** CSS **flex-direction** property */
101
+ flexDirection?: Responsive<FlexDirection>
102
+ /** CSS **flex-wrap** property */
103
+ flexWrap?: Responsive<FlexWrap>
104
+ }
105
+
106
+ /** @public */
107
+ declare interface FlexProps<T extends React.ElementType>
108
+ extends FlexParentProps, GapProps, LayoutProps {
109
+ /** Element to render */
110
+ as?: T
111
+ /** CSS **display** property */
112
+ display?: Responsive<DisplayFlex>
113
+ }
114
+
115
+ declare type FlexWrap = (typeof FLEX_WRAP)[number]
116
+
117
+ declare const FONT_WEIGHT: readonly ['regular', 'medium', 'semibold', 'bold']
118
+
119
+ declare type FontWeight = (typeof FONT_WEIGHT)[number]
120
+
121
+ declare type GapProps = {
122
+ /** CSS **gap** property */
123
+ gap?: Responsive<Space>
124
+ /** CSS **row-gap** property */
125
+ rowGap?: Responsive<Space>
126
+ /** CSS **column-gap** property */
127
+ columnGap?: Responsive<Space>
128
+ }
129
+
130
+ /** @public */
131
+ export declare function Grid<T extends React_2.ElementType = 'div'>({
132
+ display,
133
+ ...props
134
+ }: GridProps<T> & Omit<React_2.ComponentPropsWithRef<T>, keyof GridProps<T>>): JSX.Element
135
+
136
+ declare const GRID_AUTO_FLOW: readonly ['row', 'column', 'row dense', 'column dense', 'dense']
137
+
138
+ declare type GridAutoFlow = (typeof GRID_AUTO_FLOW)[number]
139
+
45
140
  declare type GridChildProps = {
46
141
  /** CSS **grid-column** property */
47
142
  gridColumn?: Responsive<string>
@@ -57,6 +152,51 @@ declare type GridChildProps = {
57
152
  gridRowEnd?: Responsive<string>
58
153
  }
59
154
 
155
+ declare type GridParentProps = {
156
+ /** CSS **grid-auto-flow** property */
157
+ gridAutoFlow?: Responsive<GridAutoFlow>
158
+ /** CSS **grid-auto-columns** property */
159
+ gridAutoColumns?: Responsive<string>
160
+ /** CSS **grid-auto-row** property */
161
+ gridAutoRows?: Responsive<string>
162
+ /** CSS **grid-template-columns** property */
163
+ gridTemplateColumns?: Responsive<string>
164
+ /** CSS **grid-template-rows** property */
165
+ gridTemplateRows?: Responsive<string>
166
+ }
167
+
168
+ /** @public */
169
+ declare interface GridProps<T extends React.ElementType>
170
+ extends GridParentProps, GapProps, LayoutProps {
171
+ /** Element to render */
172
+ as?: T
173
+ /** CSS **display** property */
174
+ display?: Responsive<DisplayGrid>
175
+ }
176
+
177
+ /** @public */
178
+ export declare function Heading<T extends React_2.ElementType = 'h2'>({
179
+ size,
180
+ weight,
181
+ ...props
182
+ }: HeadingProps & Omit<React_2.ComponentPropsWithRef<T>, keyof HeadingProps>): JSX.Element
183
+
184
+ declare const HEADING_SIZE: readonly [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
185
+
186
+ declare const HEADING_TAG: readonly ['h1', 'h2', 'h3', 'h4', 'h5', 'h6']
187
+
188
+ /** @public */
189
+ declare interface HeadingProps extends TypographyProps {
190
+ /** Element to render */
191
+ as?: HeadingTag
192
+ /** CSS **font-size** property */
193
+ size?: HeadingSize
194
+ }
195
+
196
+ declare type HeadingSize = (typeof HEADING_SIZE)[number]
197
+
198
+ declare type HeadingTag = (typeof HEADING_TAG)[number]
199
+
60
200
  declare type HeightProps = {
61
201
  /** CSS **height** property */
62
202
  height?: Responsive<string>
@@ -66,6 +206,17 @@ declare type HeightProps = {
66
206
  maxHeight?: Responsive<string>
67
207
  }
68
208
 
209
+ declare const JUSTIFY_CONTENT: readonly [
210
+ 'flex-start',
211
+ 'flex-end',
212
+ 'center',
213
+ 'space-between',
214
+ 'space-around',
215
+ 'space-evenly',
216
+ ]
217
+
218
+ declare type JustifyContent = (typeof JUSTIFY_CONTENT)[number]
219
+
69
220
  declare interface LayoutProps
70
221
  extends
71
222
  ToneProps,
@@ -77,7 +228,9 @@ declare interface LayoutProps
77
228
  PositionProps,
78
229
  OverflowProps,
79
230
  FlexChildProps,
80
- GridChildProps {}
231
+ GridChildProps,
232
+ ZIndexProps,
233
+ ShadowProps {}
81
234
 
82
235
  declare type MarginProps = {
83
236
  /** CSS **margin** property */
@@ -96,7 +249,7 @@ declare type MarginProps = {
96
249
  marginLeft?: Responsive<SpaceAuto>
97
250
  }
98
251
 
99
- declare const OVERFLOW: string[]
252
+ declare const OVERFLOW: readonly ['visible', 'hidden', 'auto', 'scroll', 'clip']
100
253
 
101
254
  declare type Overflow = (typeof OVERFLOW)[number]
102
255
 
@@ -126,7 +279,7 @@ declare interface PaddingProps {
126
279
  paddingLeft?: Responsive<Space>
127
280
  }
128
281
 
129
- declare const POSITION: string[]
282
+ declare const POSITION: readonly ['absolute', 'fixed', 'relative', 'static', 'sticky']
130
283
 
131
284
  declare type Position = (typeof POSITION)[number]
132
285
 
@@ -145,7 +298,7 @@ declare type PositionProps = {
145
298
  left?: Responsive<SpaceAuto>
146
299
  }
147
300
 
148
- declare const RADIUS: (string | number)[]
301
+ declare const RADIUS: readonly [0, 1, 2, 3, 4, 5, 6, 'full']
149
302
 
150
303
  declare type Radius = (typeof RADIUS)[number]
151
304
 
@@ -174,6 +327,11 @@ declare type Responsive<T> =
174
327
  length: 7
175
328
  })
176
329
 
330
+ declare type ShadowProps = {
331
+ /** CSS **box-shadow** property */
332
+ shadow?: string
333
+ }
334
+
177
335
  declare const SPACE: readonly [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
178
336
 
179
337
  declare type Space = (typeof SPACE)[number]
@@ -182,13 +340,57 @@ declare const SPACE_AUTO: readonly [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 'auto']
182
340
 
183
341
  declare type SpaceAuto = (typeof SPACE_AUTO)[number]
184
342
 
185
- declare const TONE: string[]
343
+ /** @public */
344
+ declare function Text_2<T extends React_2.ElementType = 'span'>({
345
+ size,
346
+ ...props
347
+ }: TextProps<T> & Omit<React_2.ComponentPropsWithRef<T>, keyof TextProps<T>>): JSX.Element
348
+ export {Text_2 as Text}
349
+
350
+ declare const TEXT_ALIGN: readonly ['left', 'center', 'right', 'justify']
351
+
352
+ declare const TEXT_SIZE: readonly [0, 1, 2, 3, 4]
353
+
354
+ declare type TextAlign = (typeof TEXT_ALIGN)[number]
355
+
356
+ /** @public */
357
+ declare interface TextProps<T extends React.ElementType> extends TypographyProps {
358
+ /** Element to render */
359
+ as?: T
360
+ /** CSS **font-size** property */
361
+ size?: TextSize
362
+ }
363
+
364
+ declare type TextSize = (typeof TEXT_SIZE)[number]
365
+
366
+ declare const TONE: readonly [
367
+ 'none',
368
+ 'neutral',
369
+ 'primary',
370
+ 'positive',
371
+ 'suggest',
372
+ 'caution',
373
+ 'critical',
374
+ ]
186
375
 
187
376
  declare type Tone = (typeof TONE)[number]
188
377
 
189
378
  declare type ToneProps = {
190
379
  /** CSS **background-color** property */
191
- tone?: Responsive<Tone>
380
+ tone?: Tone
381
+ }
382
+
383
+ declare interface TypographyProps extends MarginProps, ToneProps {
384
+ /** CSS **text-align** property */
385
+ align?: TextAlign
386
+ /** CSS **-webkit-line-clamp** property */
387
+ lineClamp?: number
388
+ /** CSS **color** property */
389
+ muted?: boolean
390
+ /** CSS **text-box-trim** property */
391
+ trim?: boolean
392
+ /** CSS **font-weight** property */
393
+ weight?: FontWeight
192
394
  }
193
395
 
194
396
  declare type WidthProps = {
@@ -200,4 +402,9 @@ declare type WidthProps = {
200
402
  maxWidth?: Responsive<string>
201
403
  }
202
404
 
405
+ declare type ZIndexProps = {
406
+ /** CSS z-index property */
407
+ zIndex?: Responsive<number>
408
+ }
409
+
203
410
  export {}