@grafctory/clay-widgets 0.0.0-stage → 0.4.1
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/LICENSE +201 -0
- package/README.md +46 -2
- package/dist/content/empty.css +107 -0
- package/dist/content/empty.d.ts +40 -0
- package/dist/content/empty.d.ts.map +1 -0
- package/dist/content/empty.js +42 -0
- package/dist/content/empty.js.map +1 -0
- package/dist/content/heading.css +34 -0
- package/dist/content/heading.d.ts +45 -0
- package/dist/content/heading.d.ts.map +1 -0
- package/dist/content/heading.js +49 -0
- package/dist/content/heading.js.map +1 -0
- package/dist/content/image.css +176 -0
- package/dist/content/image.d.ts +71 -0
- package/dist/content/image.d.ts.map +1 -0
- package/dist/content/image.js +63 -0
- package/dist/content/image.js.map +1 -0
- package/dist/content/infobox.css +186 -0
- package/dist/content/infobox.d.ts +72 -0
- package/dist/content/infobox.d.ts.map +1 -0
- package/dist/content/infobox.js +63 -0
- package/dist/content/infobox.js.map +1 -0
- package/dist/content/pill.css +76 -0
- package/dist/content/pill.d.ts +57 -0
- package/dist/content/pill.d.ts.map +1 -0
- package/dist/content/pill.js +48 -0
- package/dist/content/pill.js.map +1 -0
- package/dist/content/text.css +44 -0
- package/dist/content/text.d.ts +30 -0
- package/dist/content/text.d.ts.map +1 -0
- package/dist/content/text.js +42 -0
- package/dist/content/text.js.map +1 -0
- package/dist/controls/button.css +469 -0
- package/dist/controls/button.d.ts +116 -0
- package/dist/controls/button.d.ts.map +1 -0
- package/dist/controls/button.js +61 -0
- package/dist/controls/button.js.map +1 -0
- package/dist/controls/checkbox.css +23 -0
- package/dist/controls/checkbox.d.ts +54 -0
- package/dist/controls/checkbox.d.ts.map +1 -0
- package/dist/controls/checkbox.js +49 -0
- package/dist/controls/checkbox.js.map +1 -0
- package/dist/controls/choice.css +288 -0
- package/dist/controls/choice.d.ts +63 -0
- package/dist/controls/choice.d.ts.map +1 -0
- package/dist/controls/choice.js +52 -0
- package/dist/controls/choice.js.map +1 -0
- package/dist/controls/fieldset.css +37 -0
- package/dist/controls/fieldset.d.ts +49 -0
- package/dist/controls/fieldset.d.ts.map +1 -0
- package/dist/controls/fieldset.js +51 -0
- package/dist/controls/fieldset.js.map +1 -0
- package/dist/controls/form.css +50 -0
- package/dist/controls/form.d.ts +64 -0
- package/dist/controls/form.d.ts.map +1 -0
- package/dist/controls/form.js +62 -0
- package/dist/controls/form.js.map +1 -0
- package/dist/controls/input.css +57 -0
- package/dist/controls/input.d.ts +120 -0
- package/dist/controls/input.d.ts.map +1 -0
- package/dist/controls/input.js +78 -0
- package/dist/controls/input.js.map +1 -0
- package/dist/controls/label.css +73 -0
- package/dist/controls/label.d.ts +76 -0
- package/dist/controls/label.d.ts.map +1 -0
- package/dist/controls/label.js +73 -0
- package/dist/controls/label.js.map +1 -0
- package/dist/controls/radio.css +23 -0
- package/dist/controls/radio.d.ts +60 -0
- package/dist/controls/radio.d.ts.map +1 -0
- package/dist/controls/radio.js +50 -0
- package/dist/controls/radio.js.map +1 -0
- package/dist/controls/select.css +37 -0
- package/dist/controls/select.d.ts +62 -0
- package/dist/controls/select.d.ts.map +1 -0
- package/dist/controls/select.js +59 -0
- package/dist/controls/select.js.map +1 -0
- package/dist/controls/switch.css +154 -0
- package/dist/controls/switch.d.ts +44 -0
- package/dist/controls/switch.d.ts.map +1 -0
- package/dist/controls/switch.js +48 -0
- package/dist/controls/switch.js.map +1 -0
- package/dist/controls/textarea.css +50 -0
- package/dist/controls/textarea.d.ts +97 -0
- package/dist/controls/textarea.d.ts.map +1 -0
- package/dist/controls/textarea.js +75 -0
- package/dist/controls/textarea.js.map +1 -0
- package/dist/glyphs/icon.core.d.ts +52 -0
- package/dist/glyphs/icon.core.d.ts.map +1 -0
- package/dist/glyphs/icon.core.js +67 -0
- package/dist/glyphs/icon.core.js.map +1 -0
- package/dist/glyphs/icon.css +32 -0
- package/dist/glyphs/icon.d.ts +152 -0
- package/dist/glyphs/icon.d.ts.map +1 -0
- package/dist/glyphs/icon.js +167 -0
- package/dist/glyphs/icon.js.map +1 -0
- package/dist/glyphs/icon.md +76 -0
- package/dist/glyphs/logo.css +73 -0
- package/dist/glyphs/logo.d.ts +27 -0
- package/dist/glyphs/logo.d.ts.map +1 -0
- package/dist/glyphs/logo.js +49 -0
- package/dist/glyphs/logo.js.map +1 -0
- package/dist/index.d.ts +65 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +95 -0
- package/dist/index.js.map +1 -0
- package/dist/layouts/card.css +166 -0
- package/dist/layouts/card.d.ts +69 -0
- package/dist/layouts/card.d.ts.map +1 -0
- package/dist/layouts/card.js +57 -0
- package/dist/layouts/card.js.map +1 -0
- package/dist/layouts/stack.css +58 -0
- package/dist/layouts/stack.d.ts +64 -0
- package/dist/layouts/stack.d.ts.map +1 -0
- package/dist/layouts/stack.js +69 -0
- package/dist/layouts/stack.js.map +1 -0
- package/dist/layouts/strip.css +58 -0
- package/dist/layouts/strip.d.ts +72 -0
- package/dist/layouts/strip.d.ts.map +1 -0
- package/dist/layouts/strip.js +73 -0
- package/dist/layouts/strip.js.map +1 -0
- package/dist/layouts/tabs.core.d.ts +73 -0
- package/dist/layouts/tabs.core.d.ts.map +1 -0
- package/dist/layouts/tabs.core.js +65 -0
- package/dist/layouts/tabs.core.js.map +1 -0
- package/dist/layouts/tabs.css +260 -0
- package/dist/layouts/tabs.d.ts +57 -0
- package/dist/layouts/tabs.d.ts.map +1 -0
- package/dist/layouts/tabs.js +128 -0
- package/dist/layouts/tabs.js.map +1 -0
- package/dist/layouts/tree.css +138 -0
- package/dist/layouts/tree.d.ts +46 -0
- package/dist/layouts/tree.d.ts.map +1 -0
- package/dist/layouts/tree.js +69 -0
- package/dist/layouts/tree.js.map +1 -0
- package/dist/navigation/link.css +229 -0
- package/dist/navigation/link.d.ts +89 -0
- package/dist/navigation/link.d.ts.map +1 -0
- package/dist/navigation/link.js +91 -0
- package/dist/navigation/link.js.map +1 -0
- package/dist/navigation/path.css +122 -0
- package/dist/navigation/path.d.ts +42 -0
- package/dist/navigation/path.d.ts.map +1 -0
- package/dist/navigation/path.js +49 -0
- package/dist/navigation/path.js.map +1 -0
- package/dist/navigation/toc.core.d.ts +111 -0
- package/dist/navigation/toc.core.d.ts.map +1 -0
- package/dist/navigation/toc.core.js +60 -0
- package/dist/navigation/toc.core.js.map +1 -0
- package/dist/navigation/toc.css +53 -0
- package/dist/navigation/toc.d.ts +112 -0
- package/dist/navigation/toc.d.ts.map +1 -0
- package/dist/navigation/toc.js +321 -0
- package/dist/navigation/toc.js.map +1 -0
- package/dist/scopes/guard.css +26 -0
- package/dist/scopes/guard.d.ts +37 -0
- package/dist/scopes/guard.d.ts.map +1 -0
- package/dist/scopes/guard.js +60 -0
- package/dist/scopes/guard.js.map +1 -0
- package/dist/scopes/style.css +26 -0
- package/dist/scopes/style.d.ts +68 -0
- package/dist/scopes/style.d.ts.map +1 -0
- package/dist/scopes/style.js +108 -0
- package/dist/scopes/style.js.map +1 -0
- package/dist/shells/tool.css +778 -0
- package/dist/shells/tool.d.ts +164 -0
- package/dist/shells/tool.d.ts.map +1 -0
- package/dist/shells/tool.js +251 -0
- package/dist/shells/tool.js.map +1 -0
- package/dist/signals/more.css +42 -0
- package/dist/signals/more.d.ts +28 -0
- package/dist/signals/more.d.ts.map +1 -0
- package/dist/signals/more.js +61 -0
- package/dist/signals/more.js.map +1 -0
- package/dist/signals/note.css +221 -0
- package/dist/signals/note.d.ts +83 -0
- package/dist/signals/note.d.ts.map +1 -0
- package/dist/signals/note.js +72 -0
- package/dist/signals/note.js.map +1 -0
- package/dist/signals/toasts.css +463 -0
- package/dist/signals/toasts.d.ts +68 -0
- package/dist/signals/toasts.d.ts.map +1 -0
- package/dist/signals/toasts.js +160 -0
- package/dist/signals/toasts.js.map +1 -0
- package/package.json +331 -4
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import { jsx as _jsx } from "preact/jsx-runtime";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright © 2026 Metreeca srl
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
/**
|
|
18
|
+
* Tabbed panel.
|
|
19
|
+
*
|
|
20
|
+
* Presents a fixed set of labelled panels one at a time, under a strip of tabs the reader chooses from with the
|
|
21
|
+
* pointer or with the keyboard, or under a menu standing in for the strip where the labels would not fit.
|
|
22
|
+
*
|
|
23
|
+
* @module tabs
|
|
24
|
+
*/
|
|
25
|
+
import { useFocus } from "@grafctory/clay/focus";
|
|
26
|
+
import { useModel } from "@grafctory/clay/model";
|
|
27
|
+
import { opt } from "@grafctory/core";
|
|
28
|
+
import { createElement } from "preact";
|
|
29
|
+
import { useEffect, useId, useState } from "preact/hooks";
|
|
30
|
+
import { createTabs } from "./tabs.core.js";
|
|
31
|
+
import "./tabs.css";
|
|
32
|
+
/**
|
|
33
|
+
* Creates a tabbed layout panel.
|
|
34
|
+
*
|
|
35
|
+
* Presents the labels of the panels given, in order, and the content of the one currently chosen, starting from the
|
|
36
|
+
* first one on offer. A panel is chosen with the pointer or with the keyboard, the arrow keys stepping to either
|
|
37
|
+
* neighbour and wrapping at both ends, `Home` and `End` jumping to either end of the strip.
|
|
38
|
+
*
|
|
39
|
+
* A panel given no content is disabled: its label keeps its place, marked as such, but no gesture ever brings it on
|
|
40
|
+
* show, a pointer choice on its label being refused and keyboard steps and jumps between the labels passing it by.
|
|
41
|
+
*
|
|
42
|
+
* Where the labels would not fit on one line, the strip gives way to a menu offering the same choice under the same
|
|
43
|
+
* rules, worked with the keys the platform gives a menu of its own: the labels keep their order, a disabled one stays
|
|
44
|
+
* out of reach, and the panel on show carries on unchanged, named as before but presented as a plain region rather
|
|
45
|
+
* than as a tab panel. The strip comes back as soon as the labels fit again, so which of the two a reader meets
|
|
46
|
+
* follows the room the widget is given rather than anything the caller states.
|
|
47
|
+
*
|
|
48
|
+
* Every panel on offer stays in the document while another is on show, so what it holds keeps its state throughout,
|
|
49
|
+
* at the cost of being rendered whether or not it is visible. The panels are taken as they stand when the widget first
|
|
50
|
+
* renders: a label added or removed later leaves the strip unchanged.
|
|
51
|
+
*
|
|
52
|
+
* @param options The widget configuration
|
|
53
|
+
*
|
|
54
|
+
* @returns The tabbed panel
|
|
55
|
+
*
|
|
56
|
+
* @throws {@link !TypeError TypeError} If `panels` includes a blank label
|
|
57
|
+
*
|
|
58
|
+
* @see {@link https://www.w3.org/WAI/ARIA/apg/patterns/tabs/ ARIA Authoring Practices: Tabs Pattern}
|
|
59
|
+
*/
|
|
60
|
+
export function Tabs({ name, look, panels }) {
|
|
61
|
+
const id = useId();
|
|
62
|
+
const strip = `${id}-strip`;
|
|
63
|
+
const [collapsed, setCollapsed] = useState(false);
|
|
64
|
+
const { labels, active, select } = useModel(() => createTabs({
|
|
65
|
+
labels: Object.fromEntries(Object.entries(panels)
|
|
66
|
+
.map(([label, content]) => [label, content !== undefined]))
|
|
67
|
+
}));
|
|
68
|
+
const order = Object.keys(labels);
|
|
69
|
+
const enabled = order.filter(label => labels[label]);
|
|
70
|
+
const { tabIndex, onKeyDown } = useFocus({
|
|
71
|
+
wrap: true,
|
|
72
|
+
orientation: "horizontal",
|
|
73
|
+
items: enabled,
|
|
74
|
+
active,
|
|
75
|
+
identify: label => tab(order.indexOf(label)),
|
|
76
|
+
onMove: select
|
|
77
|
+
});
|
|
78
|
+
/*
|
|
79
|
+
* Whether the labels fit is settled by layout rather than by a measure of the window, so the strip is measured as
|
|
80
|
+
* it stands and watched for as long as the widget lives. It keeps its place in the document while the menu stands
|
|
81
|
+
* in for it, laid out at the width it would have had but taken off show, so the same measurement says when the
|
|
82
|
+
* labels fit again.
|
|
83
|
+
*/
|
|
84
|
+
useEffect(() => opt(document.getElementById(strip) ?? undefined, element => {
|
|
85
|
+
const observer = new ResizeObserver(() => setCollapsed(element.scrollWidth > element.clientWidth));
|
|
86
|
+
observer.observe(element);
|
|
87
|
+
return () => observer.disconnect();
|
|
88
|
+
}), [strip]);
|
|
89
|
+
/*
|
|
90
|
+
* A look the consumer leaves out leaves the attribute off the element, which is what lets the stylesheet tell
|
|
91
|
+
* tabs asking for the ordinary step from ones taking whatever look the area around them assigns.
|
|
92
|
+
*/
|
|
93
|
+
return createElement("clay-tabs", { collapsed, look }, _jsx("nav", { "aria-label": name, id: strip, role: "tablist", onKeyDown: onKeyDown, children: order.map((label, index) => _jsx("label", { "aria-controls": labels[label] ? panel(index) : undefined, "aria-disabled": !labels[label], "aria-selected": label === active, id: tab(index), role: "tab", tabIndex: tabIndex(label), onClick: () => select(label), children: label }, label)) }),
|
|
94
|
+
/*
|
|
95
|
+
* The menu offers the choice the strip did, the platform supplying the keys and the focus a strip owes by
|
|
96
|
+
* hand. It stands as wide as its labels rather than as wide as the bar, so the ring a platform leaves on it
|
|
97
|
+
* after a choice wraps the control alone; the bar it stands in carries the rule closing it off, which the
|
|
98
|
+
* strip carried while the strip stood there.
|
|
99
|
+
*
|
|
100
|
+
* The ring the menu keeps after a pointer choice is the platform's own verdict, which a menu earns by taking
|
|
101
|
+
* the arrow keys next: a tab, which takes none of its own, is left unmarked by the same gesture. The widget
|
|
102
|
+
* states neither, both being settled by `:focus-visible`.
|
|
103
|
+
*/
|
|
104
|
+
collapsed && _jsx("span", { children: _jsx("select", { "aria-label": name, value: active, onChange: event => select(event.currentTarget.value), children: order.map(label => _jsx("option", { disabled: !labels[label], value: label, children: label }, label)) }) }),
|
|
105
|
+
// every enabled panel is rendered, so the tab controlling it always has something to point at
|
|
106
|
+
order.map((label, index) => !labels[label] ? null :
|
|
107
|
+
_jsx("div", { hidden: label !== active, "aria-labelledby": tab(index), id: panel(index),
|
|
108
|
+
/*
|
|
109
|
+
* A tab panel promises the strip that chose it, which the menu leaves off show, so what the reader
|
|
110
|
+
* meets then is a named area of the screen instead. The name stands either way: a tab taken off show
|
|
111
|
+
* still names what it points at.
|
|
112
|
+
*
|
|
113
|
+
* The panel takes no stop of its own: a stop is owed only by a panel holding nothing focusable, which
|
|
114
|
+
* a widget handed arbitrary content cannot tell without walking the DOM, and one taken where the
|
|
115
|
+
* content is reachable already lands the reader on the whole area on the way past. What a stop would
|
|
116
|
+
* have been good for, scrolling a panel by key, the browser hands to whichever box actually scrolls and
|
|
117
|
+
* holds nothing focusable: inside a shell, the body of the main column rather than the panel within it.
|
|
118
|
+
*/
|
|
119
|
+
role: collapsed ? "region" : "tabpanel", children: panels[label] }, label)));
|
|
120
|
+
// ids are built on the position of a panel, a label being free to carry the spaces an id reference cannot
|
|
121
|
+
function tab(index) {
|
|
122
|
+
return `${id}-tab-${index}`;
|
|
123
|
+
}
|
|
124
|
+
function panel(index) {
|
|
125
|
+
return `${id}-panel-${index}`;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
//# sourceMappingURL=tabs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tabs.js","sourceRoot":"","sources":["../../src/layouts/tabs.tsx"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright © 2020-2026 EC2U Alliance
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
/*
|
|
18
|
+
* A tree node is a header, holding the toggle beside the label, above the nested nodes, which are indented
|
|
19
|
+
* under the label so the depth of each node reads off its position at a glance, however deep the tree runs.
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
clay-tree {
|
|
23
|
+
|
|
24
|
+
display: flex;
|
|
25
|
+
flex-direction: column;
|
|
26
|
+
align-items: stretch;
|
|
27
|
+
|
|
28
|
+
/* An open node is set apart from the sibling below it, so its subtree reads as one block. */
|
|
29
|
+
|
|
30
|
+
&[expanded]:not(:last-child) {
|
|
31
|
+
margin-bottom: var(--skin--spacing-025);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
& > header {
|
|
35
|
+
|
|
36
|
+
display: flex;
|
|
37
|
+
flex-direction: row;
|
|
38
|
+
align-items: center;
|
|
39
|
+
gap: var(--skin--spacing-025);
|
|
40
|
+
|
|
41
|
+
/*
|
|
42
|
+
* The toggle keeps the quiet look of a control set in running text: no rule around it, so a column of toggles
|
|
43
|
+
* reads as marks beside the labels rather than as a stack of boxes. The fill closes tight on the glyph, with
|
|
44
|
+
* just enough air to keep the label clear of it under the pointer. The box falls short of the minimum pointer
|
|
45
|
+
* target, which the rows meet through spacing instead: the label pads each row so that no two toggles stand
|
|
46
|
+
* closer than that minimum, nor close enough to a link in a label for a press to land on the wrong one.
|
|
47
|
+
*
|
|
48
|
+
* A live toggle is drawn as a subtle button is: the glyph in the subtle accent on no fill, at 10.01:1 on the
|
|
49
|
+
* light page and 7.93:1 on the dark one, and a neutral fill under the pointer and the press, as on any surface.
|
|
50
|
+
*/
|
|
51
|
+
|
|
52
|
+
& > button {
|
|
53
|
+
|
|
54
|
+
justify-content: center;
|
|
55
|
+
|
|
56
|
+
min-width: var(--skin--scaling-125);
|
|
57
|
+
min-height: var(--skin--scaling-125);
|
|
58
|
+
|
|
59
|
+
padding: var(--skin--spacing-010);
|
|
60
|
+
|
|
61
|
+
border-style: none;
|
|
62
|
+
|
|
63
|
+
/*
|
|
64
|
+
* The reset hands every box the colour of the one around it, so the glyph would take the hover fill again
|
|
65
|
+
* and stand in a darker square on it: left unpainted, it lets the fill lie once across the whole toggle.
|
|
66
|
+
*/
|
|
67
|
+
|
|
68
|
+
& > * {
|
|
69
|
+
background-color: transparent;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
&:enabled {
|
|
73
|
+
|
|
74
|
+
color: var(--skin--color-subtle);
|
|
75
|
+
background-color: transparent;
|
|
76
|
+
|
|
77
|
+
&:hover {
|
|
78
|
+
background-color: var(--skin--background-color-hover-neutral);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
&:active {
|
|
82
|
+
background-color: var(--skin--background-color-pressed-neutral);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/*
|
|
88
|
+
* A leaf marks the room of its toggle with a quiet dot, so the column of marks runs unbroken past leaves
|
|
89
|
+
* and branches alike, and each label reads as a sibling of the labels beside it.
|
|
90
|
+
*/
|
|
91
|
+
|
|
92
|
+
&:disabled::before {
|
|
93
|
+
content: "";
|
|
94
|
+
width: var(--skin--scaling-025);
|
|
95
|
+
height: var(--skin--scaling-025);
|
|
96
|
+
border-radius: 50%;
|
|
97
|
+
background-color: var(--skin--color-disabled);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/*
|
|
103
|
+
* The label alone sets the baseline of the node, so a tree lines up with text it is baseline-aligned with,
|
|
104
|
+
* rather than with the bottom edge of the toggle; padded to the toggle floor, it stays centred beside it.
|
|
105
|
+
*/
|
|
106
|
+
|
|
107
|
+
& > span {
|
|
108
|
+
|
|
109
|
+
align-self: baseline;
|
|
110
|
+
padding-block: calc((var(--skin--scaling-150) - 1lh) / 2);
|
|
111
|
+
|
|
112
|
+
flex-grow: 1;
|
|
113
|
+
min-width: 0;
|
|
114
|
+
overflow-wrap: anywhere;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/*
|
|
120
|
+
* A leaf keeps the room of a toggle so its label lines up with those of the branches beside it. A top level made
|
|
121
|
+
* of leaves alone has no branch to line up with, so its labels sit flush with the content around the tree.
|
|
122
|
+
*/
|
|
123
|
+
|
|
124
|
+
:not(clay-tree > section):not(:has(> clay-tree > header > button:enabled)) > & > header > button:disabled {
|
|
125
|
+
display: none;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
& > section {
|
|
129
|
+
|
|
130
|
+
display: flex;
|
|
131
|
+
flex-direction: column;
|
|
132
|
+
align-items: stretch;
|
|
133
|
+
|
|
134
|
+
margin-left: var(--skin--spacing-100);
|
|
135
|
+
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { type ComponentChildren } from "preact";
|
|
2
|
+
import "./tree.css";
|
|
3
|
+
/**
|
|
4
|
+
* Creates a tree node.
|
|
5
|
+
*
|
|
6
|
+
* Shows a label beside a toggle that unfolds the nested nodes below it, indented under the label so the depth of each
|
|
7
|
+
* node reads off its position. A tree is built by nesting nodes as children, each unfolding on its own. A top level
|
|
8
|
+
* made of leaves alone sets its labels flush with the content around the tree, so a flat list reads unindented.
|
|
9
|
+
*
|
|
10
|
+
* Nested nodes are rendered only while the node is expanded, so a subtree fetching its own content does so only once
|
|
11
|
+
* the reader opens it. Collapsing a node discards the state of the nodes below it, so on unfolding again each of
|
|
12
|
+
* them starts as its own `expanded` option states, whatever it was showing before.
|
|
13
|
+
*
|
|
14
|
+
* The toggle is a disclosure button: assistive technologies name it after the label and announce whether the node is
|
|
15
|
+
* expanded. The nested nodes form a group named after the label too, so a screen reader entering them hears which
|
|
16
|
+
* branch they belong to. A node with no nested nodes is a leaf: it draws a quiet dot in place of the toggle, and
|
|
17
|
+
* assistive technologies meet its label alone, with no control beside it to take the focus or announce a state.
|
|
18
|
+
*
|
|
19
|
+
* The nodes do not form an ARIA tree, so arrow keys move nothing. Each toggle is a tab stop reached in reading order
|
|
20
|
+
* like any other control on the page, so every branch on show adds a stop to the tab sequence of the page.
|
|
21
|
+
*
|
|
22
|
+
* @param options The widget configuration
|
|
23
|
+
*
|
|
24
|
+
* @returns The tree node
|
|
25
|
+
*
|
|
26
|
+
* @see {@link https://www.w3.org/WAI/ARIA/apg/patterns/disclosure/ ARIA Authoring Practices: Disclosure Pattern}
|
|
27
|
+
*/
|
|
28
|
+
export declare function Tree({ expanded, label, children }: {
|
|
29
|
+
/**
|
|
30
|
+
* Whether the node starts expanded; collapsed if omitted. Read on the first render alone, so changing it later
|
|
31
|
+
* leaves a node already on the page expanded or collapsed as the reader left it.
|
|
32
|
+
*/
|
|
33
|
+
expanded?: boolean;
|
|
34
|
+
/**
|
|
35
|
+
* The content naming the node, its toggle and its nested nodes, wrapping past its room rather than being clipped.
|
|
36
|
+
* Its text is what assistive technologies announce, so a label drawn as a glyph alone leaves the toggle unnamed.
|
|
37
|
+
*/
|
|
38
|
+
label: ComponentChildren;
|
|
39
|
+
/**
|
|
40
|
+
* The nested nodes, shown below the label while the node is expanded; a leaf if omitted.
|
|
41
|
+
*/
|
|
42
|
+
children?: ComponentChildren;
|
|
43
|
+
}): import("preact").VNode<{
|
|
44
|
+
expanded: boolean;
|
|
45
|
+
}>;
|
|
46
|
+
//# sourceMappingURL=tree.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tree.d.ts","sourceRoot":"","sources":["../../src/layouts/tree.tsx"],"names":[],"mappings":"AA2BA,OAAO,EAAE,KAAK,iBAAiB,EAAiB,MAAM,QAAQ,CAAC;AAI/D,OAAO,YAAY,CAAC;AAGpB;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,IAAI,CAAC,EAEpB,QAAgB,EAEhB,KAAK,EAEL,QAAQ,EAER,EAAE;IAEF;;;OAGG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAA;IAElB;;;OAGG;IACH,KAAK,EAAE,iBAAiB,CAAA;IAExB;;OAEG;IACH,QAAQ,CAAC,EAAE,iBAAiB,CAAA;CAE5B;;GA2CA"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "preact/jsx-runtime";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright © 2020-2026 EC2U Alliance
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
/**
|
|
18
|
+
* Collapsible hierarchy.
|
|
19
|
+
*
|
|
20
|
+
* Lays out items nested under one another as an outline the reader unfolds one level at a time, so a deep hierarchy
|
|
21
|
+
* opens on its top level and shows only the branches the reader asks for, however large the whole of it grows.
|
|
22
|
+
*
|
|
23
|
+
* @module tree
|
|
24
|
+
*/
|
|
25
|
+
import { useModel } from "@grafctory/clay/model";
|
|
26
|
+
import { createState } from "@grafctory/core/state";
|
|
27
|
+
import { createElement } from "preact";
|
|
28
|
+
import { useId } from "preact/hooks";
|
|
29
|
+
import { Icon } from "../glyphs/icon.js";
|
|
30
|
+
import { isContent } from "../index.js";
|
|
31
|
+
import "./tree.css";
|
|
32
|
+
/**
|
|
33
|
+
* Creates a tree node.
|
|
34
|
+
*
|
|
35
|
+
* Shows a label beside a toggle that unfolds the nested nodes below it, indented under the label so the depth of each
|
|
36
|
+
* node reads off its position. A tree is built by nesting nodes as children, each unfolding on its own. A top level
|
|
37
|
+
* made of leaves alone sets its labels flush with the content around the tree, so a flat list reads unindented.
|
|
38
|
+
*
|
|
39
|
+
* Nested nodes are rendered only while the node is expanded, so a subtree fetching its own content does so only once
|
|
40
|
+
* the reader opens it. Collapsing a node discards the state of the nodes below it, so on unfolding again each of
|
|
41
|
+
* them starts as its own `expanded` option states, whatever it was showing before.
|
|
42
|
+
*
|
|
43
|
+
* The toggle is a disclosure button: assistive technologies name it after the label and announce whether the node is
|
|
44
|
+
* expanded. The nested nodes form a group named after the label too, so a screen reader entering them hears which
|
|
45
|
+
* branch they belong to. A node with no nested nodes is a leaf: it draws a quiet dot in place of the toggle, and
|
|
46
|
+
* assistive technologies meet its label alone, with no control beside it to take the focus or announce a state.
|
|
47
|
+
*
|
|
48
|
+
* The nodes do not form an ARIA tree, so arrow keys move nothing. Each toggle is a tab stop reached in reading order
|
|
49
|
+
* like any other control on the page, so every branch on show adds a stop to the tab sequence of the page.
|
|
50
|
+
*
|
|
51
|
+
* @param options The widget configuration
|
|
52
|
+
*
|
|
53
|
+
* @returns The tree node
|
|
54
|
+
*
|
|
55
|
+
* @see {@link https://www.w3.org/WAI/ARIA/apg/patterns/disclosure/ ARIA Authoring Practices: Disclosure Pattern}
|
|
56
|
+
*/
|
|
57
|
+
export function Tree({ expanded = false, label, children }) {
|
|
58
|
+
const id = useId();
|
|
59
|
+
const branch = isContent(children);
|
|
60
|
+
const { open, toggle } = useModel(() => createState({
|
|
61
|
+
open: expanded,
|
|
62
|
+
toggle() {
|
|
63
|
+
return { open: !this.open };
|
|
64
|
+
}
|
|
65
|
+
}));
|
|
66
|
+
const unfolded = branch && open;
|
|
67
|
+
return createElement("clay-tree", { expanded: unfolded }, _jsxs(_Fragment, { children: [_jsxs("header", { children: [_jsx("button", { type: "button", disabled: !branch, "aria-hidden": branch ? undefined : true, "aria-labelledby": branch ? id : undefined, "aria-expanded": branch ? unfolded : undefined, onClick: toggle, children: branch && (unfolded ? _jsx(Icon.Collapse, {}) : _jsx(Icon.Expand, {})) }), _jsx("span", { id: id, children: label })] }), unfolded && _jsx("section", { role: "group", "aria-labelledby": id, children: children })] }));
|
|
68
|
+
}
|
|
69
|
+
//# sourceMappingURL=tree.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tree.js","sourceRoot":"","sources":["../../src/layouts/tree.tsx"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;AAEH;;;;;;;GAOG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AACjD,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAA0B,aAAa,EAAE,MAAM,QAAQ,CAAC;AAC/D,OAAO,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AACrC,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AACzC,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,YAAY,CAAC;AAGpB;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,MAAM,UAAU,IAAI,CAAC,EAEpB,QAAQ,GAAG,KAAK,EAEhB,KAAK,EAEL,QAAQ,EAqBR;IAEA,MAAM,EAAE,GAAG,KAAK,EAAE,CAAC;IAEnB,MAAM,MAAM,GAAG,SAAS,CAAC,QAAQ,CAAC,CAAC;IAEnC,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,QAAQ,CAAC,GAAG,EAAE,CAAC,WAAW,CAAO;QAEzD,IAAI,EAAE,QAAQ;QAEd,MAAM;YACL,OAAO,EAAE,IAAI,EAAE,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC;QAC7B,CAAC;KAED,CAAC,CAAC,CAAC;IAEJ,MAAM,QAAQ,GAAG,MAAM,IAAI,IAAI,CAAC;IAGhC,OAAO,aAAa,CAAC,WAAW,EAAE,EAAE,QAAQ,EAAE,QAAQ,EAAE,EAAE,8BAEzD,6BAEC,iBAAQ,IAAI,EAAC,QAAQ,EAAC,QAAQ,EAAE,CAAC,MAAM,iBAEzB,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,qBACrB,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,SAAS,mBACzB,MAAM,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAS,EAE5C,OAAO,EAAE,MAAM,YAEd,MAAM,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,KAAC,IAAI,CAAC,QAAQ,KAAE,CAAC,CAAC,CAAC,KAAC,IAAI,CAAC,MAAM,KAAE,CAAC,GAAU,EAEpE,eAAM,EAAE,EAAE,EAAE,YAAG,KAAK,GAAQ,IAEpB,EAIR,QAAQ,IAAI,kBAAS,IAAI,EAAC,OAAO,qBAAkB,EAAE,YAAG,QAAQ,GAAW,IAE1E,CAAC,CAAC;AAEN,CAAC"}
|
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright © 2026 Metreeca srl
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
/*
|
|
18
|
+
* A link starts from the colour, the hover colour and the focus mark the design system gives any anchor, and this
|
|
19
|
+
* sheet says how loud it appears on top of that. Every step keeps the face and size of the text around it, and holds
|
|
20
|
+
* its colour through the press. The ordinary step is underlined, so it is told from that text wherever colour fails.
|
|
21
|
+
*/
|
|
22
|
+
|
|
23
|
+
/* The look of a link stating none, which an area assigns to every link it holds. */
|
|
24
|
+
|
|
25
|
+
@property --clay-link-look {
|
|
26
|
+
syntax: "subtle | normal | strong";
|
|
27
|
+
inherits: true;
|
|
28
|
+
initial-value: normal;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/*
|
|
32
|
+
* How far the hover fill of a glyph standing alone reaches past it, and the focus mark with it. Registered without a
|
|
33
|
+
* type, so a value stated in `em` resolves on the link it reaches rather than on the element declaring it.
|
|
34
|
+
*/
|
|
35
|
+
|
|
36
|
+
@property --clay-link-inset {
|
|
37
|
+
syntax: "*";
|
|
38
|
+
inherits: true;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
clay-link {
|
|
42
|
+
|
|
43
|
+
display: inline-flex;
|
|
44
|
+
|
|
45
|
+
/*
|
|
46
|
+
* A logo or an icon in the link is centred on its wording, without stretching the line the link stands in, and
|
|
47
|
+
* kept apart from it by a gap wider than a space, so the glyph reads as a mark set beside the words it leads.
|
|
48
|
+
*
|
|
49
|
+
* A link short of room cuts its wording short with an ellipsis, wherever the area around it caps its width and
|
|
50
|
+
* keeps it to one line. Logos and icons beside the wording are left whole, however little room remains.
|
|
51
|
+
*/
|
|
52
|
+
|
|
53
|
+
& > a {
|
|
54
|
+
|
|
55
|
+
display: inline-flex;
|
|
56
|
+
align-items: center;
|
|
57
|
+
column-gap: var(--skin--spacing-050);
|
|
58
|
+
min-width: 0;
|
|
59
|
+
|
|
60
|
+
font-weight: inherit;
|
|
61
|
+
text-decoration-line: underline;
|
|
62
|
+
|
|
63
|
+
/*
|
|
64
|
+
* The underline is drawn a little below the baseline, within the line rather than below the descenders, so a
|
|
65
|
+
* container clipping its content at the edge of the line never cuts it off. The descenders it crosses break it.
|
|
66
|
+
*/
|
|
67
|
+
|
|
68
|
+
text-underline-offset: 0.15em;
|
|
69
|
+
|
|
70
|
+
/* The wording is clipped across the line only, keeping the underline whatever the line height. */
|
|
71
|
+
|
|
72
|
+
& > span {
|
|
73
|
+
min-width: 0;
|
|
74
|
+
overflow-x: clip;
|
|
75
|
+
text-overflow: ellipsis;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/*
|
|
79
|
+
* A glyph standing alone carries no text for the underline to be drawn under, and its strokes are too thin for
|
|
80
|
+
* the hover colour alone to be seen, so the pointer lays the neutral hover fill of a control across it instead,
|
|
81
|
+
* rounded as the focus mark is. Wording always sits in a span of its own, so a link lacking one holds a glyph.
|
|
82
|
+
*/
|
|
83
|
+
|
|
84
|
+
&:not(:has(> span)) {
|
|
85
|
+
|
|
86
|
+
border-radius: var(--skin--border-radius-025);
|
|
87
|
+
|
|
88
|
+
/*
|
|
89
|
+
* The reset hands every box the colour of the one around it, which the translucent fill would turn into a
|
|
90
|
+
* second coat on the glyph, so what the link carries is left unpainted and the fill is laid once.
|
|
91
|
+
*/
|
|
92
|
+
|
|
93
|
+
& > * {
|
|
94
|
+
background-color: transparent;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/*
|
|
98
|
+
* The fill reaches past the glyph by the inset as a spread shadow, which paints only outside the box and
|
|
99
|
+
* takes no room, so the lines and rows around the link never move as the pointer crosses it.
|
|
100
|
+
*/
|
|
101
|
+
|
|
102
|
+
&:hover {
|
|
103
|
+
background-color: var(--skin--background-color-hover-neutral);
|
|
104
|
+
box-shadow: 0 0 0 var(--clay-link-inset, var(--skin--spacing-025)) var(--skin--background-color-hover-neutral);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/*
|
|
108
|
+
* The focus mark the design system draws a hair off the text would close on the glyph and cut across the
|
|
109
|
+
* fill, so it is set off by the reach of the fill instead, wrapping the glyph and the fill around it alike.
|
|
110
|
+
*/
|
|
111
|
+
|
|
112
|
+
&:focus-visible {
|
|
113
|
+
outline-offset: var(--clay-link-inset, var(--skin--spacing-025));
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/* The quiet step reads as the text around it until the pointer adds the hover colour and the underline. */
|
|
121
|
+
|
|
122
|
+
&[look="subtle"] > a {
|
|
123
|
+
|
|
124
|
+
color: inherit;
|
|
125
|
+
text-decoration-line: none;
|
|
126
|
+
|
|
127
|
+
&:hover {
|
|
128
|
+
color: var(--skin--color-link-hover);
|
|
129
|
+
text-decoration-line: underline;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
/* The loud step is strong in the link colour, underlined only under the pointer. */
|
|
135
|
+
|
|
136
|
+
&[look="strong"] > a {
|
|
137
|
+
|
|
138
|
+
font-weight: var(--skin--font-weight-strong);
|
|
139
|
+
text-decoration-line: none;
|
|
140
|
+
|
|
141
|
+
&:hover {
|
|
142
|
+
text-decoration-line: underline;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
/*
|
|
148
|
+
* Links stating no look of their own take the one the area around them sets, read off the `--clay-link-look`
|
|
149
|
+
* knob through a style query: a rule has no other way to branch on a value, and the knob inherits, so every
|
|
150
|
+
* widget sits inside a container answering for it without a rule declaring one. The attribute has to be absent
|
|
151
|
+
* for the container to have a say, which is why the widget renders it only where the consumer asked for a look,
|
|
152
|
+
* and why each rule here holds itself to links carrying none, leaving a stated look to the rules above.
|
|
153
|
+
*
|
|
154
|
+
* Only the quiet and the loud steps are restated, the ordinary one being what the rules above already draw. The
|
|
155
|
+
* declarations are the ones the attribute rules carry, restated rather than shared: a style query is a conditional
|
|
156
|
+
* group and takes rules of its own, so the two forms of the same step cannot be written as one selector.
|
|
157
|
+
*/
|
|
158
|
+
|
|
159
|
+
@container style(--clay-link-look: subtle) {
|
|
160
|
+
|
|
161
|
+
&:not([look]) > a {
|
|
162
|
+
|
|
163
|
+
color: inherit;
|
|
164
|
+
text-decoration-line: none;
|
|
165
|
+
|
|
166
|
+
&:hover {
|
|
167
|
+
color: var(--skin--color-link-hover);
|
|
168
|
+
text-decoration-line: underline;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
@container style(--clay-link-look: strong) {
|
|
176
|
+
|
|
177
|
+
&:not([look]) > a {
|
|
178
|
+
|
|
179
|
+
font-weight: var(--skin--font-weight-strong);
|
|
180
|
+
text-decoration-line: none;
|
|
181
|
+
|
|
182
|
+
&:hover {
|
|
183
|
+
text-decoration-line: underline;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
/*
|
|
191
|
+
* The current entry is marked by a heavy rule in the accent colour, as the chosen tab is, whatever the look: the
|
|
192
|
+
* ink is left as the look sets it, so the mark alone says where the reader stands. It comes after the looks, which
|
|
193
|
+
* it matches with equal specificity, so that it outlasts a look dropping the underline. Under the pointer, the mark
|
|
194
|
+
* takes the hover colour of the wording just as every other underline in a link does.
|
|
195
|
+
*/
|
|
196
|
+
|
|
197
|
+
& > a[active] {
|
|
198
|
+
|
|
199
|
+
text-decoration-line: underline;
|
|
200
|
+
text-decoration-color: var(--skin--color-strong);
|
|
201
|
+
text-decoration-thickness: calc(3 * var(--skin--border-width));
|
|
202
|
+
|
|
203
|
+
&:hover {
|
|
204
|
+
text-decoration-color: currentColor;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
/*
|
|
210
|
+
* The quiet step keeps the mark as quiet as the link, thinner but drawn at the ordinary gap below the text. Both
|
|
211
|
+
* forms of the step are restated, as for the looks above: the attribute stated on the link, and the look the area
|
|
212
|
+
* around it assigns, read through a style query that takes rules of its own and shares no selector with the other.
|
|
213
|
+
*/
|
|
214
|
+
|
|
215
|
+
&[look="subtle"] > a[active] {
|
|
216
|
+
text-decoration-thickness: calc(2 * var(--skin--border-width));
|
|
217
|
+
text-underline-offset: 0.15em; /* The ordinary gap below the baseline, clear of the text it marks. */
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
@container style(--clay-link-look: subtle) {
|
|
221
|
+
|
|
222
|
+
&:not([look]) > a[active] {
|
|
223
|
+
text-decoration-thickness: calc(2 * var(--skin--border-width));
|
|
224
|
+
text-underline-offset: 0.15em; /* The ordinary gap below the baseline, clear of the text it marks. */
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
}
|