@jonmilner/ui 0.11.2 → 0.11.3
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/dist/docs/Box.md +24 -3
- package/dist/docs/Stack.md +26 -0
- package/dist/docs/llms.txt +7 -0
- package/dist/docs/manifest.json +1 -1
- package/package.json +1 -1
package/dist/docs/Box.md
CHANGED
|
@@ -6,14 +6,14 @@ The base element every component builds on: one element, chosen with `as`, style
|
|
|
6
6
|
|
|
7
7
|
## When to use
|
|
8
8
|
|
|
9
|
-
-
|
|
9
|
+
- Surfaces that need tokens but no behavior: a padded panel, a sticky bar, a grid.
|
|
10
10
|
- A semantic element (`as="section"`, `as="nav"`, `as="ul"`) that needs style props.
|
|
11
11
|
- Building a new component: render a `Box` and pass its tunable values as default style props.
|
|
12
12
|
|
|
13
13
|
## When not to use
|
|
14
14
|
|
|
15
15
|
- Text: use `Text` or `Heading`; all visible text goes through them.
|
|
16
|
-
- Stacks and rows of children with a gap: use `Stack` or `Inline`.
|
|
16
|
+
- Stacks and rows of children with a gap: use `Stack` or `Inline`. A Box with `display="flex"`, `flexDirection="column"` and `gap` is a `Stack` rebuilt by hand.
|
|
17
17
|
- Anything interactive: use `Button` or a link component, which bring focus and states.
|
|
18
18
|
|
|
19
19
|
## Rules
|
|
@@ -33,7 +33,20 @@ The base element every component builds on: one element, chosen with `as`, style
|
|
|
33
33
|
## Do
|
|
34
34
|
|
|
35
35
|
```tsx
|
|
36
|
-
|
|
36
|
+
// A centered column: `Stack`, not a Box with flex props (see Don't).
|
|
37
|
+
<Stack gap="16" alignItems="center">
|
|
38
|
+
<Heading>No projects yet</Heading>
|
|
39
|
+
<Button variant="primary">Create project</Button>
|
|
40
|
+
</Stack>
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
```tsx
|
|
44
|
+
<Box
|
|
45
|
+
as="section"
|
|
46
|
+
aria-label="Billing"
|
|
47
|
+
padding={{ base: "16", med: "24" }}
|
|
48
|
+
backgroundColor="bgRaised"
|
|
49
|
+
>
|
|
37
50
|
…
|
|
38
51
|
</Box>
|
|
39
52
|
```
|
|
@@ -57,6 +70,14 @@ import "@jonmilner/ui/responsive.css";
|
|
|
57
70
|
|
|
58
71
|
## Don't
|
|
59
72
|
|
|
73
|
+
```tsx
|
|
74
|
+
// A Box rebuilding Stack: write `<Stack gap="16" alignItems="center">` (see Do).
|
|
75
|
+
<Box display="flex" flexDirection="column" alignItems="center" gap="16">
|
|
76
|
+
<Heading>No projects yet</Heading>
|
|
77
|
+
<Button variant="primary">Create project</Button>
|
|
78
|
+
</Box>
|
|
79
|
+
```
|
|
80
|
+
|
|
60
81
|
```tsx
|
|
61
82
|
// Physical property, `md`: neither type-checks.
|
|
62
83
|
<Box paddingLeft="16" gap="md" />
|
package/dist/docs/Stack.md
CHANGED
|
@@ -22,6 +22,7 @@ A vertical column of children with even space between them. `Stack` is a `Box` w
|
|
|
22
22
|
- Space comes from `gap`, never from margins on the children.
|
|
23
23
|
- It takes every `Box` prop, and the layout defaults are style props, so `display`, `flexDirection` and `alignItems` override them.
|
|
24
24
|
- Children are not wrapped, so each child is a flex item: it stretches to the column's width unless `alignItems` says otherwise.
|
|
25
|
+
- A list needs no `className` or stylesheet. `paddingInlineStart="0"` drops the `ul` indent, and a row that is a `Box as="li"` with a `display` other than `list-item` draws no marker.
|
|
25
26
|
- The consumer's `className` comes last and `style` is passed through; `ref` is a plain prop typed for the `as` element.
|
|
26
27
|
|
|
27
28
|
## Do
|
|
@@ -39,8 +40,33 @@ A vertical column of children with even space between them. `Stack` is a `Box` w
|
|
|
39
40
|
</Stack>
|
|
40
41
|
```
|
|
41
42
|
|
|
43
|
+
```tsx
|
|
44
|
+
// A styled list with no className: the rows are surfaces, and a flex `li` draws no marker.
|
|
45
|
+
<Stack as="ul" gap="8" paddingInlineStart="0" aria-label="Projects">
|
|
46
|
+
{projects.map((project) => (
|
|
47
|
+
<Box
|
|
48
|
+
as="li"
|
|
49
|
+
key={project.id}
|
|
50
|
+
display="flex"
|
|
51
|
+
padding="12"
|
|
52
|
+
backgroundColor="bgRaised"
|
|
53
|
+
borderRadius="med"
|
|
54
|
+
>
|
|
55
|
+
<Text>{project.name}</Text>
|
|
56
|
+
</Box>
|
|
57
|
+
))}
|
|
58
|
+
</Stack>
|
|
59
|
+
```
|
|
60
|
+
|
|
42
61
|
## Don't
|
|
43
62
|
|
|
63
|
+
```tsx
|
|
64
|
+
// A class and an app stylesheet for what style props cover.
|
|
65
|
+
<Stack as="ul" gap="8" className="project-list">
|
|
66
|
+
<li>…</li>
|
|
67
|
+
</Stack>
|
|
68
|
+
```
|
|
69
|
+
|
|
44
70
|
```tsx
|
|
45
71
|
// Margins on children instead of gap; and `gap` is required.
|
|
46
72
|
<Stack>
|
package/dist/docs/llms.txt
CHANGED
|
@@ -2,6 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
> React design system. Each component's docs say when to use it, its rules and props.
|
|
4
4
|
|
|
5
|
+
## Rules for every screen
|
|
6
|
+
|
|
7
|
+
- Lay out with `Stack` (a column) and `Inline` (a row that wraps), spaced by their `gap`. Never rebuild them from a `Box` with `display`, `flexDirection` and `gap`.
|
|
8
|
+
- `Box` is for a surface (padding, background, radius, shadow) or a semantic element that needs style props.
|
|
9
|
+
- No `className`, `style` or app stylesheet for what a style prop or a component covers. Style props take token keys, so no raw colors or lengths either.
|
|
10
|
+
- A list is `Stack as="ul"` with `li` children. For one without markers or indent, add `paddingInlineStart="0"` and make each row a `Box as="li" display="flex"`, as Stack's docs show.
|
|
11
|
+
|
|
5
12
|
## Components
|
|
6
13
|
|
|
7
14
|
- [AlertDialog](AlertDialog.md): Asks the user to confirm a consequential action before it runs: delete a project, discard unsaved changes, sign out every device. Built on Base UI's AlertDialog, which owns the behavior: `role="alertdialog"`, focus moves into the dialog and stays there, the page behind is inert, Esc closes it, and a click outside does not. It wears Dialog's panel at the `sm` width with a title, a description, Cancel and one confirm button, and Cancel takes focus on open.
|
package/dist/docs/manifest.json
CHANGED