baseline-foundry 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +588 -0
- package/config/experiments/ibm-plex-engine-smoke.json +115 -0
- package/config/experiments/ubuntu-engine-smoke.json +115 -0
- package/config/foundation-theme.json +117 -0
- package/config/tiers/app.json +120 -0
- package/config/tiers/documentation.json +120 -0
- package/config/tiers/editorial.json +120 -0
- package/config/tiers/os.json +120 -0
- package/dist/accordion.d.ts +5 -0
- package/dist/accordion.js +32 -0
- package/dist/application-layout.d.ts +4 -0
- package/dist/application-layout.js +181 -0
- package/dist/baseline-grid-overlay.d.ts +5 -0
- package/dist/baseline-grid-overlay.js +50 -0
- package/dist/baseline-grid-theme.d.ts +3 -0
- package/dist/baseline-grid-theme.js +3 -0
- package/dist/baseline-grid.d.ts +7 -0
- package/dist/baseline-grid.js +35 -0
- package/dist/build.d.ts +21 -0
- package/dist/build.js +440 -0
- package/dist/code-snippet.d.ts +6 -0
- package/dist/code-snippet.js +95 -0
- package/dist/contextual-menu.d.ts +4 -0
- package/dist/contextual-menu.js +156 -0
- package/dist/css-app-tier.d.ts +1 -0
- package/dist/css-app-tier.js +77 -0
- package/dist/css-components/article-pagination.d.ts +13 -0
- package/dist/css-components/article-pagination.js +151 -0
- package/dist/css-components/button-actions.d.ts +7 -0
- package/dist/css-components/button-actions.js +165 -0
- package/dist/css-components/cards-options.d.ts +6 -0
- package/dist/css-components/cards-options.js +180 -0
- package/dist/css-components/chip-badge-status.d.ts +10 -0
- package/dist/css-components/chip-badge-status.js +162 -0
- package/dist/css-components/content-card.d.ts +25 -0
- package/dist/css-components/content-card.js +517 -0
- package/dist/css-components/control-row.d.ts +2 -0
- package/dist/css-components/control-row.js +18 -0
- package/dist/css-components/cta-figure-aspect.d.ts +1 -0
- package/dist/css-components/cta-figure-aspect.js +123 -0
- package/dist/css-components/document-navigation.d.ts +13 -0
- package/dist/css-components/document-navigation.js +400 -0
- package/dist/css-components/editorial-content.d.ts +6 -0
- package/dist/css-components/editorial-content.js +52 -0
- package/dist/css-components/icon.d.ts +1 -0
- package/dist/css-components/icon.js +75 -0
- package/dist/css-components/interactive-feedback.d.ts +2 -0
- package/dist/css-components/interactive-feedback.js +230 -0
- package/dist/css-components/interactive-tables.d.ts +7 -0
- package/dist/css-components/interactive-tables.js +164 -0
- package/dist/css-components/linked-logo-site-layout.d.ts +21 -0
- package/dist/css-components/linked-logo-site-layout.js +214 -0
- package/dist/css-components/list-tree.d.ts +5 -0
- package/dist/css-components/list-tree.js +98 -0
- package/dist/css-components/list.d.ts +3 -0
- package/dist/css-components/list.js +119 -0
- package/dist/css-components/logo-media.d.ts +16 -0
- package/dist/css-components/logo-media.js +219 -0
- package/dist/css-components/navigation-layout.d.ts +5 -0
- package/dist/css-components/navigation-layout.js +151 -0
- package/dist/css-components/panel.d.ts +6 -0
- package/dist/css-components/panel.js +148 -0
- package/dist/css-components/search-box-and-filter.d.ts +9 -0
- package/dist/css-components/search-box-and-filter.js +267 -0
- package/dist/css-components/sites-editorial-ports.d.ts +19 -0
- package/dist/css-components/sites-editorial-ports.js +264 -0
- package/dist/css-components/sites-foundation.d.ts +17 -0
- package/dist/css-components/sites-foundation.js +173 -0
- package/dist/css-components/sites-rich-lists.d.ts +18 -0
- package/dist/css-components/sites-rich-lists.js +364 -0
- package/dist/css-components/static-content-ports.d.ts +14 -0
- package/dist/css-components/static-content-ports.js +206 -0
- package/dist/css-components/tab-section.d.ts +19 -0
- package/dist/css-components/tab-section.js +103 -0
- package/dist/css-components/table.d.ts +7 -0
- package/dist/css-components/table.js +79 -0
- package/dist/css-components/tabs-choice-breadcrumbs.d.ts +9 -0
- package/dist/css-components/tabs-choice-breadcrumbs.js +307 -0
- package/dist/css-components/tiered-list-equal-height-row.d.ts +1 -0
- package/dist/css-components/tiered-list-equal-height-row.js +286 -0
- package/dist/css-components.d.ts +2 -0
- package/dist/css-components.js +2701 -0
- package/dist/css-grid.d.ts +1 -0
- package/dist/css-grid.js +179 -0
- package/dist/css.d.ts +6 -0
- package/dist/css.js +431 -0
- package/dist/experiments/ibm-plex-engine-smoke/styles.css +8969 -0
- package/dist/experiments/ibm-plex-engine-smoke/surfaces.json +604 -0
- package/dist/experiments/ibm-plex-engine-smoke/tokens.json +217 -0
- package/dist/in-page-navigation.d.ts +7 -0
- package/dist/in-page-navigation.js +136 -0
- package/dist/index.d.ts +37 -0
- package/dist/index.js +18 -0
- package/dist/interactive-feedback.d.ts +14 -0
- package/dist/interactive-feedback.js +96 -0
- package/dist/interactive-tables.d.ts +28 -0
- package/dist/interactive-tables.js +184 -0
- package/dist/list-tree.d.ts +4 -0
- package/dist/list-tree.js +44 -0
- package/dist/panel-drawer.d.ts +4 -0
- package/dist/panel-drawer.js +171 -0
- package/dist/presets/app-tier/styles.css +9459 -0
- package/dist/presets/app-tier/surfaces.json +1225 -0
- package/dist/presets/app-tier/tokens.json +221 -0
- package/dist/presets/prose/styles.css +9442 -0
- package/dist/presets/prose/surfaces.json +1225 -0
- package/dist/presets/prose/tokens.json +221 -0
- package/dist/presets.d.ts +6 -0
- package/dist/presets.js +27 -0
- package/dist/range-controls.d.ts +9 -0
- package/dist/range-controls.js +73 -0
- package/dist/resizable-aside.d.ts +4 -0
- package/dist/resizable-aside.js +328 -0
- package/dist/side-navigation.d.ts +4 -0
- package/dist/side-navigation.js +219 -0
- package/dist/styles.css +9442 -0
- package/dist/surfaces.json +1225 -0
- package/dist/tabs.d.ts +4 -0
- package/dist/tabs.js +88 -0
- package/dist/tier-registry.d.ts +10 -0
- package/dist/tier-registry.js +25 -0
- package/dist/tiers/app/styles.css +9459 -0
- package/dist/tiers/app/surfaces.json +1225 -0
- package/dist/tiers/app/tokens.json +221 -0
- package/dist/tiers/documentation/styles.css +9442 -0
- package/dist/tiers/documentation/surfaces.json +1225 -0
- package/dist/tiers/documentation/tokens.json +221 -0
- package/dist/tiers/editorial/styles.css +9442 -0
- package/dist/tiers/editorial/surfaces.json +1225 -0
- package/dist/tiers/editorial/tokens.json +221 -0
- package/dist/tiers/os/styles.css +9442 -0
- package/dist/tiers/os/surfaces.json +1225 -0
- package/dist/tiers/os/tokens.json +221 -0
- package/dist/tokens.json +221 -0
- package/dist/tooltip.d.ts +4 -0
- package/dist/tooltip.js +70 -0
- package/dist/top-navigation.d.ts +4 -0
- package/dist/top-navigation.js +354 -0
- package/dist/types.d.ts +155 -0
- package/dist/types.js +1 -0
- package/dist/vanilla-theme-colors.d.ts +5 -0
- package/dist/vanilla-theme-colors.js +208 -0
- package/docs/publishing.md +66 -0
- package/package.json +108 -0
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
const ROOT_SELECTOR = ".bf-side-navigation";
|
|
2
|
+
const DRAWER_SELECTOR = ".bf-side-navigation-drawer";
|
|
3
|
+
const OVERLAY_SELECTOR = ".bf-side-navigation-overlay";
|
|
4
|
+
const TOGGLE_SELECTOR = ".bf-side-navigation-toggle";
|
|
5
|
+
const EXPAND_SELECTOR = ".bf-side-navigation-expand, .bf-side-navigation-accordion-button";
|
|
6
|
+
const ITEM_SELECTOR = ".bf-side-navigation-item";
|
|
7
|
+
const LIST_SELECTOR = ".bf-side-navigation-list";
|
|
8
|
+
const LINK_SELECTOR = ".bf-side-navigation-link";
|
|
9
|
+
const TEXT_SELECTOR = ".bf-side-navigation-text";
|
|
10
|
+
const LARGE_BREAKPOINT = "(min-width: 64.75rem)";
|
|
11
|
+
const DRAWER_EXPANDED_CLASS = "is-drawer-expanded";
|
|
12
|
+
const DRAWER_COLLAPSED_CLASS = "is-drawer-collapsed";
|
|
13
|
+
const DRAWER_HIDDEN_CLASS = "is-drawer-hidden";
|
|
14
|
+
const lastTriggerByRoot = new WeakMap();
|
|
15
|
+
const hideTimerByRoot = new WeakMap();
|
|
16
|
+
function queryAllWithinRoot(root, selector) {
|
|
17
|
+
const elements = Array.from(root.querySelectorAll(selector));
|
|
18
|
+
if (root instanceof Element && root.matches(selector)) {
|
|
19
|
+
elements.unshift(root);
|
|
20
|
+
}
|
|
21
|
+
return elements;
|
|
22
|
+
}
|
|
23
|
+
function getRootWindow(root) {
|
|
24
|
+
if (root instanceof Document) {
|
|
25
|
+
return root.defaultView;
|
|
26
|
+
}
|
|
27
|
+
return root.ownerDocument?.defaultView ?? null;
|
|
28
|
+
}
|
|
29
|
+
function getRoots(root) {
|
|
30
|
+
return queryAllWithinRoot(root, ROOT_SELECTOR);
|
|
31
|
+
}
|
|
32
|
+
function getDrawer(sideNavigation) {
|
|
33
|
+
return sideNavigation.querySelector(DRAWER_SELECTOR);
|
|
34
|
+
}
|
|
35
|
+
function getOverlay(sideNavigation) {
|
|
36
|
+
return sideNavigation.querySelector(OVERLAY_SELECTOR);
|
|
37
|
+
}
|
|
38
|
+
function getToggles(sideNavigation) {
|
|
39
|
+
return Array.from(sideNavigation.querySelectorAll(TOGGLE_SELECTOR)).filter(toggle => {
|
|
40
|
+
return !toggle.matches(EXPAND_SELECTOR);
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
function isLargeViewport(target) {
|
|
44
|
+
return target.ownerDocument.defaultView?.matchMedia(LARGE_BREAKPOINT).matches ?? false;
|
|
45
|
+
}
|
|
46
|
+
function isDrawerOpen(sideNavigation) {
|
|
47
|
+
return sideNavigation.classList.contains(DRAWER_EXPANDED_CLASS);
|
|
48
|
+
}
|
|
49
|
+
function clearHideTimer(sideNavigation) {
|
|
50
|
+
const timer = hideTimerByRoot.get(sideNavigation);
|
|
51
|
+
if (timer !== undefined) {
|
|
52
|
+
sideNavigation.ownerDocument.defaultView?.clearTimeout(timer);
|
|
53
|
+
hideTimerByRoot.delete(sideNavigation);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
function updateDrawerA11y(sideNavigation, expanded) {
|
|
57
|
+
for (const toggle of getToggles(sideNavigation)) {
|
|
58
|
+
toggle.setAttribute("aria-expanded", String(expanded));
|
|
59
|
+
}
|
|
60
|
+
getDrawer(sideNavigation)?.setAttribute("aria-hidden", String(!expanded));
|
|
61
|
+
getOverlay(sideNavigation)?.setAttribute("aria-hidden", String(!expanded));
|
|
62
|
+
}
|
|
63
|
+
function focusDrawer(sideNavigation) {
|
|
64
|
+
const drawer = getDrawer(sideNavigation);
|
|
65
|
+
if (!drawer) {
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
const focusTarget = drawer.querySelector("button, [href], input, select, textarea, [tabindex]:not([tabindex='-1'])");
|
|
69
|
+
if (focusTarget) {
|
|
70
|
+
queueMicrotask(() => focusTarget.focus());
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
function openDrawer(sideNavigation, trigger) {
|
|
74
|
+
clearHideTimer(sideNavigation);
|
|
75
|
+
sideNavigation.classList.remove(DRAWER_HIDDEN_CLASS, DRAWER_COLLAPSED_CLASS);
|
|
76
|
+
sideNavigation.classList.add(DRAWER_EXPANDED_CLASS);
|
|
77
|
+
updateDrawerA11y(sideNavigation, true);
|
|
78
|
+
if (trigger) {
|
|
79
|
+
lastTriggerByRoot.set(sideNavigation, trigger);
|
|
80
|
+
}
|
|
81
|
+
focusDrawer(sideNavigation);
|
|
82
|
+
}
|
|
83
|
+
function closeDrawer(sideNavigation, restoreFocus) {
|
|
84
|
+
clearHideTimer(sideNavigation);
|
|
85
|
+
sideNavigation.classList.remove(DRAWER_EXPANDED_CLASS);
|
|
86
|
+
sideNavigation.classList.add(DRAWER_COLLAPSED_CLASS);
|
|
87
|
+
updateDrawerA11y(sideNavigation, false);
|
|
88
|
+
if (!isLargeViewport(sideNavigation)) {
|
|
89
|
+
const timer = sideNavigation.ownerDocument.defaultView?.setTimeout(() => {
|
|
90
|
+
if (!sideNavigation.classList.contains(DRAWER_EXPANDED_CLASS)) {
|
|
91
|
+
sideNavigation.classList.add(DRAWER_HIDDEN_CLASS);
|
|
92
|
+
}
|
|
93
|
+
}, 180);
|
|
94
|
+
if (timer !== undefined) {
|
|
95
|
+
hideTimerByRoot.set(sideNavigation, timer);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
if (restoreFocus) {
|
|
99
|
+
lastTriggerByRoot.get(sideNavigation)?.focus();
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
function getImmediateNestedList(item) {
|
|
103
|
+
for (const child of Array.from(item.children)) {
|
|
104
|
+
if (child instanceof HTMLElement && child.matches(LIST_SELECTOR)) {
|
|
105
|
+
return child;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
return null;
|
|
109
|
+
}
|
|
110
|
+
function getImmediateLinkOrText(item) {
|
|
111
|
+
for (const child of Array.from(item.children)) {
|
|
112
|
+
if (child instanceof HTMLElement && child.matches(`${LINK_SELECTOR}, ${TEXT_SELECTOR}`)) {
|
|
113
|
+
return child;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
return null;
|
|
117
|
+
}
|
|
118
|
+
function syncExpandControl(toggle) {
|
|
119
|
+
const item = toggle.closest(ITEM_SELECTOR);
|
|
120
|
+
if (!item) {
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
const expanded = toggle.getAttribute("aria-expanded") === "true";
|
|
124
|
+
const nestedList = getImmediateNestedList(item);
|
|
125
|
+
const linkOrText = getImmediateLinkOrText(item);
|
|
126
|
+
if (nestedList) {
|
|
127
|
+
nestedList.setAttribute("aria-expanded", String(expanded));
|
|
128
|
+
nestedList.setAttribute("aria-hidden", String(!expanded));
|
|
129
|
+
}
|
|
130
|
+
if (linkOrText && linkOrText.classList.contains("is-expandable")) {
|
|
131
|
+
linkOrText.setAttribute("aria-expanded", String(expanded));
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
function toggleExpand(toggle) {
|
|
135
|
+
const expanded = toggle.getAttribute("aria-expanded") === "true";
|
|
136
|
+
toggle.setAttribute("aria-expanded", String(!expanded));
|
|
137
|
+
syncExpandControl(toggle);
|
|
138
|
+
}
|
|
139
|
+
function syncInitialState(root) {
|
|
140
|
+
for (const sideNavigation of getRoots(root)) {
|
|
141
|
+
const expanded = isDrawerOpen(sideNavigation);
|
|
142
|
+
if (getDrawer(sideNavigation)) {
|
|
143
|
+
if (isLargeViewport(sideNavigation)) {
|
|
144
|
+
sideNavigation.classList.remove(DRAWER_HIDDEN_CLASS, DRAWER_COLLAPSED_CLASS);
|
|
145
|
+
}
|
|
146
|
+
else if (!expanded) {
|
|
147
|
+
sideNavigation.classList.add(DRAWER_HIDDEN_CLASS);
|
|
148
|
+
}
|
|
149
|
+
updateDrawerA11y(sideNavigation, expanded && !sideNavigation.classList.contains(DRAWER_HIDDEN_CLASS));
|
|
150
|
+
}
|
|
151
|
+
for (const toggle of Array.from(sideNavigation.querySelectorAll(EXPAND_SELECTOR))) {
|
|
152
|
+
if (!toggle.hasAttribute("aria-expanded")) {
|
|
153
|
+
toggle.setAttribute("aria-expanded", "false");
|
|
154
|
+
}
|
|
155
|
+
syncExpandControl(toggle);
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
export function initSideNavigations(options = {}) {
|
|
160
|
+
const root = options.root ?? document;
|
|
161
|
+
syncInitialState(root);
|
|
162
|
+
const onClick = (event) => {
|
|
163
|
+
const target = event.target;
|
|
164
|
+
if (!(target instanceof Element)) {
|
|
165
|
+
return;
|
|
166
|
+
}
|
|
167
|
+
const expandToggle = target.closest(EXPAND_SELECTOR);
|
|
168
|
+
if (expandToggle) {
|
|
169
|
+
event.preventDefault();
|
|
170
|
+
toggleExpand(expandToggle);
|
|
171
|
+
return;
|
|
172
|
+
}
|
|
173
|
+
const toggle = target.closest(TOGGLE_SELECTOR);
|
|
174
|
+
if (toggle) {
|
|
175
|
+
const sideNavigation = toggle.closest(ROOT_SELECTOR);
|
|
176
|
+
if (!sideNavigation) {
|
|
177
|
+
return;
|
|
178
|
+
}
|
|
179
|
+
event.preventDefault();
|
|
180
|
+
if (isDrawerOpen(sideNavigation)) {
|
|
181
|
+
closeDrawer(sideNavigation, false);
|
|
182
|
+
}
|
|
183
|
+
else {
|
|
184
|
+
openDrawer(sideNavigation, toggle);
|
|
185
|
+
}
|
|
186
|
+
return;
|
|
187
|
+
}
|
|
188
|
+
const overlay = target.closest(OVERLAY_SELECTOR);
|
|
189
|
+
if (overlay) {
|
|
190
|
+
const sideNavigation = overlay.closest(ROOT_SELECTOR);
|
|
191
|
+
if (sideNavigation) {
|
|
192
|
+
event.preventDefault();
|
|
193
|
+
closeDrawer(sideNavigation, true);
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
};
|
|
197
|
+
const onKeyDown = (event) => {
|
|
198
|
+
if (!(event instanceof KeyboardEvent) || event.key !== "Escape") {
|
|
199
|
+
return;
|
|
200
|
+
}
|
|
201
|
+
for (const sideNavigation of getRoots(root)) {
|
|
202
|
+
if (isDrawerOpen(sideNavigation)) {
|
|
203
|
+
closeDrawer(sideNavigation, true);
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
};
|
|
207
|
+
const onResize = () => {
|
|
208
|
+
syncInitialState(root);
|
|
209
|
+
};
|
|
210
|
+
const rootWindow = getRootWindow(root);
|
|
211
|
+
root.addEventListener("click", onClick);
|
|
212
|
+
root.addEventListener("keydown", onKeyDown);
|
|
213
|
+
rootWindow?.addEventListener("resize", onResize);
|
|
214
|
+
return () => {
|
|
215
|
+
root.removeEventListener("click", onClick);
|
|
216
|
+
root.removeEventListener("keydown", onKeyDown);
|
|
217
|
+
rootWindow?.removeEventListener("resize", onResize);
|
|
218
|
+
};
|
|
219
|
+
}
|