@scalewing/react 1.68.0 → 1.69.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/CHANGELOG.md +6 -0
- package/README.md +1 -1
- package/dist/components/Box.d.ts +8 -2
- package/dist/css/css-box-link.d.ts +3 -1
- package/dist/css/css-box-link.js +47 -4
- package/dist/styles.css +15 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# @scalewing/react
|
|
2
2
|
|
|
3
|
+
## 1.69.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 324ad2c: `Box as="a" link="inline"` (`sw-link-inline`) is a link inside a sentence: the accent colour, always underlined, so it never depends on colour alone and passes axe's `link-in-text-block` where the accent is under 3:1 against the text around it. The line is 1px, 0.18em below the baseline, in the accent at 60 %; hover and keyboard focus draw it in the full accent at the focus ring's width, and the words stay in the accent. Focus keeps the canvas ring, forced colours paint it as any link, and `external` keeps its arrow. Requested by FutMas for its docs' body text (`docs/requests/futmas-box-link-inline.md`).
|
|
8
|
+
|
|
3
9
|
## 1.68.0
|
|
4
10
|
|
|
5
11
|
### Minor Changes
|
package/README.md
CHANGED
|
@@ -120,7 +120,7 @@ Import the CSS once at the application entry. Do not copy it into your source tr
|
|
|
120
120
|
|
|
121
121
|
`AppHeader` is the page's top chrome, sticky by default (`sticky={false}` leaves it in flow). Its default `appearance="glass"` is a rounded frosted card. `appearance="bar"` (`AppHeaderAppearance`, `appHeaderAppearances`) is a full-width band of the solid surface with the border hairline under it: no blur, no rounding, no side or top border, the same under Reduce Transparency, and the hairline kept in forced colors. Set it against the page's edges (no side gutter round it) and put the gutter inside it. A `ref` reaches its `header` element. An unknown `appearance` throws a `RangeError`.
|
|
122
122
|
|
|
123
|
-
`Box hideBelow="md"` hides a region under 48rem and `hideFrom="md"` hides it at 48rem and wider, so a product can swap a wide layout for a narrow one without its own stylesheet. They also take `lg` (64rem), for content that fits only from a laptop up, such as a row of labelled destinations that a tablet shows as glyphs (name each glyph-only control, for example with `Tooltip relationship="label"`); the layout props keep `md`. `breakpointQuery('below', 'lg')` returns the query a hide class uses (`not all and (min-width: 64rem)`), for an app whose script must follow the same width. An unknown breakpoint throws a `RangeError`. Hidden regions leave the accessibility tree; do not use this to protect data. `Box as="a"` is a layout link. Use `Button` for press actions. `Box as="a" link="quiet"` (opt-in; `link="accent"`, the default, is the canvas link) is a title that opens something, such as a table row's title: it keeps the surrounding text's colour at weight 600 (`sw-link-quiet`) and is underlined on hover and keyboard focus. Its weight is the non-colour cue WCAG 1.4.1 asks for (axe's `link-in-text-block` passes it on colour, the same colour and background as its text, or on its weight; the weight is what keeps it visibly a link), so use it in text lighter than 600. In text already at 600 the quiet look has no cue: an accent link there needs at least 3:1 contrast against the text. `link` on a box that is not `as="a"` throws a `TypeError`, an unknown value a `RangeError`. `Box as="a" external` (opt-in) opens the address in a new tab: it sets `target="_blank"` (always), adds `noopener noreferrer` to your `rel` words (each once), draws a decorative arrow (↗, `sw-link-external-mark`, `aria-hidden`) right after the words with no space, so it never wraps alone, and reads `newTabLabel` after the link's name from a visually hidden span ("Check the marsh map (opens in a new tab)"). The arrow is drawn with borders in the link's colour (accent, the hover colour, a quiet link's), so forced colours keep it, and is mirrored in right-to-left text. `newTabLabel` is your words in your language; it is required with `external` (blank throws a `RangeError`) and refused without it (`TypeError`); `external` on a box that is not `as="a"` throws a `TypeError`. `Field` associates a native `<input>` or `<select>` with a label and token gap; native text controls inherit the generated document canvas. `Steps` is a one-page vertical stepper: an `ol` of `Step` panels in order, numbered by their place, a line joining each marker to the next (in the success color below a done step). A `Step` takes `status` (`'upcoming' | 'current' | 'done' | 'error' | 'skipped'`) and `title` (a heading at the list's `headingLevel`, 2 by default, or the step's own). The current step is open with its `children` and has `aria-current="step"`; an error step stays open with a "!" marker. A done step folds to one line: a check, the title, its `summary` (truncated) and, with `onEdit` and `editLabel`, a ghost small `Button` at the end named by its label and the title ("Edit The site"). A step ahead is greyed with its number in a ring; a skipped step is greyed with its `skippedReason` after the title (pass your own separator, such as "· not needed"). A folded step's heading ends in its status word for assistive technology (visually hidden; English by default, `labels` on `Steps` takes your words): its name is one visually hidden line, the title, a comma and the word ("The site, Done"), and the drawn title is `aria-hidden`, because a browser lays a hidden box out as a block and would put a space before the comma ("The site , Done"). The step's region and its Edit button are still named by the drawn title. A current step, and a skipped step showing its reason, draw and read their words as they are. The heading's text content now holds the title twice (drawn, then in the spoken line), so a test reading a folded heading's `textContent` or finding its title with a pattern (`getByText(/The site/)`) finds both: query headings by role and name (`getByRole('heading', { name: 'The site, Done' })`). Copying a folded heading, or finding its title in the page, meets the words twice too. The comma after the title is Scalewing's, as before; the word is yours. When a step becomes current from a folded state (upcoming, done or skipped), focus moves to its heading, a programmatic focus target; if several do in one update, the first in the list takes it. A first render, a move between current and error, and a step that turns to error leave focus alone: after a refused submit, move focus to the first invalid field yourself, as with `Field`. An error step has no `aria-current`; its heading's status word says it needs attention. Scalewing holds no order rules: the consumer sets each step's status. `Steps open` (off by default) keeps every step open at once, for a form whose sections are all filled on one page: each step shows its `children` whatever its status, inside a `section` named by its title (a region, class `sw-steps-region`), every title at the open size; the marker still follows the status (a number to fill, a check when done, "!" in error, a grey ring and muted title when greyed, such as after a blocking step), no step is `aria-current`, and no step takes focus when its status changes. `titleDetail` (opt-in) is muted words after an open step's title, on its line, such as "Optional" on a step a person may skip, or "Wetlands done · Woodlands empty" on a step with a part per habitat: the label size at the body's weight in the muted colour, a space-2 after the title on its baseline, or on a line of their own under the title where they do not fit beside it (a long title on a phone), never past the panel (a long word breaks). They are drawn while the step is open (current or error, or every step of an open list, with fields or without) and stay as the step turns done in an open list; a folded step draws its summary or reason instead. They sit outside the heading, so the heading's name stays the title (and its status word) and a heading list reads the titles alone; an open list's region keeps the title as its name and is described by the words, read as a person enters it, and in a stepped list they follow the heading in reading order. Write your own separators inside the words; Scalewing draws only the gap after the title. The words share a skipped step's reason's muted colour, not its size: a reason is part of the title, these are a note beside it. Give a step its `titleDetail` from its first render: setting or clearing it later moves the heading into or out of the title line, which remounts it (and drops its focus if it has it). A blank `titleDetail` throws a `RangeError`. Pass the `Step`s as direct children (a Fragment around several would share one number). A `Step` outside `Steps`, a Fragment child, a blank title or reason, an unknown status or heading level, `onEdit` without `editLabel`, or a blank status word throws a `RangeError`.
|
|
123
|
+
`Box hideBelow="md"` hides a region under 48rem and `hideFrom="md"` hides it at 48rem and wider, so a product can swap a wide layout for a narrow one without its own stylesheet. They also take `lg` (64rem), for content that fits only from a laptop up, such as a row of labelled destinations that a tablet shows as glyphs (name each glyph-only control, for example with `Tooltip relationship="label"`); the layout props keep `md`. `breakpointQuery('below', 'lg')` returns the query a hide class uses (`not all and (min-width: 64rem)`), for an app whose script must follow the same width. An unknown breakpoint throws a `RangeError`. Hidden regions leave the accessibility tree; do not use this to protect data. `Box as="a"` is a layout link. Use `Button` for press actions. `Box as="a" link="quiet"` (opt-in; `link="accent"`, the default, is the canvas link) is a title that opens something, such as a table row's title: it keeps the surrounding text's colour at weight 600 (`sw-link-quiet`) and is underlined on hover and keyboard focus. Its weight is the non-colour cue WCAG 1.4.1 asks for (axe's `link-in-text-block` passes it on colour, the same colour and background as its text, or on its weight; the weight is what keeps it visibly a link), so use it in text lighter than 600. In text already at 600 the quiet look has no cue: an accent link there needs at least 3:1 contrast against the text. `Box as="a" link="inline"` (opt-in) is a link inside a sentence, such as a docs paragraph: the accent colour, always underlined (`sw-link-inline`), so it never depends on colour alone, wherever the accent falls under 3:1 against the words around it (axe's `link-in-text-block`, WCAG 1.4.1). The line is 1 px, 0.18em below the baseline, in the accent at 60 %; hover and keyboard focus draw it in the full accent at the focus ring's width, and the words stay in the accent (the canvas link's hover turns them the text colour). Focus keeps the canvas focus ring, forced colours paint the words and the line in the system link colour, and `external` adds its arrow after the underlined words. Use `inline` in running text, `quiet` for a title that opens something, and the default canvas link for a link that stands alone. `link` on a box that is not `as="a"` throws a `TypeError`, an unknown value a `RangeError`. `Box as="a" external` (opt-in) opens the address in a new tab: it sets `target="_blank"` (always), adds `noopener noreferrer` to your `rel` words (each once), draws a decorative arrow (↗, `sw-link-external-mark`, `aria-hidden`) right after the words with no space, so it never wraps alone, and reads `newTabLabel` after the link's name from a visually hidden span ("Check the marsh map (opens in a new tab)"). The arrow is drawn with borders in the link's colour (accent, the hover colour, a quiet link's, an inline link's), so forced colours keep it, and is mirrored in right-to-left text. `newTabLabel` is your words in your language; it is required with `external` (blank throws a `RangeError`) and refused without it (`TypeError`); `external` on a box that is not `as="a"` throws a `TypeError`. `Field` associates a native `<input>` or `<select>` with a label and token gap; native text controls inherit the generated document canvas. `Steps` is a one-page vertical stepper: an `ol` of `Step` panels in order, numbered by their place, a line joining each marker to the next (in the success color below a done step). A `Step` takes `status` (`'upcoming' | 'current' | 'done' | 'error' | 'skipped'`) and `title` (a heading at the list's `headingLevel`, 2 by default, or the step's own). The current step is open with its `children` and has `aria-current="step"`; an error step stays open with a "!" marker. A done step folds to one line: a check, the title, its `summary` (truncated) and, with `onEdit` and `editLabel`, a ghost small `Button` at the end named by its label and the title ("Edit The site"). A step ahead is greyed with its number in a ring; a skipped step is greyed with its `skippedReason` after the title (pass your own separator, such as "· not needed"). A folded step's heading ends in its status word for assistive technology (visually hidden; English by default, `labels` on `Steps` takes your words): its name is one visually hidden line, the title, a comma and the word ("The site, Done"), and the drawn title is `aria-hidden`, because a browser lays a hidden box out as a block and would put a space before the comma ("The site , Done"). The step's region and its Edit button are still named by the drawn title. A current step, and a skipped step showing its reason, draw and read their words as they are. The heading's text content now holds the title twice (drawn, then in the spoken line), so a test reading a folded heading's `textContent` or finding its title with a pattern (`getByText(/The site/)`) finds both: query headings by role and name (`getByRole('heading', { name: 'The site, Done' })`). Copying a folded heading, or finding its title in the page, meets the words twice too. The comma after the title is Scalewing's, as before; the word is yours. When a step becomes current from a folded state (upcoming, done or skipped), focus moves to its heading, a programmatic focus target; if several do in one update, the first in the list takes it. A first render, a move between current and error, and a step that turns to error leave focus alone: after a refused submit, move focus to the first invalid field yourself, as with `Field`. An error step has no `aria-current`; its heading's status word says it needs attention. Scalewing holds no order rules: the consumer sets each step's status. `Steps open` (off by default) keeps every step open at once, for a form whose sections are all filled on one page: each step shows its `children` whatever its status, inside a `section` named by its title (a region, class `sw-steps-region`), every title at the open size; the marker still follows the status (a number to fill, a check when done, "!" in error, a grey ring and muted title when greyed, such as after a blocking step), no step is `aria-current`, and no step takes focus when its status changes. `titleDetail` (opt-in) is muted words after an open step's title, on its line, such as "Optional" on a step a person may skip, or "Wetlands done · Woodlands empty" on a step with a part per habitat: the label size at the body's weight in the muted colour, a space-2 after the title on its baseline, or on a line of their own under the title where they do not fit beside it (a long title on a phone), never past the panel (a long word breaks). They are drawn while the step is open (current or error, or every step of an open list, with fields or without) and stay as the step turns done in an open list; a folded step draws its summary or reason instead. They sit outside the heading, so the heading's name stays the title (and its status word) and a heading list reads the titles alone; an open list's region keeps the title as its name and is described by the words, read as a person enters it, and in a stepped list they follow the heading in reading order. Write your own separators inside the words; Scalewing draws only the gap after the title. The words share a skipped step's reason's muted colour, not its size: a reason is part of the title, these are a note beside it. Give a step its `titleDetail` from its first render: setting or clearing it later moves the heading into or out of the title line, which remounts it (and drops its focus if it has it). A blank `titleDetail` throws a `RangeError`. Pass the `Step`s as direct children (a Fragment around several would share one number). A `Step` outside `Steps`, a Fragment child, a blank title or reason, an unknown status or heading level, `onEdit` without `editLabel`, or a blank status word throws a `RangeError`.
|
|
124
124
|
|
|
125
125
|
```tsx
|
|
126
126
|
<Steps aria-label="Heron survey">
|
package/dist/components/Box.d.ts
CHANGED
|
@@ -21,7 +21,10 @@ export type BoxProps = SpacingProps & VisibilityProps & ColumnSpanProps & HTMLAt
|
|
|
21
21
|
* `quiet` keeps the surrounding text's colour at weight 600 and
|
|
22
22
|
* underlines on hover and focus, for a title that opens something,
|
|
23
23
|
* such as a table row's. Weight is its non-colour cue, so use it in
|
|
24
|
-
* text lighter than 600.
|
|
24
|
+
* text lighter than 600. `inline` is a link inside a sentence: the
|
|
25
|
+
* accent colour, always underlined (the non-colour cue), the line
|
|
26
|
+
* stronger on hover and focus. Only for `as="a"`; an unknown value
|
|
27
|
+
* throws.
|
|
25
28
|
*/
|
|
26
29
|
link?: BoxLink;
|
|
27
30
|
/**
|
|
@@ -55,7 +58,10 @@ export declare const Box: import("react").ForwardRefExoticComponent<SpacingProps
|
|
|
55
58
|
* `quiet` keeps the surrounding text's colour at weight 600 and
|
|
56
59
|
* underlines on hover and focus, for a title that opens something,
|
|
57
60
|
* such as a table row's. Weight is its non-colour cue, so use it in
|
|
58
|
-
* text lighter than 600.
|
|
61
|
+
* text lighter than 600. `inline` is a link inside a sentence: the
|
|
62
|
+
* accent colour, always underlined (the non-colour cue), the line
|
|
63
|
+
* stronger on hover and focus. Only for `as="a"`; an unknown value
|
|
64
|
+
* throws.
|
|
59
65
|
*/
|
|
60
66
|
link?: BoxLink;
|
|
61
67
|
/**
|
|
@@ -3,8 +3,10 @@
|
|
|
3
3
|
* canvas link: the accent colour, no underline. `quiet` is a title that
|
|
4
4
|
* opens something, such as the title of a table row: the surrounding
|
|
5
5
|
* text's colour at weight 600, underlined while hovered or focused.
|
|
6
|
+
* `inline` is a link inside a sentence: the accent colour, always
|
|
7
|
+
* underlined.
|
|
6
8
|
*/
|
|
7
|
-
export declare const boxLinkAppearances: readonly ["accent", "quiet"];
|
|
9
|
+
export declare const boxLinkAppearances: readonly ["accent", "quiet", "inline"];
|
|
8
10
|
export type BoxLinkAppearance = (typeof boxLinkAppearances)[number];
|
|
9
11
|
/** The decorative new-tab mark after an external link's words. */
|
|
10
12
|
export declare const externalLinkMarkClass = "sw-link-external-mark";
|
package/dist/css/css-box-link.js
CHANGED
|
@@ -4,9 +4,18 @@ import { typographyVariants } from '@scalewing/tokens';
|
|
|
4
4
|
* canvas link: the accent colour, no underline. `quiet` is a title that
|
|
5
5
|
* opens something, such as the title of a table row: the surrounding
|
|
6
6
|
* text's colour at weight 600, underlined while hovered or focused.
|
|
7
|
+
* `inline` is a link inside a sentence: the accent colour, always
|
|
8
|
+
* underlined.
|
|
7
9
|
*/
|
|
8
|
-
export const boxLinkAppearances = ['accent', 'quiet'];
|
|
10
|
+
export const boxLinkAppearances = ['accent', 'quiet', 'inline'];
|
|
9
11
|
const quietLinkClass = 'sw-link-quiet';
|
|
12
|
+
const inlineLinkClass = 'sw-link-inline';
|
|
13
|
+
/** The generated class of each look; the canvas link has none. */
|
|
14
|
+
const boxLinkClasses = {
|
|
15
|
+
accent: undefined,
|
|
16
|
+
quiet: quietLinkClass,
|
|
17
|
+
inline: inlineLinkClass,
|
|
18
|
+
};
|
|
10
19
|
/** The decorative new-tab mark after an external link's words. */
|
|
11
20
|
export const externalLinkMarkClass = 'sw-link-external-mark';
|
|
12
21
|
export function assertBoxLink(link, as) {
|
|
@@ -19,7 +28,7 @@ export function assertBoxLink(link, as) {
|
|
|
19
28
|
}
|
|
20
29
|
/** The generated class for a Box `link` prop, or none for the canvas link. */
|
|
21
30
|
export function boxLinkClass(link) {
|
|
22
|
-
return link ===
|
|
31
|
+
return link === undefined ? undefined : boxLinkClasses[link];
|
|
23
32
|
}
|
|
24
33
|
/*
|
|
25
34
|
* A quiet link keeps the colour of the text around it, so colour cannot
|
|
@@ -35,6 +44,13 @@ export function boxLinkClass(link) {
|
|
|
35
44
|
* Forced colours paint it in the system link colour, as any link.
|
|
36
45
|
*/
|
|
37
46
|
export function cssBoxLinkClasses() {
|
|
47
|
+
return `${cssQuietLinkClasses()}
|
|
48
|
+
|
|
49
|
+
${cssInlineLinkClasses()}
|
|
50
|
+
|
|
51
|
+
${cssExternalLinkMarkClasses()}`;
|
|
52
|
+
}
|
|
53
|
+
function cssQuietLinkClasses() {
|
|
38
54
|
const quiet = `[data-theme] a.${quietLinkClass}`;
|
|
39
55
|
return `${quiet} {
|
|
40
56
|
color: inherit;
|
|
@@ -45,9 +61,36 @@ ${quiet}:hover,
|
|
|
45
61
|
${quiet}:focus-visible {
|
|
46
62
|
color: inherit;
|
|
47
63
|
text-decoration-line: underline;
|
|
64
|
+
}`;
|
|
65
|
+
}
|
|
66
|
+
/*
|
|
67
|
+
* An inline link sits in a sentence, among words in the text colour. Its
|
|
68
|
+
* accent alone may be under 3:1 against them (axe's link-in-text-block),
|
|
69
|
+
* so it is always underlined: the non-colour cue WCAG 1.4.1 asks for. The
|
|
70
|
+
* line is a hairline a little below the baseline in the accent at 60 %,
|
|
71
|
+
* as the inverse band's links; hover and keyboard focus draw it in the
|
|
72
|
+
* full accent at the focus ring's width, as a Markdown link's hover. The
|
|
73
|
+
* words stay in the accent while hovered, unlike the canvas link's hover.
|
|
74
|
+
* Focus keeps the canvas focus ring. The rules outrank the canvas
|
|
75
|
+
* `[data-theme] a` rules, hover included. Forced colours paint the words
|
|
76
|
+
* and the line in the system link colour, as any link.
|
|
77
|
+
*/
|
|
78
|
+
function cssInlineLinkClasses() {
|
|
79
|
+
const inline = `[data-theme] a.${inlineLinkClass}`;
|
|
80
|
+
return `${inline} {
|
|
81
|
+
color: var(--sw-color-accent);
|
|
82
|
+
text-decoration-color: color-mix(in srgb, currentColor 60%, transparent);
|
|
83
|
+
text-decoration-line: underline;
|
|
84
|
+
text-decoration-thickness: 1px;
|
|
85
|
+
text-underline-offset: 0.18em;
|
|
48
86
|
}
|
|
49
87
|
|
|
50
|
-
${
|
|
88
|
+
${inline}:hover,
|
|
89
|
+
${inline}:focus-visible {
|
|
90
|
+
color: var(--sw-color-accent);
|
|
91
|
+
text-decoration-color: currentColor;
|
|
92
|
+
text-decoration-thickness: var(--sw-focus-ring-width);
|
|
93
|
+
}`;
|
|
51
94
|
}
|
|
52
95
|
/*
|
|
53
96
|
* An external link's new-tab mark: an arrow to the inline end and up (↗),
|
|
@@ -85,5 +128,5 @@ ${mark}::after {
|
|
|
85
128
|
${mark}:dir(rtl) { transform: scaleX(-1); }`;
|
|
86
129
|
}
|
|
87
130
|
export function boxLinkClassCatalog() {
|
|
88
|
-
return [quietLinkClass, externalLinkMarkClass];
|
|
131
|
+
return [quietLinkClass, inlineLinkClass, externalLinkMarkClass];
|
|
89
132
|
}
|
package/dist/styles.css
CHANGED
|
@@ -671,6 +671,21 @@ body {
|
|
|
671
671
|
text-decoration-line: underline;
|
|
672
672
|
}
|
|
673
673
|
|
|
674
|
+
[data-theme] a.sw-link-inline {
|
|
675
|
+
color: var(--sw-color-accent);
|
|
676
|
+
text-decoration-color: color-mix(in srgb, currentColor 60%, transparent);
|
|
677
|
+
text-decoration-line: underline;
|
|
678
|
+
text-decoration-thickness: 1px;
|
|
679
|
+
text-underline-offset: 0.18em;
|
|
680
|
+
}
|
|
681
|
+
|
|
682
|
+
[data-theme] a.sw-link-inline:hover,
|
|
683
|
+
[data-theme] a.sw-link-inline:focus-visible {
|
|
684
|
+
color: var(--sw-color-accent);
|
|
685
|
+
text-decoration-color: currentColor;
|
|
686
|
+
text-decoration-thickness: var(--sw-focus-ring-width);
|
|
687
|
+
}
|
|
688
|
+
|
|
674
689
|
.sw-link-external-mark {
|
|
675
690
|
border-right: 2px solid currentColor;
|
|
676
691
|
border-top: 2px solid currentColor;
|