@sanity-labs/ui-poc 0.0.1-alpha.9 → 0.0.1-versioned.0
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/README.md +151 -0
- package/dist/_chunks-es/LazyRefractor.js +9 -0
- package/dist/_chunks-es/LazyRefractor.js.map +1 -0
- package/dist/index.d.ts +464 -42
- package/dist/index.js +1202 -170
- package/dist/index.js.map +1 -1
- package/dist/styles.css +1 -8931
- package/package.json +21 -11
- package/src/components/box/Box.tsx +10 -4
- package/src/components/box/box.css +3 -4
- package/src/components/button/Button.tsx +63 -0
- package/src/components/button/button.css +82 -0
- package/src/components/button/button.props.ts +104 -0
- package/src/components/card/Card.tsx +6 -5
- package/src/components/card/card.css +2 -5
- package/src/components/card/card.props.ts +9 -8
- package/src/components/checkbox/Checkbox.tsx +57 -0
- package/src/components/checkbox/checkbox.css +100 -0
- package/src/components/checkbox/checkbox.props.ts +25 -0
- package/src/components/code/Code.tsx +44 -0
- package/src/components/code/LazyRefractor.tsx +9 -0
- package/src/components/code/code.css +40 -0
- package/src/components/code/code.props.ts +37 -0
- package/src/components/container/Container.tsx +26 -0
- package/src/components/container/container.css +4 -0
- package/src/components/container/container.props.ts +24 -0
- package/src/components/divider/Divider.tsx +6 -1
- package/src/components/flex/Flex.tsx +10 -4
- package/src/components/flex/flex.css +3 -4
- package/src/components/grid/Grid.tsx +10 -4
- package/src/components/grid/grid.css +3 -4
- package/src/components/h-stack/HStack.tsx +30 -0
- package/src/components/h-stack/hStack.props.ts +15 -0
- package/src/components/heading/Heading.tsx +9 -5
- package/src/components/heading/heading.css +4 -4
- package/src/components/heading/heading.props.ts +2 -1
- package/src/components/icon/Icon.tsx +20 -0
- package/src/components/icon/icon.css +17 -0
- package/src/components/icon/icon.props.ts +31 -0
- package/src/components/icon-button/IconButton.tsx +28 -0
- package/src/components/icon-button/iconButton.props.ts +26 -0
- package/src/components/index.css +18 -0
- package/src/components/indicator/Indicator.tsx +38 -0
- package/src/components/indicator/indicator.css +4 -0
- package/src/components/indicator/indicator.props.ts +20 -0
- package/src/components/indicator-stack/IndicatorStack.tsx +27 -0
- package/src/components/indicator-stack/indicator-stack.css +7 -0
- package/src/components/indicator-stack/indicatorStack.props.ts +13 -0
- package/src/components/inline/Inline.tsx +36 -0
- package/src/components/inline/inline.css +4 -0
- package/src/components/inline/inline.props.ts +96 -0
- package/src/components/label/Label.tsx +30 -0
- package/src/components/label/label.css +3 -0
- package/src/components/label/label.props.ts +19 -0
- package/src/components/link/Link.tsx +25 -0
- package/src/components/link/link.css +12 -0
- package/src/components/link/link.props.ts +23 -0
- package/src/components/list/List.tsx +112 -0
- package/src/components/list/list.css +10 -0
- package/src/components/list/list.props.ts +78 -0
- package/src/components/press-area/PressArea.tsx +25 -0
- package/src/components/press-area/press-area.css +17 -0
- package/src/components/press-area/pressArea.props.ts +14 -0
- package/src/components/radio/Radio.tsx +42 -0
- package/src/components/radio/radio.css +97 -0
- package/src/components/radio/radio.props.ts +20 -0
- package/src/components/skip-to-content/SkipToContent.tsx +32 -0
- package/src/components/skip-to-content/skip-to-content.css +9 -0
- package/src/components/skip-to-content/skipToContent.props.ts +24 -0
- package/src/components/spinner/Spinner.tsx +24 -0
- package/src/components/spinner/spinner.css +10 -0
- package/src/components/spinner/spinner.props.ts +16 -0
- package/src/components/switch/Switch.tsx +42 -0
- package/src/components/switch/switch.css +119 -0
- package/src/components/switch/switch.props.ts +20 -0
- package/src/components/text/Text.tsx +14 -5
- package/src/components/text/text.css +4 -4
- package/src/components/text/text.props.ts +3 -4
- package/src/components/tooltip/Tooltip.tsx +92 -0
- package/src/components/tooltip/tooltip.css +52 -0
- package/src/components/tooltip/tooltip.props.ts +20 -0
- package/src/components/tooltip-group/TooltipGroup.tsx +63 -0
- package/src/components/tooltip-group/tooltipGroup.props.ts +13 -0
- package/src/components/v-stack/VStack.tsx +28 -0
- package/src/components/v-stack/vStack.props.ts +15 -0
- package/src/components/visually-hidden/VisuallyHidden.tsx +25 -0
- package/src/components/visually-hidden/visually-hidden.css +9 -0
- package/src/components/visually-hidden/visuallyHidden.props.ts +19 -0
- package/src/css/classes/dynamic/width.css +2 -0
- package/src/css/classes/generic/index.css +1 -0
- package/src/css/classes/generic/placement.css +171 -0
- package/src/css/classes/local/border.css +14 -10
- package/src/css/classes/local/text-trim.css +6 -0
- package/src/css/classes/local/tone.css +60 -33
- package/src/css/classes/system/container.css +6 -6
- package/src/css/classes/system/gap.css +3 -0
- package/src/css/classes/system/margin.css +85 -29
- package/src/css/classes/system/padding.css +0 -7
- package/src/css/classes/system/radius.css +1 -1
- package/src/css/global/reset.css +6 -2
- package/src/css/tokens/index.css +3 -2
- package/src/css/tokens/opacity.css +6 -0
- package/src/css/tokens/semantic.css +21 -0
- package/src/css/tokens/surface.css +27 -0
- package/src/index.css +10 -2
- package/src/index.ts +22 -0
- package/src/props/border.ts +5 -5
- package/src/props/flexParent.ts +1 -1
- package/src/props/gap.ts +7 -7
- package/src/props/layout.ts +3 -0
- package/src/props/margin.ts +15 -15
- package/src/props/placement.ts +15 -0
- package/src/props/position.ts +0 -7
- package/src/props/shadow.ts +2 -2
- package/src/props/typography.ts +2 -2
- package/src/props/zIndex.ts +15 -0
- package/src/types/Button.ts +8 -0
- package/src/types/Code.ts +5 -0
- package/src/types/Container.ts +2 -0
- package/src/types/Icon.ts +2 -0
- package/src/types/Interactive.ts +8 -0
- package/src/types/List.ts +2 -0
- package/src/types/Placement.ts +15 -0
- package/src/types/PropDef.ts +22 -5
- package/src/types/Responsive.ts +0 -1
- package/src/types/Space.ts +6 -0
- package/src/types/Tone.ts +1 -9
- package/src/utils/getProps.test.ts +5 -3
- package/src/utils/getProps.ts +8 -2
- package/src/utils/getVersionedClassname.ts +5 -0
- package/dist/components.css +0 -38
- package/dist/utilities.css +0 -9659
- package/src/css/tokens/border.css +0 -3
- package/src/css/tokens/tone.css +0 -30
- package/src/styles.css +0 -8931
package/README.md
ADDED
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
# Sanity UI 4
|
|
2
|
+
|
|
3
|
+
The next version of Sanity's component library. Faster, simpler, and built on CSS instead of styled-components.
|
|
4
|
+
|
|
5
|
+
## What's different from v3
|
|
6
|
+
|
|
7
|
+
- **CSS classes instead of styled-components.** No runtime style generation. Smaller bundles, faster renders.
|
|
8
|
+
- **Direct props for layout.** Width, height, position, border, and overflow are first-class props — no more `style={{ ... }}` escape hatches.
|
|
9
|
+
- **Works alongside v3.** Install both packages in the same app. No forced migration.
|
|
10
|
+
|
|
11
|
+
## Install
|
|
12
|
+
|
|
13
|
+
```sh
|
|
14
|
+
pnpm add @sanity-labs/ui-poc
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
Requires React 19.2+ and Node >=20.19 <22 || >=22.12.
|
|
18
|
+
|
|
19
|
+
## Setup
|
|
20
|
+
|
|
21
|
+
Import the stylesheet at your app entry point. Without it, components render as unstyled HTML with no error.
|
|
22
|
+
|
|
23
|
+
```tsx
|
|
24
|
+
import '@sanity-labs/ui-poc/styles.css'
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
If your app uses Sanity UI v3, keep the existing `ThemeProvider` setup.
|
|
28
|
+
|
|
29
|
+
```tsx
|
|
30
|
+
import {ThemeProvider, studioTheme, ToastProvider} from '@sanity/ui'
|
|
31
|
+
import '@sanity-labs/ui-poc/styles.css'
|
|
32
|
+
import App from './App'
|
|
33
|
+
|
|
34
|
+
createRoot(document.getElementById('root')!).render(
|
|
35
|
+
<ThemeProvider theme={studioTheme}>
|
|
36
|
+
<ToastProvider>
|
|
37
|
+
<App />
|
|
38
|
+
</ToastProvider>
|
|
39
|
+
</ThemeProvider>,
|
|
40
|
+
)
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## Usage
|
|
44
|
+
|
|
45
|
+
Import from `@sanity-labs/ui-poc`. Components not yet in v4 — Menu, Dialog, TextInput, Badge — remain in `@sanity/ui`.
|
|
46
|
+
|
|
47
|
+
```tsx
|
|
48
|
+
import {Box, Flex, Card, Heading, Text, Button} from '@sanity-labs/ui-poc'
|
|
49
|
+
import {AddIcon} from '@sanity/icons'
|
|
50
|
+
|
|
51
|
+
export default function App() {
|
|
52
|
+
return (
|
|
53
|
+
<Flex minHeight="100vh">
|
|
54
|
+
<Box as="nav" aria-label="Main" padding={3} borderRight width="240px">
|
|
55
|
+
<Heading as="h2" size={1}>
|
|
56
|
+
My App
|
|
57
|
+
</Heading>
|
|
58
|
+
</Box>
|
|
59
|
+
<Box as="main" padding={4} flexGrow={1}>
|
|
60
|
+
<Flex alignItems="center" justifyContent="space-between" flexWrap="wrap" gap={2}>
|
|
61
|
+
<Heading as="h1" size={2}>
|
|
62
|
+
Documents
|
|
63
|
+
</Heading>
|
|
64
|
+
<Button iconStart={AddIcon} text="New" />
|
|
65
|
+
</Flex>
|
|
66
|
+
<Box marginTop={3}>
|
|
67
|
+
<Card density="loose">
|
|
68
|
+
<Text size={1}>First document</Text>
|
|
69
|
+
<Text size={1} muted>
|
|
70
|
+
Edited 2 hours ago
|
|
71
|
+
</Text>
|
|
72
|
+
</Card>
|
|
73
|
+
</Box>
|
|
74
|
+
</Box>
|
|
75
|
+
</Flex>
|
|
76
|
+
)
|
|
77
|
+
}
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
## Components
|
|
81
|
+
|
|
82
|
+
All components below are from `@sanity-labs/ui-poc`.
|
|
83
|
+
|
|
84
|
+
### Layout
|
|
85
|
+
|
|
86
|
+
| Component | What it does |
|
|
87
|
+
| ----------- | ----------------------------------------------------------------------------------- |
|
|
88
|
+
| `Box` | General container. Padding, margin, border, overflow, and position as direct props. |
|
|
89
|
+
| `Flex` | Flexbox layout. `alignItems`, `justifyContent`, `flexDirection`, `gap`. |
|
|
90
|
+
| `Grid` | CSS grid. Use `gridTemplateColumns` with a CSS string (e.g. `"repeat(3, 1fr)"`). |
|
|
91
|
+
| `Container` | Max-width content wrapper. |
|
|
92
|
+
| `HStack` | Horizontal stack. Accepts `gap` and `as` only — use `Flex` for alignment control. |
|
|
93
|
+
| `VStack` | Vertical stack. Accepts `gap` and `as` only — use `Flex` for alignment control. |
|
|
94
|
+
| `Inline` | Inline flow layout with wrapping and gap. |
|
|
95
|
+
|
|
96
|
+
### Typography
|
|
97
|
+
|
|
98
|
+
| Component | What it does |
|
|
99
|
+
| --------- | ----------------------------------------------------------------------- |
|
|
100
|
+
| `Heading` | Semantic headings (`h1`–`h6`). Always set `as` to match the level. |
|
|
101
|
+
| `Text` | Body copy, captions, labels. Props: `size`, `weight`, `muted`, `align`. |
|
|
102
|
+
| `Label` | Form input label. Use only with form elements. |
|
|
103
|
+
| `Code` | Inline or block code. Uses the system monospace font. |
|
|
104
|
+
|
|
105
|
+
### Interactive
|
|
106
|
+
|
|
107
|
+
| Component | What it does |
|
|
108
|
+
| ---------- | ------------------------------------------------------------------------------------------------------------------------ |
|
|
109
|
+
| `Button` | `level` (primary/secondary/tertiary), `tone` (neutral/critical), `iconStart`, `iconEnd`, `text`, `fullWidth`, `loading`. |
|
|
110
|
+
| `Checkbox` | Controlled checkbox. Requires `label` (string). |
|
|
111
|
+
| `Radio` | Controlled radio button. |
|
|
112
|
+
| `Switch` | Toggle control. Requires `label` (string). |
|
|
113
|
+
| `Link` | Anchor element styled as a link. |
|
|
114
|
+
|
|
115
|
+
### Display
|
|
116
|
+
|
|
117
|
+
| Component | What it does |
|
|
118
|
+
| ---------------- | -------------------------------------------------------------------------------------------------------------------- |
|
|
119
|
+
| `Card` | Raised surface with background and `tone`. Does not accept padding, margin, or layout props — wrap content in `Box`. |
|
|
120
|
+
| `Divider` | Horizontal rule between content sections. |
|
|
121
|
+
| `Icon` | Renders a `@sanity/icons` icon component. Always set `aria-label` or `aria-hidden`. |
|
|
122
|
+
| `Indicator` | Status dot with `tone`. |
|
|
123
|
+
| `IndicatorGroup` | Grouped `Indicator` elements. |
|
|
124
|
+
| `Spinner` | Loading indicator. |
|
|
125
|
+
|
|
126
|
+
### Lists
|
|
127
|
+
|
|
128
|
+
| Component | What it does |
|
|
129
|
+
| --------- | --------------------------------------------------- |
|
|
130
|
+
| `List` | Semantic list. Use `List.Item` and `List.ItemText`. |
|
|
131
|
+
|
|
132
|
+
### Accessibility
|
|
133
|
+
|
|
134
|
+
| Component | What it does |
|
|
135
|
+
| ---------------- | ------------------------------------------------------------------------------------------------ |
|
|
136
|
+
| `SkipToContent` | Visually hidden skip-nav link. Must be the first focusable element. Requires `hash` and `label`. |
|
|
137
|
+
| `VisuallyHidden` | Hides content visually while keeping it in the accessibility tree. |
|
|
138
|
+
|
|
139
|
+
### Still from `@sanity/ui`
|
|
140
|
+
|
|
141
|
+
Menu, Dialog, TextInput, Select, Stack, Badge, ThemeProvider, ToastProvider, and other components not yet migrated to v4.
|
|
142
|
+
|
|
143
|
+
## Contributing
|
|
144
|
+
|
|
145
|
+
We welcome feedback and contributions. Start here:
|
|
146
|
+
|
|
147
|
+
1. **Try the components** and report what breaks, what confuses, or what's missing.
|
|
148
|
+
2. **Read the contribution model** — build a recipe with existing building block components, then propose graduating it.
|
|
149
|
+
3. **Open a PR** following the branch naming and checklist in the developer contribution docs.
|
|
150
|
+
|
|
151
|
+
During preview, the most useful contribution is using the components and telling us what happens.
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { hasLanguage, Refractor } from "react-refractor";
|
|
3
|
+
function LazyRefractor({ language, value }) {
|
|
4
|
+
return hasLanguage(language) ? /* @__PURE__ */ jsx(Refractor, { inline: !0, language, value }) : /* @__PURE__ */ jsx("code", { children: value });
|
|
5
|
+
}
|
|
6
|
+
export {
|
|
7
|
+
LazyRefractor as default
|
|
8
|
+
};
|
|
9
|
+
//# sourceMappingURL=LazyRefractor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LazyRefractor.js","sources":["../../src/components/code/LazyRefractor.tsx"],"sourcesContent":["import {hasLanguage, Refractor, type RefractorProps} from 'react-refractor'\n\nexport default function LazyRefractor({language, value}: RefractorProps) {\n if (!hasLanguage(language)) {\n return <code>{value}</code>\n }\n\n return <Refractor inline language={language} value={value} />\n}\n"],"names":[],"mappings":";;AAEA,SAAwB,cAAc,EAAC,UAAU,SAAwB;AACvE,SAAK,YAAY,QAAQ,IAIlB,oBAAC,WAAA,EAAU,QAAM,IAAC,UAAoB,MAAA,CAAc,IAHlD,oBAAC,QAAA,EAAM,UAAA,OAAM;AAIxB;"}
|