@jonmilner/ui 0.3.0 → 0.3.2
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/Badge/Badge.css.mjs +5 -3
- package/dist/Badge/index.d.mts +1 -1
- package/dist/Badge/index.mjs +8 -0
- package/dist/docs/Badge.md +5 -5
- package/dist/docs/lint.md +21 -0
- package/dist/docs/llms.txt +1 -0
- package/dist/docs/manifest.json +5 -3
- package/dist/lint/index.d.mts +9 -0
- package/dist/lint/index.mjs +18 -0
- package/package.json +5 -1
package/dist/Badge/Badge.css.mjs
CHANGED
|
@@ -10,11 +10,13 @@ var t = "_1ixfil10", n = e({
|
|
|
10
10
|
variant: {
|
|
11
11
|
neutral: "_1ixfil12",
|
|
12
12
|
accent: "_1ixfil13",
|
|
13
|
-
|
|
13
|
+
success: "_1ixfil14",
|
|
14
|
+
warning: "_1ixfil15",
|
|
15
|
+
danger: "_1ixfil16"
|
|
14
16
|
},
|
|
15
17
|
size: {
|
|
16
|
-
sm: "
|
|
17
|
-
med: "
|
|
18
|
+
sm: "_1ixfil17",
|
|
19
|
+
med: "_1ixfil18"
|
|
18
20
|
}
|
|
19
21
|
},
|
|
20
22
|
defaultVariants: {},
|
package/dist/Badge/index.d.mts
CHANGED
|
@@ -4,7 +4,7 @@ import { ComponentPropsWithRef } from "react";
|
|
|
4
4
|
//#region src/Badge/index.d.ts
|
|
5
5
|
export type BadgeOwnProps = {
|
|
6
6
|
size?: "sm" | "med";
|
|
7
|
-
variant?: "neutral" | "accent" | "danger";
|
|
7
|
+
variant?: "neutral" | "accent" | "success" | "warning" | "danger";
|
|
8
8
|
};
|
|
9
9
|
export type BadgeProps = StyleProps & BadgeOwnProps & OmitEach<ComponentPropsWithRef<"span">, keyof StyleProps | keyof BadgeOwnProps>;
|
|
10
10
|
export declare function Badge({ variant, size, display, paddingInline, paddingBlock, borderRadius, backgroundColor, color, className, children, ...props }: BadgeProps): import("react").JSX.Element | null;
|
package/dist/Badge/index.mjs
CHANGED
|
@@ -13,6 +13,14 @@ var o = {
|
|
|
13
13
|
backgroundColor: "accent",
|
|
14
14
|
color: "accentFg"
|
|
15
15
|
},
|
|
16
|
+
success: {
|
|
17
|
+
backgroundColor: "success",
|
|
18
|
+
color: "successFg"
|
|
19
|
+
},
|
|
20
|
+
warning: {
|
|
21
|
+
backgroundColor: "warning",
|
|
22
|
+
color: "warningFg"
|
|
23
|
+
},
|
|
16
24
|
danger: {
|
|
17
25
|
backgroundColor: "danger",
|
|
18
26
|
color: "dangerFg"
|
package/dist/docs/Badge.md
CHANGED
|
@@ -20,13 +20,13 @@ A static label that states the status of, or a short fact about, the thing besid
|
|
|
20
20
|
|
|
21
21
|
## Rules
|
|
22
22
|
|
|
23
|
-
- `variant`: `neutral` (default, `fgMuted` on `bgMuted`) for most statuses and facts; `accent` (`accentFg` on `accent`) to draw the eye; `
|
|
23
|
+
- `variant`: `neutral` (default, `fgMuted` on `bgMuted`) for most statuses and facts; `accent` (`accentFg` on `accent`) to draw the eye; `success` (`successFg` on `success`) for a done or healthy state; `warning` (`warningFg` on `warning`) for one that needs attention soon; `danger` (`dangerFg` on `danger`) for a failure or a blocked state.
|
|
24
24
|
- `size`: `sm` or `med` (default), the label's `fontSize` step.
|
|
25
|
-
- The label states the state. Color is never the only cue (WCAG 1.4.1): under forced colors every variant is the same outlined box, and some readers cannot tell the fills apart. Write "Failed", not a red badge reading "3".
|
|
25
|
+
- The label states the state. Color is never the only cue (WCAG 1.4.1): under forced colors every variant, `success` and `warning` included, is the same outlined box, and some readers cannot tell the fills apart (green from red above all). Write "Failed" or "Passed", not a red or green badge reading "3".
|
|
26
26
|
- Keep it to one or two words; it never wraps. With no children it renders nothing.
|
|
27
27
|
- Fill, text color, padding, radius and `display` (`inline-block`) are default style props on the outer `span`; a consumer's win. `className`, `style` and `ref` go to it, `className` last. The box holds inside a `Text` or `Heading` too.
|
|
28
28
|
- The module has no hooks, so a server component can render it.
|
|
29
|
-
- Migrating from the inbox's `Pill`: `Pill tone=…` is `Badge variant
|
|
29
|
+
- Migrating from the inbox's `Pill`: `Pill tone=…` is `Badge variant=…`, with `good` as `success`, `warn` as `warning` and `bad` as `danger`; `pillLink` has no Badge equivalent (compose `Clickable`).
|
|
30
30
|
|
|
31
31
|
## Do
|
|
32
32
|
|
|
@@ -60,7 +60,7 @@ A static label that states the status of, or a short fact about, the thing besid
|
|
|
60
60
|
- It is plain text in a `span`: screen readers read the label in line with what is around it, so the label must make sense there ("Quarterly report Draft").
|
|
61
61
|
- No role, no `aria-live`: a badge that changes is not announced. If a status change matters right away, announce it elsewhere (a toast).
|
|
62
62
|
- Each variant's text and fill pass AA (4.5:1) in light and dark mode; the pairs are in `contrastPairs` (ADR 0033).
|
|
63
|
-
- Under forced colors every badge is `CanvasText` on `Canvas` with a `CanvasText` outline, so the box survives and the variants look alike; the label carries the meaning. The role fills are not kept: `accent` would take the link color, on something that is not a link, and the browser's backplate would hide the filled variants' text.
|
|
63
|
+
- Under forced colors every badge is `CanvasText` on `Canvas` with a `CanvasText` outline, so the box survives and the variants look alike; the label carries the meaning. The role fills are not kept: `accent` would take the link color, on something that is not a link, and the browser's backplate would hide the filled variants' text. `success`, `warning` and `danger` map to the same system pair (ADR 0104), so only the label tells them apart.
|
|
64
64
|
|
|
65
65
|
## Props
|
|
66
66
|
|
|
@@ -71,6 +71,6 @@ Generated from the TypeScript types.
|
|
|
71
71
|
| Prop | Type | Required | Description |
|
|
72
72
|
| --- | --- | --- | --- |
|
|
73
73
|
| `size` | `"med" \| "sm"` | no | |
|
|
74
|
-
| `variant` | `"accent" \| "danger" \| "neutral"` | no | |
|
|
74
|
+
| `variant` | `"accent" \| "danger" \| "neutral" \| "success" \| "warning"` | no | |
|
|
75
75
|
|
|
76
76
|
Also accepts the style props (see `manifest.json` `styleProps`).
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# Lint
|
|
2
|
+
|
|
3
|
+
`@jonmilner/ui/lint` holds the options for `uiLint()` from `@jonmilner/oxlint-config` that follow the library's components. Import it in the app's `vite.config.ts`; nothing in it runs in the app.
|
|
4
|
+
|
|
5
|
+
## textComponents
|
|
6
|
+
|
|
7
|
+
The library's components and parts that render their children through `Text`. Pass it as `textComponents`, so documented usage such as `<Tabs.Tab>Privacy</Tabs.Tab>` or `<Field.Label>Email</Field.Label>` passes `ui/no-bare-text`.
|
|
8
|
+
|
|
9
|
+
```ts
|
|
10
|
+
import { lint, uiLint } from "@jonmilner/oxlint-config";
|
|
11
|
+
import { textComponents } from "@jonmilner/ui/lint";
|
|
12
|
+
import { defineConfig } from "vite-plus";
|
|
13
|
+
|
|
14
|
+
export default defineConfig({
|
|
15
|
+
lint: { ...lint, ...uiLint({ textComponents: [...textComponents, "VisuallyHidden"] }) },
|
|
16
|
+
});
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
- The option replaces the preset's default list, so add the app's own text components (here `VisuallyHidden`) after the library's.
|
|
20
|
+
- Never copy the list into the app: it changes with the library, and an upgrade brings the new parts.
|
|
21
|
+
- The rule matches a tag's last segment: `Tabs.Tab` is `Tab`. So `Item` and `Label` pass any component's part of that name, and `Trigger` and `Close` pass even without the look (`variant`, `size`, an icon) that makes them a Button. Give a look-less `Trigger` or `Close` a `Text` child yourself.
|
package/dist/docs/llms.txt
CHANGED
|
@@ -30,4 +30,5 @@
|
|
|
30
30
|
|
|
31
31
|
- [manifest.json](manifest.json): every component, prop, variant, icon and token, as JSON
|
|
32
32
|
- [theming.md](theming.md): themes, brands and tokens
|
|
33
|
+
- [lint.md](lint.md): the `uiLint()` options the library ships
|
|
33
34
|
- [migrations/](migrations/README.md): upgrade notes for breaking releases
|
package/dist/docs/manifest.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "./manifest.schema.json",
|
|
3
3
|
"package": "@jonmilner/ui",
|
|
4
|
-
"version": "0.3.
|
|
4
|
+
"version": "0.3.2",
|
|
5
5
|
"components": [
|
|
6
6
|
{
|
|
7
7
|
"name": "AlertDialog",
|
|
@@ -143,12 +143,14 @@
|
|
|
143
143
|
},
|
|
144
144
|
{
|
|
145
145
|
"name": "variant",
|
|
146
|
-
"type": "\"accent\" | \"danger\" | \"neutral\"",
|
|
146
|
+
"type": "\"accent\" | \"danger\" | \"neutral\" | \"success\" | \"warning\"",
|
|
147
147
|
"required": false,
|
|
148
148
|
"values": [
|
|
149
149
|
"accent",
|
|
150
150
|
"danger",
|
|
151
|
-
"neutral"
|
|
151
|
+
"neutral",
|
|
152
|
+
"success",
|
|
153
|
+
"warning"
|
|
152
154
|
]
|
|
153
155
|
}
|
|
154
156
|
],
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
//#region src/lint/index.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* The library's components and parts that render their children through `Text`, for the
|
|
4
|
+
* `textComponents` option of `uiLint()` from `@jonmilner/oxlint-config`. A part is named by its
|
|
5
|
+
* property (`Tabs.Tab` is `Tab`). Spread it and add the app's own text components; see
|
|
6
|
+
* `docs/lint.md`.
|
|
7
|
+
*/
|
|
8
|
+
export declare const textComponents: readonly string[];
|
|
9
|
+
//#endregion
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
//#region src/lint/index.ts
|
|
2
|
+
var e = Object.freeze([
|
|
3
|
+
"Text",
|
|
4
|
+
"Heading",
|
|
5
|
+
"Button",
|
|
6
|
+
"Badge",
|
|
7
|
+
"Tag",
|
|
8
|
+
"Chip",
|
|
9
|
+
"Tab",
|
|
10
|
+
"Item",
|
|
11
|
+
"Label",
|
|
12
|
+
"Error",
|
|
13
|
+
"Description",
|
|
14
|
+
"Trigger",
|
|
15
|
+
"Close"
|
|
16
|
+
]);
|
|
17
|
+
//#endregion
|
|
18
|
+
export { e as textComponents };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jonmilner/ui",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.2",
|
|
4
4
|
"files": [
|
|
5
5
|
"dist",
|
|
6
6
|
"THIRD_PARTY_NOTICES.md"
|
|
@@ -114,6 +114,10 @@
|
|
|
114
114
|
"types": "./dist/testing/index.d.mts",
|
|
115
115
|
"default": "./dist/testing/index.mjs"
|
|
116
116
|
},
|
|
117
|
+
"./lint": {
|
|
118
|
+
"types": "./dist/lint/index.d.mts",
|
|
119
|
+
"default": "./dist/lint/index.mjs"
|
|
120
|
+
},
|
|
117
121
|
"./base.css": "./dist/base.css",
|
|
118
122
|
"./docs/*": "./dist/docs/*"
|
|
119
123
|
},
|