@mojawork/ui-docs 2.6.1 → 2.8.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 +2 -2
- package/catalog/atoms/image-grid.md +45 -1
- package/catalog/atoms/inline-spinner.md +188 -0
- package/catalog/atoms/mosaic.md +1 -1
- package/catalog/atoms/reader-doc.md +25 -0
- package/catalog/forms/chip.md +285 -0
- package/catalog/guide.json +69 -7
- package/catalog/layout/spinner.md +7 -0
- package/catalog/manifest.json +29 -5
- package/catalog/version.json +2 -2
- package/package.json +1 -1
- package/storybook/2621.2245d387.iframe.bundle.js +1 -0
- package/storybook/4555.525bbef9.iframe.bundle.js +1 -0
- package/storybook/9045.46ed3f61.iframe.bundle.js +2 -0
- package/storybook/{_external-mwork-music-player-docs-mdx.6f943768.iframe.bundle.js → _external-mwork-music-player-docs-mdx.3d0f7156.iframe.bundle.js} +1 -1
- package/storybook/_external-mwork-music-player-mwork-music-player-stories.26c06b83.iframe.bundle.js +1 -0
- package/storybook/atoms-_electrons-loader-docs-mdx.1176957f.iframe.bundle.js +1 -0
- package/storybook/atoms-_electrons-loader-loader-component-stories.8edadc42.iframe.bundle.js +1 -0
- package/storybook/atoms-image-grid-docs-mdx.7cb6414e.iframe.bundle.js +1 -0
- package/storybook/atoms-image-grid-image-grid-component-stories.8290e900.iframe.bundle.js +1 -0
- package/storybook/atoms-inline-spinner-docs-mdx.a98163b8.iframe.bundle.js +1 -0
- package/storybook/atoms-inline-spinner-inline-spinner-component-stories.76f59aa8.iframe.bundle.js +1 -0
- package/storybook/{atoms-mosaic-mosaic-component-stories.0a6bc043.iframe.bundle.js → atoms-mosaic-mosaic-component-stories.c2ec95f2.iframe.bundle.js} +1 -1
- package/storybook/atoms-reader-doc-docs-mdx.1860338f.iframe.bundle.js +1 -0
- package/storybook/atoms-reader-doc-reader-doc-component-stories.8ccd618b.iframe.bundle.js +1 -0
- package/storybook/{atoms-thumb-docs-mdx.2143ad01.iframe.bundle.js → atoms-thumb-docs-mdx.7286b617.iframe.bundle.js} +1 -1
- package/storybook/{atoms-thumb-thumb-component-stories.06f51d03.iframe.bundle.js → atoms-thumb-thumb-component-stories.f7e9dbae.iframe.bundle.js} +1 -1
- package/storybook/{atoms-typewriter-docs-mdx.3b1088c0.iframe.bundle.js → atoms-typewriter-docs-mdx.993bc264.iframe.bundle.js} +1 -1
- package/storybook/atoms-typewriter-typewriter-component-stories.80f07c89.iframe.bundle.js +1 -0
- package/storybook/examples-image-grid-slider-docs-mdx.d3578699.iframe.bundle.js +1 -0
- package/storybook/examples-image-grid-slider-image-grid-slider-stories.cda91b79.iframe.bundle.js +1 -0
- package/storybook/forms-chip-chip-component-stories.90a45ea4.iframe.bundle.js +1 -0
- package/storybook/forms-chip-docs-mdx.01e1b518.iframe.bundle.js +1 -0
- package/storybook/{home-overview-mdx.0d4ede52.iframe.bundle.js → home-overview-mdx.a2833e60.iframe.bundle.js} +1 -1
- package/storybook/iframe.html +3 -3
- package/storybook/index.json +1 -1
- package/storybook/layout-spinner-docs-mdx.03741741.iframe.bundle.js +1 -0
- package/storybook/layout-spinner-spinner-component-stories.69ae1389.iframe.bundle.js +1 -0
- package/storybook/{main.e33bfc7e33aad318b1d2.css → main.4530991c57c404682bbb.css} +16 -0
- package/storybook/main.5e4e255f.iframe.bundle.js +1 -0
- package/storybook/project.json +1 -1
- package/storybook/runtime~main.a2ec52c2.iframe.bundle.js +1 -0
- package/storybook/version.json +2 -2
- package/version.json +2 -2
- package/storybook/4555.251b232c.iframe.bundle.js +0 -1
- package/storybook/9045.a50616e9.iframe.bundle.js +0 -2
- package/storybook/_external-mwork-music-player-mwork-music-player-stories.08fbf651.iframe.bundle.js +0 -1
- package/storybook/atoms-image-grid-docs-mdx.18b4df2a.iframe.bundle.js +0 -1
- package/storybook/atoms-image-grid-image-grid-component-stories.a0a92d9e.iframe.bundle.js +0 -1
- package/storybook/atoms-reader-doc-docs-mdx.0688c3b9.iframe.bundle.js +0 -1
- package/storybook/atoms-reader-doc-reader-doc-component-stories.a6fec57d.iframe.bundle.js +0 -1
- package/storybook/atoms-typewriter-typewriter-component-stories.4fefc019.iframe.bundle.js +0 -1
- package/storybook/examples-image-grid-slider-docs-mdx.9e38157e.iframe.bundle.js +0 -1
- package/storybook/examples-image-grid-slider-image-grid-slider-stories.028c8c2b.iframe.bundle.js +0 -1
- package/storybook/layout-spinner-docs-mdx.4be572c0.iframe.bundle.js +0 -1
- package/storybook/layout-spinner-spinner-component-stories.ab8245c6.iframe.bundle.js +0 -1
- package/storybook/main.1f12809e.iframe.bundle.js +0 -1
- package/storybook/runtime~main.52ba2f02.iframe.bundle.js +0 -1
- /package/storybook/{9045.a50616e9.iframe.bundle.js.LICENSE.txt → 9045.46ed3f61.iframe.bundle.js.LICENSE.txt} +0 -0
package/README.md
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
# @mojawork/ui-docs
|
|
2
2
|
|
|
3
|
-
The documentation of `@mojawork/ui` 2.
|
|
3
|
+
The documentation of `@mojawork/ui` 2.8.0, version-true and offline:
|
|
4
4
|
the built Storybook plus the cooked catalog. Install nothing — start it:
|
|
5
5
|
|
|
6
6
|
```bash
|
|
7
|
-
npx @mojawork/ui-docs@2.
|
|
7
|
+
npx @mojawork/ui-docs@2.8.0
|
|
8
8
|
```
|
|
9
9
|
|
|
10
10
|
and open the printed URL. The Storybook you see is exactly the one this
|
|
@@ -13,6 +13,13 @@ slider can point at the same picture. It opens nothing itself: a click emits
|
|
|
13
13
|
`clickIndex`, and what follows — a slider in zoom, a route — is the host's
|
|
14
14
|
decision. `cols` must be set; the default `0` draws no columns.
|
|
15
15
|
|
|
16
|
+
As a **strip** (`singleRow` with a `tileHeight`) it is one row of equally
|
|
17
|
+
sized tiles that scrolls sideways once there are more than fit — a row of
|
|
18
|
+
episode stills, a row of posters. Then `cols` plays no part, nothing is
|
|
19
|
+
padded, and `tileAspect` gives the tile its shape. `imageFit` decides how
|
|
20
|
+
a tile holds its picture in either mode: at its own size (the default), or
|
|
21
|
+
filling the tile, or fitted whole.
|
|
22
|
+
|
|
16
23
|
---
|
|
17
24
|
|
|
18
25
|
> **Guide:** recommendations for `ui-image-grid` — use for, not for, instead, shown in — are served by `get_guide` (name: `ui-image-grid`). The section above is the truth; the guide is the offer.
|
|
@@ -23,6 +30,17 @@ decision. `cols` must be set; the default `0` draws no columns.
|
|
|
23
30
|
|
|
24
31
|
---
|
|
25
32
|
|
|
33
|
+
### [Strip](?path=/story/atoms-image-grid--strip)
|
|
34
|
+
|
|
35
|
+
One row of fixed-size tiles that scrolls sideways — an episode strip, a row
|
|
36
|
+
of posters. `singleRow` with a `tileHeight`: every tile is that tall and
|
|
37
|
+
`tileHeight × tileAspect` wide, the row holds exactly its items, and once
|
|
38
|
+
they are wider than the container it scrolls instead of shrinking them.
|
|
39
|
+
`cols` is not read. The pictures fill their tiles (`imageFit: 'cover'`), and
|
|
40
|
+
the click area names the tile — the story writes the item's `alt` into it.
|
|
41
|
+
|
|
42
|
+
---
|
|
43
|
+
|
|
26
44
|
#### Features
|
|
27
45
|
|
|
28
46
|
- **Responsive Grid**: Automatically adjusts to its container and supports configurable column counts.
|
|
@@ -67,6 +85,24 @@ decision. `cols` must be set; the default `0` draws no columns.
|
|
|
67
85
|
<td>undefined</td>
|
|
68
86
|
<td>Height of the grid container. If <code>singleRow</code> is false, this is the total height. If <code>singleRow</code> is true, this value is divided by <code>cols</code> to determine the row height. Falls back to 200px when no height is given.</td>
|
|
69
87
|
</tr>
|
|
88
|
+
<tr>
|
|
89
|
+
<td>tileHeight</td>
|
|
90
|
+
<td>number</td>
|
|
91
|
+
<td>undefined</td>
|
|
92
|
+
<td>Strip mode, with <code>singleRow</code>: the fixed tile height in pixels. The row then holds exactly its items at that size and scrolls sideways when they do not fit; <code>cols</code> and <code>height</code> are not read. Without it the single row keeps its <code>height / cols</code> sizing.</td>
|
|
93
|
+
</tr>
|
|
94
|
+
<tr>
|
|
95
|
+
<td>tileAspect</td>
|
|
96
|
+
<td>string</td>
|
|
97
|
+
<td>'1/1'</td>
|
|
98
|
+
<td>The strip tile's shape as <code>width/height</code> — <code>'16/9'</code> for stills, <code>'2/3'</code> for posters. Read only together with <code>tileHeight</code>.</td>
|
|
99
|
+
</tr>
|
|
100
|
+
<tr>
|
|
101
|
+
<td>imageFit</td>
|
|
102
|
+
<td><code>'none' | 'cover' | 'contain'</code></td>
|
|
103
|
+
<td>'none'</td>
|
|
104
|
+
<td>How a tile holds its picture. <code>none</code> draws it at its own size and lets the tile crop it; <code>cover</code> fills the tile and crops what does not fit; <code>contain</code> shows the whole picture with bars where the shapes differ.</td>
|
|
105
|
+
</tr>
|
|
70
106
|
<tr>
|
|
71
107
|
<td>singleRow</td>
|
|
72
108
|
<td>boolean</td>
|
|
@@ -118,7 +154,13 @@ In the story above, the fourth tile is that case, and it says so: the entry
|
|
|
118
154
|
carries the title *"no image on purpose"*. Give it whatever wording fits your
|
|
119
155
|
case — the component supplies the space, never the words.
|
|
120
156
|
|
|
121
|
-
|
|
157
|
+
**A picture that fails to load** is the other case, and it ends in the same
|
|
158
|
+
picture: the tile keeps its surface and shows the item's `alt` text, centred,
|
|
159
|
+
whatever the fit mode — a sized `<img>` that failed would otherwise draw the
|
|
160
|
+
browser's broken-image icon in a corner. The grid marks the tile on the
|
|
161
|
+
image's `error` event; new data clears the marks.
|
|
162
|
+
|
|
163
|
+
Two things worth knowing about the empty state:
|
|
122
164
|
|
|
123
165
|
- **It is the same branch as `loaded: false`.** Turn `loaded` off and *every*
|
|
124
166
|
tile shows its title. The component does not distinguish "not there yet" from
|
|
@@ -140,12 +182,14 @@ The number of columns is determined by the `cols` input and the total number of
|
|
|
140
182
|
- If `dataCount / cols > cols`, the grid becomes "square-ish" or expands to fit items, calculating columns as `Math.ceil(dataCount / cols)`.
|
|
141
183
|
- Otherwise, it uses the fixed `cols` value provided.
|
|
142
184
|
- With `cols` at `0` (the default) no expansion happens and the grid gets zero columns — a column count is part of using the component.
|
|
185
|
+
- A **single row never expands and never pads**: it holds exactly its items. The square is the two-dimensional grid's shape, and a row has no second dimension to fill.
|
|
143
186
|
|
|
144
187
|
##### Height Calculation (`scrollerHeight`)
|
|
145
188
|
|
|
146
189
|
The height of the grid container is dynamically calculated:
|
|
147
190
|
- **Standard Mode (`singleRow` is false)**: Uses the `height` input value in pixels. Falls back to `200px` when no `height` is given.
|
|
148
191
|
- **Single Row Mode (`singleRow` is true)**: The height is calculated as `height / cols` (both must be set; otherwise the same `height`-or-`200px` fallback applies). This ensures that even in a horizontal scroll scenario, the items maintain a consistent aspect ratio based on the intended column count.
|
|
192
|
+
- **Strip Mode (`singleRow` with `tileHeight`)**: The height IS `tileHeight`; each tile is `tileHeight` tall and `tileHeight × tileAspect` wide, and the row's tracks are that width, so the row overflows and scrolls instead of shrinking the tiles to fit. See the [Strip](?path=/story/atoms-image-grid--strip) story.
|
|
149
193
|
|
|
150
194
|
---
|
|
151
195
|
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
### Inline Spinner
|
|
2
|
+
|
|
3
|
+
A loading indicator for one area of a page.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
### What it does, and what it does not
|
|
8
|
+
|
|
9
|
+
It turns, where it is put. That is the whole component: no backdrop, no focus
|
|
10
|
+
trap, no service, no message, nothing blocked. A panel waiting for its record,
|
|
11
|
+
a tile waiting for a picture, a list waiting for a page — the indicator sits in
|
|
12
|
+
the flow and the layout around it stays where it is.
|
|
13
|
+
|
|
14
|
+
It is the counterpart to `ui-layout-spinner`, which is the application's single
|
|
15
|
+
global overlay and says of itself that it is not the spinner for one
|
|
16
|
+
component's own loading state. This one is that spinner.
|
|
17
|
+
|
|
18
|
+
**It shows whenever it is in the DOM.** Whether something is loading is the
|
|
19
|
+
consumer's question, and an `@if` around the tag is the honest answer to it —
|
|
20
|
+
a `loading` input would only move the same boolean one level down and add a
|
|
21
|
+
state the component would have to be trusted with.
|
|
22
|
+
|
|
23
|
+
Both draw the same animation: it lives in an internal electron that the global
|
|
24
|
+
spinner builds in as well, so there is one set of keyframes in the library and
|
|
25
|
+
not two that drift.
|
|
26
|
+
|
|
27
|
+
---
|
|
28
|
+
|
|
29
|
+
> **Guide:** recommendations for `ui-inline-spinner` — use for, not for, instead, shown in — are served by `get_guide` (name: `ui-inline-spinner`). The section above is the truth; the guide is the offer.
|
|
30
|
+
|
|
31
|
+
---
|
|
32
|
+
|
|
33
|
+
### Default
|
|
34
|
+
|
|
35
|
+
#### Story: Default
|
|
36
|
+
|
|
37
|
+
https://moja.work/storybook/?path=/story/atoms-inline-spinner--default
|
|
38
|
+
|
|
39
|
+
```ts
|
|
40
|
+
export const Default: Story = {
|
|
41
|
+
args: { type: 'ring', label: 'Loading' },
|
|
42
|
+
render: (args) => ({
|
|
43
|
+
props: { ...args },
|
|
44
|
+
template: `<ui-inline-spinner [type]="type" [label]="label" />`,
|
|
45
|
+
}),
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* All three visuals side by side. All three read `--ui-spinner-size`: for the
|
|
50
|
+
* two discs it is the diameter, for the bar its length. A utility class on the
|
|
51
|
+
* tag widens the wrapper, not the animation — the variable is the handle.
|
|
52
|
+
*/
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
---
|
|
56
|
+
|
|
57
|
+
### The three visuals
|
|
58
|
+
|
|
59
|
+
`ring` and `disco` are discs, `linear` is a bar. They are the same three the
|
|
60
|
+
global spinner offers, because it is the same drawing.
|
|
61
|
+
|
|
62
|
+
#### Story: Types
|
|
63
|
+
|
|
64
|
+
https://moja.work/storybook/?path=/story/atoms-inline-spinner--types
|
|
65
|
+
|
|
66
|
+
```ts
|
|
67
|
+
export const Types: Story = {
|
|
68
|
+
parameters: { controls: { disable: true } },
|
|
69
|
+
render: () => ({
|
|
70
|
+
template: `
|
|
71
|
+
<div class="flex flex-wrap items-center gap-16">
|
|
72
|
+
<ui-inline-spinner type="ring" />
|
|
73
|
+
<ui-inline-spinner type="disco" />
|
|
74
|
+
<ui-inline-spinner type="linear" style="--ui-spinner-size: 16rem" />
|
|
75
|
+
</div>
|
|
76
|
+
`,
|
|
77
|
+
}),
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Size rides on `--ui-spinner-size`, the stroke on `--ui-spinner-stroke` —
|
|
82
|
+
* set from the outside, so the tag needs no input per dimension and a caller
|
|
83
|
+
* can drive them from their own tokens.
|
|
84
|
+
*/
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
---
|
|
88
|
+
|
|
89
|
+
### Size
|
|
90
|
+
|
|
91
|
+
Size is a named hook, not an input: `--ui-spinner-size` is the diameter of the
|
|
92
|
+
discs and the length of the bar, `--ui-spinner-stroke` is how thick the line is
|
|
93
|
+
drawn — the ring's annulus and the bar's height. Set them on the tag, or
|
|
94
|
+
inherit them from a container, and the same component serves a spinner beside a
|
|
95
|
+
line of text and one filling a panel.
|
|
96
|
+
|
|
97
|
+
Two consequences worth knowing. A width utility on the tag widens the wrapper,
|
|
98
|
+
not the animation — the variable is the handle. And unset, both fall back to
|
|
99
|
+
what the global spinner has always drawn (26rem), which is why moving the
|
|
100
|
+
animation into the shared electron changed nothing about the overlay.
|
|
101
|
+
|
|
102
|
+
#### Story: Sizes
|
|
103
|
+
|
|
104
|
+
https://moja.work/storybook/?path=/story/atoms-inline-spinner--sizes
|
|
105
|
+
|
|
106
|
+
```ts
|
|
107
|
+
export const Sizes: Story = {
|
|
108
|
+
parameters: { controls: { disable: true } },
|
|
109
|
+
render: () => ({
|
|
110
|
+
template: `
|
|
111
|
+
<div class="flex flex-wrap items-center gap-16">
|
|
112
|
+
<ui-inline-spinner style="--ui-spinner-size: 2rem; --ui-spinner-stroke: 0.3rem" />
|
|
113
|
+
<ui-inline-spinner style="--ui-spinner-size: 4rem; --ui-spinner-stroke: 0.4rem" />
|
|
114
|
+
<ui-inline-spinner style="--ui-spinner-size: 8rem; --ui-spinner-stroke: 0.8rem" />
|
|
115
|
+
</div>
|
|
116
|
+
`,
|
|
117
|
+
}),
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* In its place: a panel waiting for its content. The spinner sits in the flow
|
|
122
|
+
* and takes the width it is given — nothing is covered, nothing is blocked,
|
|
123
|
+
* and the page around it stays where it is.
|
|
124
|
+
*/
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
---
|
|
128
|
+
|
|
129
|
+
### In place
|
|
130
|
+
|
|
131
|
+
Nothing is covered and nothing is blocked. The tag takes exactly the room the
|
|
132
|
+
animation needs and sits where it is put — it does not stretch across the line
|
|
133
|
+
and centre itself, so placing it is the container's decision and not a
|
|
134
|
+
behaviour to work around. In the panel below, one pair of utility classes on
|
|
135
|
+
the panel does the centring.
|
|
136
|
+
|
|
137
|
+
#### Story: InAPanel
|
|
138
|
+
|
|
139
|
+
https://moja.work/storybook/?path=/story/atoms-inline-spinner--in-a-panel
|
|
140
|
+
|
|
141
|
+
```ts
|
|
142
|
+
export const InAPanel: Story = {
|
|
143
|
+
parameters: { controls: { disable: true } },
|
|
144
|
+
render: () => ({
|
|
145
|
+
template: `
|
|
146
|
+
<div class="flex h-64 w-96 items-center justify-center border">
|
|
147
|
+
<ui-inline-spinner label="Loading" />
|
|
148
|
+
</div>
|
|
149
|
+
`,
|
|
150
|
+
}),
|
|
151
|
+
};
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
---
|
|
155
|
+
|
|
156
|
+
### Arguments (Props)
|
|
157
|
+
|
|
158
|
+
#### Inputs
|
|
159
|
+
|
|
160
|
+
<table>
|
|
161
|
+
<thead>
|
|
162
|
+
<tr>
|
|
163
|
+
<th>Name</th>
|
|
164
|
+
<th>Type</th>
|
|
165
|
+
<th>Default</th>
|
|
166
|
+
<th>Description</th>
|
|
167
|
+
</tr>
|
|
168
|
+
</thead>
|
|
169
|
+
<tbody>
|
|
170
|
+
<tr>
|
|
171
|
+
<td>`type`</td>
|
|
172
|
+
<td>`'ring' | 'linear' | 'disco'`</td>
|
|
173
|
+
<td>`'ring'`</td>
|
|
174
|
+
<td>Which of the three visuals is drawn.</td>
|
|
175
|
+
</tr>
|
|
176
|
+
<tr>
|
|
177
|
+
<td>`label`</td>
|
|
178
|
+
<td>`string | null`</td>
|
|
179
|
+
<td>`null`</td>
|
|
180
|
+
<td>
|
|
181
|
+
What a screen reader is told while this is on screen. The animation is
|
|
182
|
+
`aria-hidden`, so without a word here the wait is silent. The sentence
|
|
183
|
+
belongs to the consumer — the library does not know what is loading and
|
|
184
|
+
has no dictionary for it.
|
|
185
|
+
</td>
|
|
186
|
+
</tr>
|
|
187
|
+
</tbody>
|
|
188
|
+
</table>
|
package/catalog/atoms/mosaic.md
CHANGED
|
@@ -141,7 +141,7 @@ export const OverImage: Story = {
|
|
|
141
141
|
<section class="relative m-4 h-96 w-[36rem]">
|
|
142
142
|
<img
|
|
143
143
|
class="h-full w-full object-cover"
|
|
144
|
-
src="https://moja.work/
|
|
144
|
+
src="https://moja.work/content/_assets/pictures/numbers/50/numbers-007.png"
|
|
145
145
|
alt="number-07"
|
|
146
146
|
/>
|
|
147
147
|
@if (shown()) { ${mosaic('absolute inset-0 z-10')} }
|
|
@@ -128,6 +128,31 @@ export const Figure: Story = {
|
|
|
128
128
|
render,
|
|
129
129
|
};
|
|
130
130
|
|
|
131
|
+
/**
|
|
132
|
+
* Emphasis stays in the line. The house sheet sets `strong` like a fourth
|
|
133
|
+
* heading — the reader takes size, line height and colour back, so a bold
|
|
134
|
+
* word mid-sentence is a bold word and not a blue subheading.
|
|
135
|
+
*/
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
The same rule, turned inward: the library's own sheet sets `strong` like a
|
|
139
|
+
fourth heading — its size, its line height, the default colour — which is
|
|
140
|
+
right for the house's surfaces and would be wrong here. A `**word**` in the
|
|
141
|
+
middle of a sentence is a bold word, not a subheading, so the reader takes
|
|
142
|
+
the three back and leaves only the weight. The rule is pinned by a test
|
|
143
|
+
against the stylesheet.
|
|
144
|
+
|
|
145
|
+
#### Story: Emphasis
|
|
146
|
+
|
|
147
|
+
https://moja.work/storybook/?path=/story/atoms-readerdoc--emphasis
|
|
148
|
+
|
|
149
|
+
```ts
|
|
150
|
+
export const Emphasis: Story = {
|
|
151
|
+
parameters: noControls,
|
|
152
|
+
args: { ...base, markdown: WITH_EMPHASIS },
|
|
153
|
+
render,
|
|
154
|
+
};
|
|
155
|
+
|
|
131
156
|
/**
|
|
132
157
|
* Inline code in a squeezed table cell: the hyphenated names stay on one line
|
|
133
158
|
* each, the description column takes the break.
|
|
@@ -0,0 +1,285 @@
|
|
|
1
|
+
### Chip
|
|
2
|
+
|
|
3
|
+
A small label that reports what is done to it.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
### What it does, and what it does not
|
|
8
|
+
|
|
9
|
+
It shows the text it is given and emits — a set filter, a chosen genre, a tag
|
|
10
|
+
on a record. What a press MEANS is the consumer's answer: the chip does not
|
|
11
|
+
select itself, does not mark itself active, and above all **does not remove
|
|
12
|
+
itself**. It says the cross was pressed; taking it out of the list is the job
|
|
13
|
+
of whoever holds the list.
|
|
14
|
+
|
|
15
|
+
That is the whole component. It has no active state, no group, no selection
|
|
16
|
+
model and no keyboard walk across a row — a set of chips that behave as one
|
|
17
|
+
choice is a different thing, and it is not this one.
|
|
18
|
+
|
|
19
|
+
---
|
|
20
|
+
|
|
21
|
+
> **Guide:** recommendations for `ui-chip` — use for, not for, instead, shown in — are served by `get_guide` (name: `ui-chip`). The section above is the truth; the guide is the offer.
|
|
22
|
+
|
|
23
|
+
---
|
|
24
|
+
|
|
25
|
+
### Two buttons, never nested
|
|
26
|
+
|
|
27
|
+
The label is one button and the remove cross is another, side by side inside
|
|
28
|
+
the chip's frame. This is the one decision worth knowing about, because from
|
|
29
|
+
the outside it looks like a single control.
|
|
30
|
+
|
|
31
|
+
A clickable chip containing a clickable cross would be a button inside a
|
|
32
|
+
button. With the mouse you would have to hit pixels; with the keyboard you
|
|
33
|
+
land on two targets of which one swallows the other, and the outer one fires
|
|
34
|
+
when the inner one is pressed. As siblings both are reachable, in order, and
|
|
35
|
+
no `stopPropagation` is needed anywhere — the cross simply is not inside the
|
|
36
|
+
thing it would otherwise trigger.
|
|
37
|
+
|
|
38
|
+
It also means focus is drawn on the control that has it, not around the whole
|
|
39
|
+
chip: two stops must look like two stops.
|
|
40
|
+
|
|
41
|
+
---
|
|
42
|
+
|
|
43
|
+
### Default
|
|
44
|
+
|
|
45
|
+
#### Story: Default
|
|
46
|
+
|
|
47
|
+
https://moja.work/storybook/?path=/story/forms-chip--default
|
|
48
|
+
|
|
49
|
+
```ts
|
|
50
|
+
export const Default: Story = {
|
|
51
|
+
args: { removable: true, removeLabel: 'Remove' },
|
|
52
|
+
render: (args) => ({
|
|
53
|
+
props: { ...args },
|
|
54
|
+
template: `
|
|
55
|
+
<ui-chip
|
|
56
|
+
[removable]="removable"
|
|
57
|
+
[removeLabel]="removeLabel"
|
|
58
|
+
(chipClick)="chipClick()"
|
|
59
|
+
(chipRemove)="chipRemove()"
|
|
60
|
+
>Label</ui-chip>
|
|
61
|
+
`,
|
|
62
|
+
}),
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* With and without the cross. The same component either way — the input says
|
|
67
|
+
* whether the chip can be thrown away, and nothing else changes.
|
|
68
|
+
*/
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
---
|
|
72
|
+
|
|
73
|
+
### With and without the cross
|
|
74
|
+
|
|
75
|
+
`removable` decides whether the chip can be thrown away. Nothing else changes
|
|
76
|
+
with it — the same component, one control more.
|
|
77
|
+
|
|
78
|
+
#### Story: Removable
|
|
79
|
+
|
|
80
|
+
https://moja.work/storybook/?path=/story/forms-chip--removable
|
|
81
|
+
|
|
82
|
+
```ts
|
|
83
|
+
export const Removable: Story = {
|
|
84
|
+
parameters: { controls: { disable: true } },
|
|
85
|
+
render: () => ({
|
|
86
|
+
template: `
|
|
87
|
+
<div class="flex flex-wrap items-center gap-4">
|
|
88
|
+
<ui-chip>Plain</ui-chip>
|
|
89
|
+
<ui-chip [removable]="true" removeLabel="Remove">Removable</ui-chip>
|
|
90
|
+
</div>
|
|
91
|
+
`,
|
|
92
|
+
}),
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* A row of them, as a filter bar collects itself. The chips do not remove
|
|
97
|
+
* themselves — the parent takes them out of its list when `chipRemove` says
|
|
98
|
+
* so, which is why they can be a plain list here.
|
|
99
|
+
*/
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
---
|
|
103
|
+
|
|
104
|
+
### A row of them
|
|
105
|
+
|
|
106
|
+
How a filter bar collects itself. The chips are a plain list because they do
|
|
107
|
+
not remove themselves: the parent drops the entry when `chipRemove` says so,
|
|
108
|
+
and the row re-renders.
|
|
109
|
+
|
|
110
|
+
#### Story: ARow
|
|
111
|
+
|
|
112
|
+
https://moja.work/storybook/?path=/story/forms-chip--a-row
|
|
113
|
+
|
|
114
|
+
```ts
|
|
115
|
+
export const ARow: Story = {
|
|
116
|
+
parameters: { controls: { disable: true } },
|
|
117
|
+
render: () => ({
|
|
118
|
+
template: `
|
|
119
|
+
<div class="flex flex-wrap items-center gap-4">
|
|
120
|
+
<ui-chip [removable]="true" removeLabel="Remove">Genre</ui-chip>
|
|
121
|
+
<ui-chip [removable]="true" removeLabel="Remove">Year</ui-chip>
|
|
122
|
+
<ui-chip [removable]="true" removeLabel="Remove">Publisher</ui-chip>
|
|
123
|
+
</div>
|
|
124
|
+
`,
|
|
125
|
+
}),
|
|
126
|
+
};
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* A label longer than the room it has shortens rather than pushing the row
|
|
130
|
+
* apart, and the cross keeps its place at the end.
|
|
131
|
+
*/
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
---
|
|
135
|
+
|
|
136
|
+
### A long label
|
|
137
|
+
|
|
138
|
+
A label longer than the room it has shortens rather than pushing the row
|
|
139
|
+
apart, and the cross keeps its place at the end — so a row of chips holds one
|
|
140
|
+
flight line whatever their labels do.
|
|
141
|
+
|
|
142
|
+
#### Story: LongLabel
|
|
143
|
+
|
|
144
|
+
https://moja.work/storybook/?path=/story/forms-chip--long-label
|
|
145
|
+
|
|
146
|
+
```ts
|
|
147
|
+
export const LongLabel: Story = {
|
|
148
|
+
parameters: { controls: { disable: true } },
|
|
149
|
+
render: () => ({
|
|
150
|
+
template: `
|
|
151
|
+
<div class="w-64">
|
|
152
|
+
<ui-chip [removable]="true" removeLabel="Remove"
|
|
153
|
+
>A label longer than the room it is given</ui-chip
|
|
154
|
+
>
|
|
155
|
+
</div>
|
|
156
|
+
`,
|
|
157
|
+
}),
|
|
158
|
+
};
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* Colours are custom properties, not inputs: set them on the tag, or once on
|
|
162
|
+
* a container so a whole row follows.
|
|
163
|
+
*/
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
---
|
|
167
|
+
|
|
168
|
+
### Colours
|
|
169
|
+
|
|
170
|
+
Custom properties, not inputs: set them on the tag, or once on a container so
|
|
171
|
+
a whole row follows. Every one falls back to a library token, so an unset chip
|
|
172
|
+
is a chip in the house colours.
|
|
173
|
+
|
|
174
|
+
<table class="ui">
|
|
175
|
+
<tr>
|
|
176
|
+
<th>variable</th>
|
|
177
|
+
<th>fallback</th>
|
|
178
|
+
</tr>
|
|
179
|
+
<tr>
|
|
180
|
+
<td>`--ui-chip-bg`</td>
|
|
181
|
+
<td>`var(--ui-c-fourthly)`</td>
|
|
182
|
+
</tr>
|
|
183
|
+
<tr>
|
|
184
|
+
<td>`--ui-chip-text`</td>
|
|
185
|
+
<td>`var(--ui-c-default)`</td>
|
|
186
|
+
</tr>
|
|
187
|
+
<tr>
|
|
188
|
+
<td>`--ui-chip-hover`</td>
|
|
189
|
+
<td>the text colour at 10%</td>
|
|
190
|
+
</tr>
|
|
191
|
+
<tr>
|
|
192
|
+
<td>`--ui-chip-radius`</td>
|
|
193
|
+
<td>`999px` — a pill; set the library radius for a square one</td>
|
|
194
|
+
</tr>
|
|
195
|
+
<tr>
|
|
196
|
+
<td>`--ui-chip-icon-size`</td>
|
|
197
|
+
<td>`1.6rem`</td>
|
|
198
|
+
</tr>
|
|
199
|
+
</table>
|
|
200
|
+
|
|
201
|
+
#### Story: Colours
|
|
202
|
+
|
|
203
|
+
https://moja.work/storybook/?path=/story/forms-chip--colours
|
|
204
|
+
|
|
205
|
+
```ts
|
|
206
|
+
export const Colours: Story = {
|
|
207
|
+
parameters: { controls: { disable: true } },
|
|
208
|
+
render: () => ({
|
|
209
|
+
template: `
|
|
210
|
+
<div class="flex flex-wrap items-center gap-4">
|
|
211
|
+
<ui-chip [removable]="true" removeLabel="Remove">Default</ui-chip>
|
|
212
|
+
<ui-chip
|
|
213
|
+
[removable]="true"
|
|
214
|
+
removeLabel="Remove"
|
|
215
|
+
style="--ui-chip-bg: var(--ui-c-focus); --ui-chip-text: var(--ui-c-static)"
|
|
216
|
+
>Accent</ui-chip
|
|
217
|
+
>
|
|
218
|
+
<ui-chip style="--ui-chip-radius: var(--ui-border-radius)">Square</ui-chip>
|
|
219
|
+
<ui-chip
|
|
220
|
+
[removable]="true"
|
|
221
|
+
removeLabel="Remove"
|
|
222
|
+
style="--ui-chip-radius: var(--ui-border-radius)"
|
|
223
|
+
>Square</ui-chip
|
|
224
|
+
>
|
|
225
|
+
</div>
|
|
226
|
+
`,
|
|
227
|
+
}),
|
|
228
|
+
};
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
---
|
|
232
|
+
|
|
233
|
+
### Arguments (Props)
|
|
234
|
+
|
|
235
|
+
#### Inputs
|
|
236
|
+
|
|
237
|
+
<table class="ui">
|
|
238
|
+
<tr>
|
|
239
|
+
<th>Name</th>
|
|
240
|
+
<th>Type</th>
|
|
241
|
+
<th>Default</th>
|
|
242
|
+
<th>Description</th>
|
|
243
|
+
</tr>
|
|
244
|
+
<tr>
|
|
245
|
+
<td>`removable`</td>
|
|
246
|
+
<td>`boolean`</td>
|
|
247
|
+
<td>`false`</td>
|
|
248
|
+
<td>Whether the remove cross is offered.</td>
|
|
249
|
+
</tr>
|
|
250
|
+
<tr>
|
|
251
|
+
<td>`removeLabel`</td>
|
|
252
|
+
<td>`string | null`</td>
|
|
253
|
+
<td>`null`</td>
|
|
254
|
+
<td>
|
|
255
|
+
What a screen reader is told the cross does. It carries no text of its
|
|
256
|
+
own, and "close" says nothing about which chip — the sentence belongs to
|
|
257
|
+
the consumer, who knows both the word and the language.
|
|
258
|
+
</td>
|
|
259
|
+
</tr>
|
|
260
|
+
</table>
|
|
261
|
+
|
|
262
|
+
#### Outputs
|
|
263
|
+
|
|
264
|
+
<table class="ui">
|
|
265
|
+
<tr>
|
|
266
|
+
<th>Name</th>
|
|
267
|
+
<th>Payload</th>
|
|
268
|
+
<th>Description</th>
|
|
269
|
+
</tr>
|
|
270
|
+
<tr>
|
|
271
|
+
<td>`chipClick`</td>
|
|
272
|
+
<td>`void`</td>
|
|
273
|
+
<td>The label was pressed.</td>
|
|
274
|
+
</tr>
|
|
275
|
+
<tr>
|
|
276
|
+
<td>`chipRemove`</td>
|
|
277
|
+
<td>`void`</td>
|
|
278
|
+
<td>The cross was pressed. The chip stays; removing it is the parent's.</td>
|
|
279
|
+
</tr>
|
|
280
|
+
</table>
|
|
281
|
+
|
|
282
|
+
#### Content
|
|
283
|
+
|
|
284
|
+
The label is projected: `<ui-chip>Genre</ui-chip>`. Whatever a chip is a chip
|
|
285
|
+
of goes inside — a word, a number, an icon beside a word.
|