@redvars/peacock 4.2.1 → 4.3.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/dist/{BaseField-D8ByB0l3.js → BaseField-CHBcjVc2.js} +3 -3
- package/dist/{BaseField-D8ByB0l3.js.map → BaseField-CHBcjVc2.js.map} +1 -1
- package/dist/{BaseInput-xCHvT4AN.js → BaseInput-DZp2O8Gh.js} +2 -2
- package/dist/{BaseInput-xCHvT4AN.js.map → BaseInput-DZp2O8Gh.js.map} +1 -1
- package/dist/ai-badge.js +2 -2
- package/dist/ai-summary.js +2 -2
- package/dist/alert.js +2 -2
- package/dist/anchor-nav.js +2 -2
- package/dist/app-shell.js +2 -2
- package/dist/assistant-panel.js +2 -2
- package/dist/assistant-step.js +2 -2
- package/dist/assistant-steps.js +2 -2
- package/dist/avatar-group.js +2 -2
- package/dist/banner.js +2 -2
- package/dist/{base-progress-DxNgAQtw.js → base-progress-CKQ32Ruw.js} +2 -2
- package/dist/{base-progress-DxNgAQtw.js.map → base-progress-CKQ32Ruw.js.map} +1 -1
- package/dist/bottom-sheet.js +2 -2
- package/dist/breadcrumb.js +2 -2
- package/dist/calendar.js +2 -2
- package/dist/{canvas-base-DHKf2CmA.js → canvas-base-BoKef3yr.js} +2 -2
- package/dist/{canvas-base-DHKf2CmA.js.map → canvas-base-BoKef3yr.js.map} +1 -1
- package/dist/carousel.js +644 -0
- package/dist/carousel.js.map +1 -0
- package/dist/{cartesian-chart-G6VX1aKk.js → cartesian-chart-DqZxnoG1.js} +2 -2
- package/dist/{cartesian-chart-G6VX1aKk.js.map → cartesian-chart-DqZxnoG1.js.map} +1 -1
- package/dist/{cb-group-base-CZLzCnXK.js → cb-group-base-Bf7iOIGS.js} +2 -2
- package/dist/{cb-group-base-CZLzCnXK.js.map → cb-group-base-Bf7iOIGS.js.map} +1 -1
- package/dist/cb-group.js +3 -3
- package/dist/cb-rule.js +3 -3
- package/dist/chart-area.js +4 -4
- package/dist/chart-bar.js +4 -4
- package/dist/{chart-base-DREru2P0.js → chart-base-ByCJM_9C.js} +2 -2
- package/dist/{chart-base-DREru2P0.js.map → chart-base-ByCJM_9C.js.map} +1 -1
- package/dist/chart-doughnut.js +3 -3
- package/dist/chart-line.js +4 -4
- package/dist/chart-pie.js +3 -3
- package/dist/chat-event.js +2 -2
- package/dist/chat-message.js +2 -2
- package/dist/chat-thread.js +2 -2
- package/dist/checkbox-group.js +3 -3
- package/dist/checkbox.js +3 -3
- package/dist/chip-set.js +2 -2
- package/dist/chip.js +2 -2
- package/dist/circular-progress.js +3 -3
- package/dist/citation.js +2 -2
- package/dist/code-editor.js +3 -3
- package/dist/code-highlighter.js +2 -2
- package/dist/color-field.js +4 -4
- package/dist/color-picker.js +2 -2
- package/dist/command-palette.js +2 -2
- package/dist/comment-composer.js +4 -4
- package/dist/condition-builder.js +3 -3
- package/dist/confirm-dialog.js +2 -2
- package/dist/copy-button.js +2 -2
- package/dist/currency-field.js +4 -4
- package/dist/custom-elements-jsdocs.json +902 -74
- package/dist/custom-elements.json +2842 -1
- package/dist/date-field.js +5 -5
- package/dist/date-picker.js +2 -2
- package/dist/date-range-field.js +5 -5
- package/dist/datetime-field.js +5 -5
- package/dist/dependency-map.js +3 -3
- package/dist/description-item.js +2 -2
- package/dist/description-list.js +2 -2
- package/dist/{diagram-CHF70xTL.js → diagram-Cnrj-4y3.js} +2 -2
- package/dist/{diagram-CHF70xTL.js.map → diagram-Cnrj-4y3.js.map} +1 -1
- package/dist/diagram-controls.js +2 -2
- package/dist/diagram-minimap.js +2 -2
- package/dist/diagram.js +4 -4
- package/dist/diff-viewer.js +2 -2
- package/dist/discussion-activity.js +2 -2
- package/dist/discussion-comment.js +2 -2
- package/dist/discussion.js +4 -4
- package/dist/{document-editor-Cb9fCxvA.js → document-editor-C8ThjDQ7.js} +2 -2
- package/dist/{document-editor-Cb9fCxvA.js.map → document-editor-C8ThjDQ7.js.map} +1 -1
- package/dist/document-editor.js +3 -3
- package/dist/draft-card.js +2 -2
- package/dist/erd.js +3 -3
- package/dist/file-upload.js +3 -3
- package/dist/filter-bar.js +2 -2
- package/dist/flow.js +4 -4
- package/dist/form.js +2 -2
- package/dist/{generative-view-C4fJ2zI7.js → generative-view-CQ8-g1wY.js} +2 -2
- package/dist/{generative-view-C4fJ2zI7.js.map → generative-view-CQ8-g1wY.js.map} +1 -1
- package/dist/generative-view.js +3 -3
- package/dist/highlight-Be0wu7kh.js +252 -0
- package/dist/highlight-Be0wu7kh.js.map +1 -0
- package/dist/highlight.js +6 -0
- package/dist/highlight.js.map +1 -0
- package/dist/html-editor.js +4 -4
- package/dist/{i18n-controller-CH4e9sju.js → i18n-controller-DLJcJ5gO.js} +2 -2
- package/dist/{i18n-controller-CH4e9sju.js.map → i18n-controller-DLJcJ5gO.js.map} +1 -1
- package/dist/image.js +2 -2
- package/dist/index.js +26 -16
- package/dist/index.js.map +1 -1
- package/dist/inline-edit.js +2 -2
- package/dist/input.js +3 -3
- package/dist/json-viewer.js +2 -2
- package/dist/kanban.js +2 -2
- package/dist/kbd.js +2 -2
- package/dist/linear-progress.js +3 -3
- package/dist/listbox.js +2 -2
- package/dist/loader-full.js +19 -9
- package/dist/loader-full.js.map +1 -1
- package/dist/loader.js +46 -9
- package/dist/loader.js.map +1 -1
- package/dist/markdown-editor.js +4 -4
- package/dist/mention-input.js +4 -4
- package/dist/modal.js +2 -2
- package/dist/navigation-bar.js +2 -2
- package/dist/navigation-drawer.js +2 -2
- package/dist/navigation-rail.js +2 -2
- package/dist/notification-center.js +2 -2
- package/dist/number-field.js +4 -4
- package/dist/page-header.js +2 -2
- package/dist/pagination.js +2 -2
- package/dist/password-field.js +4 -4
- package/dist/password-rules.js +2 -2
- package/dist/phone-field.js +4 -4
- package/dist/{picker-field-loXW-xrW.js → picker-field-B5xOFc3-.js} +3 -3
- package/dist/{picker-field-loXW-xrW.js.map → picker-field-B5xOFc3-.js.map} +1 -1
- package/dist/pin-input.js +4 -4
- package/dist/presence-indicator.js +2 -2
- package/dist/prompt-input.js +4 -4
- package/dist/radio.js +3 -3
- package/dist/rating.js +3 -3
- package/dist/redvars-loader.js +2 -2
- package/dist/relative-time.js +2 -2
- package/dist/resizable-panels.js +2 -2
- package/dist/{rich-text-input-B5j0eqCJ.js → rich-text-input-C4B9D6oD.js} +3 -3
- package/dist/{rich-text-input-B5j0eqCJ.js.map → rich-text-input-C4B9D6oD.js.map} +1 -1
- package/dist/{schema-BJzlGRP1.js → schema-CPhNrjrx.js} +2 -2
- package/dist/{schema-BJzlGRP1.js.map → schema-CPhNrjrx.js.map} +1 -1
- package/dist/search.js +3 -3
- package/dist/select.js +4 -4
- package/dist/side-sheet.js +2 -2
- package/dist/signature-pad.js +3 -3
- package/dist/site-footer-group.js +142 -0
- package/dist/site-footer-group.js.map +1 -0
- package/dist/site-footer.js +338 -0
- package/dist/site-footer.js.map +1 -0
- package/dist/site-header.js +774 -0
- package/dist/site-header.js.map +1 -0
- package/dist/site-nav-group.js +123 -0
- package/dist/site-nav-group.js.map +1 -0
- package/dist/site-nav-link.js +321 -0
- package/dist/site-nav-link.js.map +1 -0
- package/dist/site-nav-menu.js +506 -0
- package/dist/site-nav-menu.js.map +1 -0
- package/dist/site-nav-shared-BDR2HG8e.js +23 -0
- package/dist/site-nav-shared-BDR2HG8e.js.map +1 -0
- package/dist/slider.js +3 -3
- package/dist/snackbar.js +2 -2
- package/dist/sparkline.js +2 -2
- package/dist/split-button.js +2 -2
- package/dist/src/__internal/i18n/strings.d.ts +24 -0
- package/dist/src/carousel/carousel.d.ts +135 -0
- package/dist/src/carousel/index.d.ts +1 -0
- package/dist/src/highlight/highlight.d.ts +56 -0
- package/dist/src/highlight/index.d.ts +2 -0
- package/dist/src/highlight/matches.d.ts +9 -0
- package/dist/src/index.d.ts +9 -0
- package/dist/src/site-footer/index.d.ts +2 -0
- package/dist/src/site-footer/site-footer-group.d.ts +34 -0
- package/dist/src/site-footer/site-footer.d.ts +74 -0
- package/dist/src/site-header/index.d.ts +4 -0
- package/dist/src/site-header/site-header.d.ts +170 -0
- package/dist/src/site-header/site-nav-group.d.ts +32 -0
- package/dist/src/site-header/site-nav-link.d.ts +65 -0
- package/dist/src/site-header/site-nav-menu.d.ts +104 -0
- package/dist/src/site-header/site-nav-shared.d.ts +13 -0
- package/dist/src/video/index.d.ts +2 -0
- package/dist/src/video/video-source.d.ts +12 -0
- package/dist/src/video/video.d.ts +80 -0
- package/dist/stat.js +2 -2
- package/dist/status-indicator.js +2 -2
- package/dist/step.js +2 -2
- package/dist/stepper.js +2 -2
- package/dist/{strings-o6v6Hrmn.js → strings-MXyrGrNs.js} +28 -1
- package/dist/strings-MXyrGrNs.js.map +1 -0
- package/dist/svg.js +2 -2
- package/dist/switch.js +3 -3
- package/dist/table.js +2 -2
- package/dist/test/carousel.test.d.ts +1 -0
- package/dist/test/highlight.test.d.ts +1 -0
- package/dist/test/site-footer.test.d.ts +1 -0
- package/dist/test/site-header.test.d.ts +1 -0
- package/dist/test/video.test.d.ts +1 -0
- package/dist/textarea.js +4 -4
- package/dist/time-field.js +5 -5
- package/dist/time-picker.js +2 -2
- package/dist/timeline-item.js +2 -2
- package/dist/timeline.js +2 -2
- package/dist/{toggle-base-BSzBnLZN.js → toggle-base-I1wE_fVe.js} +2 -2
- package/dist/{toggle-base-BSzBnLZN.js.map → toggle-base-I1wE_fVe.js.map} +1 -1
- package/dist/tour.js +2 -2
- package/dist/transfer-list.js +3 -3
- package/dist/tree-chart.js +3 -3
- package/dist/tree-item.js +2 -2
- package/dist/tree.js +2 -2
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/typing-indicator.js +2 -2
- package/dist/url-field.js +4 -4
- package/dist/user-menu.js +2 -2
- package/dist/video-IwNmHyft.js +509 -0
- package/dist/video-IwNmHyft.js.map +1 -0
- package/dist/video.js +12 -0
- package/dist/video.js.map +1 -0
- package/dist/virtual-list.js +2 -2
- package/dist/workflow-timeline.js +2 -2
- package/dist/workflow.js +3 -3
- package/dist/workspace-switcher.js +2 -2
- package/package.json +1 -1
- package/readme.md +5 -0
- package/src/__internal/i18n/strings.ts +31 -0
- package/src/carousel/carousel.scss +124 -0
- package/src/carousel/carousel.ts +547 -0
- package/src/carousel/index.ts +1 -0
- package/src/highlight/highlight.scss +25 -0
- package/src/highlight/highlight.ts +123 -0
- package/src/highlight/index.ts +2 -0
- package/src/highlight/matches.ts +94 -0
- package/src/index.ts +18 -0
- package/src/loader.ts +36 -0
- package/src/site-footer/index.ts +2 -0
- package/src/site-footer/site-footer-group.scss +53 -0
- package/src/site-footer/site-footer-group.ts +52 -0
- package/src/site-footer/site-footer.scss +171 -0
- package/src/site-footer/site-footer.ts +151 -0
- package/src/site-header/index.ts +8 -0
- package/src/site-header/site-header.scss +238 -0
- package/src/site-header/site-header.ts +565 -0
- package/src/site-header/site-nav-group.scss +29 -0
- package/src/site-header/site-nav-group.ts +57 -0
- package/src/site-header/site-nav-link.scss +154 -0
- package/src/site-header/site-nav-link.ts +140 -0
- package/src/site-header/site-nav-menu.scss +182 -0
- package/src/site-header/site-nav-menu.ts +336 -0
- package/src/site-header/site-nav-shared.ts +27 -0
- package/src/video/index.ts +2 -0
- package/src/video/video-source.ts +80 -0
- package/src/video/video.scss +183 -0
- package/src/video/video.ts +246 -0
- package/dist/strings-o6v6Hrmn.js.map +0 -1
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
/** A run of marked text: `[start, end)` in UTF-16 code units of the original text. */
|
|
2
|
+
export type HighlightRange = [start: number, end: number];
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Folds text for matching: lower case in the locale, accents and other combining marks removed.
|
|
6
|
+
* Returns the folded text and, for each of its code units, the original text's range it came from,
|
|
7
|
+
* so a match in the folded text maps back to the original even when folding changes lengths.
|
|
8
|
+
*/
|
|
9
|
+
function fold(text: string, locale: string) {
|
|
10
|
+
let folded = '';
|
|
11
|
+
const starts: number[] = [];
|
|
12
|
+
const ends: number[] = [];
|
|
13
|
+
let offset = 0;
|
|
14
|
+
for (const char of text) {
|
|
15
|
+
const piece = char
|
|
16
|
+
.normalize('NFD')
|
|
17
|
+
.replace(/\p{M}/gu, '')
|
|
18
|
+
.toLocaleLowerCase(locale);
|
|
19
|
+
for (let i = 0; i < piece.length; i += 1) {
|
|
20
|
+
starts.push(offset);
|
|
21
|
+
ends.push(offset + char.length);
|
|
22
|
+
}
|
|
23
|
+
// A mark that folds away, such as a combining accent, belongs to the letter before it.
|
|
24
|
+
if (!piece && ends.length) ends[ends.length - 1] = offset + char.length;
|
|
25
|
+
folded += piece;
|
|
26
|
+
offset += char.length;
|
|
27
|
+
}
|
|
28
|
+
return { folded, starts, ends };
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* The words of a query to look for, longest first so a longer word wins where two overlap.
|
|
33
|
+
* One-letter words are left out when the query has longer ones, so "reset a password" does not
|
|
34
|
+
* mark every "a".
|
|
35
|
+
*/
|
|
36
|
+
function queryWords(query: string, locale: string): string[] {
|
|
37
|
+
const words = Array.from(
|
|
38
|
+
new Set(
|
|
39
|
+
fold(query, locale)
|
|
40
|
+
.folded.split(/[\s\p{P}]+/u)
|
|
41
|
+
.filter(Boolean),
|
|
42
|
+
),
|
|
43
|
+
);
|
|
44
|
+
const long = words.filter(word => [...word].length > 1);
|
|
45
|
+
return (long.length ? long : words).sort((a, b) => b.length - a.length);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/** Sorts ranges and merges the ones that touch or overlap. */
|
|
49
|
+
export function mergeRanges(ranges: readonly HighlightRange[], length: number) {
|
|
50
|
+
const sorted = ranges
|
|
51
|
+
.map(
|
|
52
|
+
([start, end]): HighlightRange => [
|
|
53
|
+
Math.max(0, Math.min(start, length)),
|
|
54
|
+
Math.max(0, Math.min(end, length)),
|
|
55
|
+
],
|
|
56
|
+
)
|
|
57
|
+
.filter(([start, end]) => end > start)
|
|
58
|
+
.sort((a, b) => a[0] - b[0]);
|
|
59
|
+
const merged: HighlightRange[] = [];
|
|
60
|
+
for (const range of sorted) {
|
|
61
|
+
const last = merged[merged.length - 1];
|
|
62
|
+
if (last && range[0] <= last[1]) last[1] = Math.max(last[1], range[1]);
|
|
63
|
+
else merged.push([range[0], range[1]]);
|
|
64
|
+
}
|
|
65
|
+
return merged;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Where the words of `query` occur in `text`, each word on its own, ignoring case and accents.
|
|
70
|
+
* Ranges are sorted and do not overlap.
|
|
71
|
+
*/
|
|
72
|
+
export function findMatches(
|
|
73
|
+
text: string,
|
|
74
|
+
query: string,
|
|
75
|
+
locale = 'en',
|
|
76
|
+
): HighlightRange[] {
|
|
77
|
+
const words = queryWords(query, locale);
|
|
78
|
+
if (!text || !words.length) return [];
|
|
79
|
+
const { folded, starts, ends } = fold(text, locale);
|
|
80
|
+
const taken = new Array<boolean>(folded.length).fill(false);
|
|
81
|
+
const ranges: HighlightRange[] = [];
|
|
82
|
+
for (const word of words) {
|
|
83
|
+
let from = folded.indexOf(word);
|
|
84
|
+
while (from !== -1) {
|
|
85
|
+
const to = from + word.length;
|
|
86
|
+
if (!taken.slice(from, to).some(Boolean)) {
|
|
87
|
+
taken.fill(true, from, to);
|
|
88
|
+
ranges.push([starts[from], ends[to - 1]]);
|
|
89
|
+
}
|
|
90
|
+
from = folded.indexOf(word, to);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
return mergeRanges(ranges, text.length);
|
|
94
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -159,6 +159,24 @@ export {
|
|
|
159
159
|
NavigationDrawerItem,
|
|
160
160
|
NavigationDrawerGroup,
|
|
161
161
|
} from './navigation-drawer/index.js';
|
|
162
|
+
export {
|
|
163
|
+
SiteHeader,
|
|
164
|
+
SiteNavMenu,
|
|
165
|
+
SiteNavGroup,
|
|
166
|
+
SiteNavLink,
|
|
167
|
+
} from './site-header/index.js';
|
|
168
|
+
export type {
|
|
169
|
+
SiteHeaderCloseDetail,
|
|
170
|
+
SiteNavMenuCloseDetail,
|
|
171
|
+
SiteNavMenuCloseReason,
|
|
172
|
+
} from './site-header/index.js';
|
|
173
|
+
export { SiteFooter, SiteFooterGroup } from './site-footer/index.js';
|
|
174
|
+
export { Carousel } from './carousel/index.js';
|
|
175
|
+
export type { CarouselChangeDetail } from './carousel/index.js';
|
|
176
|
+
export { Video, parseVideoSource } from './video/index.js';
|
|
177
|
+
export type { VideoProvider } from './video/index.js';
|
|
178
|
+
export { Highlight, findMatches } from './highlight/index.js';
|
|
179
|
+
export type { HighlightRange } from './highlight/index.js';
|
|
162
180
|
export { Listbox, ListboxOption } from './listbox/index.js';
|
|
163
181
|
export type { ListboxChangeDetail } from './listbox/index.js';
|
|
164
182
|
export { PinInput } from './pin-input/index.js';
|
package/src/loader.ts
CHANGED
|
@@ -151,6 +151,15 @@ import { NavigationBarItem } from '@/navigation-bar/navigation-bar-item.js';
|
|
|
151
151
|
import { NavigationDrawer } from '@/navigation-drawer/navigation-drawer.js';
|
|
152
152
|
import { NavigationDrawerItem } from '@/navigation-drawer/navigation-drawer-item.js';
|
|
153
153
|
import { NavigationDrawerGroup } from '@/navigation-drawer/navigation-drawer-group.js';
|
|
154
|
+
import { SiteHeader } from '@/site-header/site-header.js';
|
|
155
|
+
import { SiteNavMenu } from '@/site-header/site-nav-menu.js';
|
|
156
|
+
import { SiteNavGroup } from '@/site-header/site-nav-group.js';
|
|
157
|
+
import { SiteNavLink } from '@/site-header/site-nav-link.js';
|
|
158
|
+
import { SiteFooter } from '@/site-footer/site-footer.js';
|
|
159
|
+
import { SiteFooterGroup } from '@/site-footer/site-footer-group.js';
|
|
160
|
+
import { Carousel } from '@/carousel/carousel.js';
|
|
161
|
+
import { Video } from '@/video/video.js';
|
|
162
|
+
import { Highlight } from '@/highlight/highlight.js';
|
|
154
163
|
|
|
155
164
|
// Resolve the folder this script was served from. `new URL('.', …)` drops the file name and any
|
|
156
165
|
// query string, so `loader.js?styles` still yields `…/dist` (no trailing slash).
|
|
@@ -674,6 +683,33 @@ const loaderConfig: LoaderConfig = {
|
|
|
674
683
|
'wc-navigation-drawer-group': {
|
|
675
684
|
CustomElementClass: NavigationDrawerGroup,
|
|
676
685
|
},
|
|
686
|
+
'wc-site-header': {
|
|
687
|
+
CustomElementClass: SiteHeader,
|
|
688
|
+
},
|
|
689
|
+
'wc-site-nav-menu': {
|
|
690
|
+
CustomElementClass: SiteNavMenu,
|
|
691
|
+
},
|
|
692
|
+
'wc-site-nav-group': {
|
|
693
|
+
CustomElementClass: SiteNavGroup,
|
|
694
|
+
},
|
|
695
|
+
'wc-site-nav-link': {
|
|
696
|
+
CustomElementClass: SiteNavLink,
|
|
697
|
+
},
|
|
698
|
+
'wc-site-footer': {
|
|
699
|
+
CustomElementClass: SiteFooter,
|
|
700
|
+
},
|
|
701
|
+
'wc-site-footer-group': {
|
|
702
|
+
CustomElementClass: SiteFooterGroup,
|
|
703
|
+
},
|
|
704
|
+
'wc-carousel': {
|
|
705
|
+
CustomElementClass: Carousel,
|
|
706
|
+
},
|
|
707
|
+
'wc-video': {
|
|
708
|
+
CustomElementClass: Video,
|
|
709
|
+
},
|
|
710
|
+
'wc-highlight': {
|
|
711
|
+
CustomElementClass: Highlight,
|
|
712
|
+
},
|
|
677
713
|
'wc-calendar': {
|
|
678
714
|
importPath: `${distDirectory}/calendar.js`,
|
|
679
715
|
dependencies: [
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
@use '../../scss/mixin';
|
|
2
|
+
|
|
3
|
+
@include mixin.base-styles;
|
|
4
|
+
|
|
5
|
+
:host {
|
|
6
|
+
display: block;
|
|
7
|
+
min-inline-size: 0;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
.title {
|
|
11
|
+
@include mixin.get-typography(title-small);
|
|
12
|
+
|
|
13
|
+
margin-block-end: var(--spacing-150);
|
|
14
|
+
color: var(--color-on-surface);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
.links {
|
|
18
|
+
display: flex;
|
|
19
|
+
flex-direction: column;
|
|
20
|
+
align-items: flex-start;
|
|
21
|
+
gap: var(--spacing-100);
|
|
22
|
+
|
|
23
|
+
::slotted(a) {
|
|
24
|
+
@include mixin.get-typography-not-important(body-medium);
|
|
25
|
+
|
|
26
|
+
color: var(--color-on-surface-variant);
|
|
27
|
+
text-decoration: none;
|
|
28
|
+
border-radius: var(--shape-corner-extra-small);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
::slotted(a:hover) {
|
|
32
|
+
color: var(--color-primary);
|
|
33
|
+
text-decoration: underline;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
::slotted(a:focus-visible) {
|
|
37
|
+
outline: 2px solid var(--color-primary);
|
|
38
|
+
outline-offset: 2px;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// Tap targets on narrow footers.
|
|
43
|
+
@container (max-width: 48rem) {
|
|
44
|
+
.links {
|
|
45
|
+
gap: 0;
|
|
46
|
+
|
|
47
|
+
::slotted(a) {
|
|
48
|
+
display: inline-flex;
|
|
49
|
+
align-items: center;
|
|
50
|
+
min-block-size: 2.75rem;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { html, LitElement } from 'lit';
|
|
2
|
+
import { property } from 'lit/decorators.js';
|
|
3
|
+
import IndividualComponent from '@/IndividualComponent.js';
|
|
4
|
+
import styles from './site-footer-group.scss';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* @label Site Footer Group
|
|
8
|
+
* @tag wc-site-footer-group
|
|
9
|
+
* @rawTag site-footer-group
|
|
10
|
+
*
|
|
11
|
+
* @summary A titled column of links in a site footer.
|
|
12
|
+
* @overview
|
|
13
|
+
* <p>A column of a <code>wc-site-footer</code>: a title and a list of links. The column is a
|
|
14
|
+
* navigation landmark named by its <code>label</code>, so a screen reader lists "Product",
|
|
15
|
+
* "Company" and so on among the page's landmarks.</p>
|
|
16
|
+
* <p>Put plain <code><a></code> elements or <code>wc-link</code> in it; the group lays them
|
|
17
|
+
* out and styles plain links.</p>
|
|
18
|
+
*
|
|
19
|
+
* @slot - The column's links.
|
|
20
|
+
*
|
|
21
|
+
* @csspart nav - The `<nav>` element.
|
|
22
|
+
* @csspart title - The column's title.
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* ```html
|
|
26
|
+
* <wc-site-footer-group label="Developers">
|
|
27
|
+
* <a href="/docs">Docs</a>
|
|
28
|
+
* <a href="https://peacock.redvars.com">Peacock</a>
|
|
29
|
+
* </wc-site-footer-group>
|
|
30
|
+
* ```
|
|
31
|
+
* @tags navigation
|
|
32
|
+
*/
|
|
33
|
+
@IndividualComponent
|
|
34
|
+
export class SiteFooterGroup extends LitElement {
|
|
35
|
+
// ── Static ───────────────────────────────────────────────────────────────
|
|
36
|
+
|
|
37
|
+
static styles = [styles];
|
|
38
|
+
|
|
39
|
+
// ── Properties ───────────────────────────────────────────────────────────
|
|
40
|
+
|
|
41
|
+
/** The column's title, also the name of its navigation landmark. */
|
|
42
|
+
@property() label = '';
|
|
43
|
+
|
|
44
|
+
// ── Render ───────────────────────────────────────────────────────────────
|
|
45
|
+
|
|
46
|
+
render() {
|
|
47
|
+
return html`<nav class="nav" part="nav" aria-label=${this.label}>
|
|
48
|
+
<div class="title" part="title" aria-hidden="true">${this.label}</div>
|
|
49
|
+
<div class="links"><slot></slot></div>
|
|
50
|
+
</nav>`;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
@use '../../scss/mixin';
|
|
2
|
+
|
|
3
|
+
@include mixin.base-styles;
|
|
4
|
+
|
|
5
|
+
:host {
|
|
6
|
+
display: block;
|
|
7
|
+
container-type: inline-size;
|
|
8
|
+
color: var(--color-on-surface-variant);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
.footer {
|
|
12
|
+
background-color: var(
|
|
13
|
+
--site-footer-background,
|
|
14
|
+
var(--color-surface-container-low)
|
|
15
|
+
);
|
|
16
|
+
border-block-start: 1px solid var(--color-outline-variant);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
.inner {
|
|
20
|
+
// The max width is the content's, without the padding, so it lines up with a page's content column.
|
|
21
|
+
max-inline-size: var(--site-footer-max-width, none);
|
|
22
|
+
margin-inline: auto;
|
|
23
|
+
padding: var(--spacing-600) var(--spacing-500) var(--spacing-300);
|
|
24
|
+
box-sizing: content-box;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
.slim .inner {
|
|
28
|
+
padding-block: var(--spacing-300);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
.top {
|
|
32
|
+
display: grid;
|
|
33
|
+
grid-template-columns: minmax(12rem, 1.4fr) 4fr;
|
|
34
|
+
gap: var(--spacing-400);
|
|
35
|
+
|
|
36
|
+
&[hidden] {
|
|
37
|
+
display: none;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
.top:has(.brand[hidden]) {
|
|
42
|
+
grid-template-columns: 1fr;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
.brand {
|
|
46
|
+
display: flex;
|
|
47
|
+
flex-direction: column;
|
|
48
|
+
gap: var(--spacing-150);
|
|
49
|
+
color: var(--color-on-surface);
|
|
50
|
+
|
|
51
|
+
&[hidden] {
|
|
52
|
+
display: none;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
::slotted(a) {
|
|
56
|
+
@include mixin.get-typography-not-important(title-medium);
|
|
57
|
+
|
|
58
|
+
display: inline-flex;
|
|
59
|
+
align-items: center;
|
|
60
|
+
gap: var(--spacing-100);
|
|
61
|
+
align-self: flex-start;
|
|
62
|
+
color: inherit;
|
|
63
|
+
font-weight: var(--font-weight-bold);
|
|
64
|
+
text-decoration: none;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
::slotted(p) {
|
|
68
|
+
@include mixin.get-typography-not-important(body-medium);
|
|
69
|
+
|
|
70
|
+
max-inline-size: 22rem;
|
|
71
|
+
margin: 0;
|
|
72
|
+
color: var(--color-on-surface-variant);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
.groups {
|
|
77
|
+
display: grid;
|
|
78
|
+
grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr));
|
|
79
|
+
gap: var(--spacing-400);
|
|
80
|
+
|
|
81
|
+
&[hidden] {
|
|
82
|
+
display: none;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
.bottom {
|
|
87
|
+
@include mixin.get-typography(body-small);
|
|
88
|
+
|
|
89
|
+
display: flex;
|
|
90
|
+
flex-wrap: wrap;
|
|
91
|
+
align-items: center;
|
|
92
|
+
justify-content: space-between;
|
|
93
|
+
gap: var(--spacing-200);
|
|
94
|
+
margin-block-start: var(--spacing-500);
|
|
95
|
+
padding-block-start: var(--spacing-300);
|
|
96
|
+
border-block-start: 1px solid var(--color-outline-variant);
|
|
97
|
+
|
|
98
|
+
&[hidden] {
|
|
99
|
+
display: none;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
.slim .bottom {
|
|
104
|
+
margin: 0;
|
|
105
|
+
padding: 0;
|
|
106
|
+
border: none;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
.legal {
|
|
110
|
+
display: flex;
|
|
111
|
+
flex-wrap: wrap;
|
|
112
|
+
align-items: center;
|
|
113
|
+
gap: var(--spacing-100) var(--spacing-300);
|
|
114
|
+
|
|
115
|
+
&[hidden] {
|
|
116
|
+
display: none;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
::slotted(a) {
|
|
120
|
+
color: inherit;
|
|
121
|
+
text-decoration: underline;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
::slotted(a:hover) {
|
|
125
|
+
color: var(--color-primary);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
.social {
|
|
130
|
+
display: flex;
|
|
131
|
+
gap: var(--spacing-050);
|
|
132
|
+
|
|
133
|
+
&[hidden] {
|
|
134
|
+
display: none;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
// The footer's own width, so it fits a portal content area as well as a full page.
|
|
139
|
+
@container (max-width: 48rem) {
|
|
140
|
+
.inner {
|
|
141
|
+
padding: var(--spacing-400) var(--spacing-300) var(--spacing-200);
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
.top {
|
|
145
|
+
grid-template-columns: 1fr;
|
|
146
|
+
gap: var(--spacing-300);
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
.groups {
|
|
150
|
+
grid-template-columns: repeat(2, minmax(0, 1fr));
|
|
151
|
+
gap: var(--spacing-300) var(--spacing-200);
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
.bottom {
|
|
155
|
+
flex-direction: column;
|
|
156
|
+
align-items: flex-start;
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
@container (max-width: 24rem) {
|
|
161
|
+
.groups {
|
|
162
|
+
grid-template-columns: 1fr;
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
@media (forced-colors: active) {
|
|
167
|
+
.footer,
|
|
168
|
+
.bottom {
|
|
169
|
+
border-color: CanvasText;
|
|
170
|
+
}
|
|
171
|
+
}
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
import { html, LitElement } from 'lit';
|
|
2
|
+
import { state } from 'lit/decorators.js';
|
|
3
|
+
import { classMap } from 'lit/directives/class-map.js';
|
|
4
|
+
import IndividualComponent from '@/IndividualComponent.js';
|
|
5
|
+
import { SiteFooterGroup } from './site-footer-group.js';
|
|
6
|
+
import styles from './site-footer.scss';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* @label Site Footer
|
|
10
|
+
* @tag wc-site-footer
|
|
11
|
+
* @rawTag site-footer
|
|
12
|
+
*
|
|
13
|
+
* @summary The footer of a website or portal: brand, columns of links, legal links and social links.
|
|
14
|
+
* @overview
|
|
15
|
+
* <p>Site footer is the page's <code>contentinfo</code> landmark. The <code>brand</code> slot and
|
|
16
|
+
* the <code>wc-site-footer-group</code> columns sit at the top; a bottom row holds the
|
|
17
|
+
* <code>legal</code> slot (copyright and policy links) and the <code>social</code> slot (icon
|
|
18
|
+
* buttons that link to the site's profiles).</p>
|
|
19
|
+
* <p>Slots that are empty take no room, so the same component is a full website footer or a slim
|
|
20
|
+
* portal footer with one row of text and links.</p>
|
|
21
|
+
* <p>The footer responds to its own width, not the viewport's: narrower than 48rem the columns wrap
|
|
22
|
+
* two to a row, and narrower than 24rem they stack. Links stay visible at every width, one tap away,
|
|
23
|
+
* rather than folded into an accordion.</p>
|
|
24
|
+
*
|
|
25
|
+
* @slot brand - The site's logo and name, and an optional line of text under it.
|
|
26
|
+
* @slot - The footer's `wc-site-footer-group` columns.
|
|
27
|
+
* @slot legal - Copyright and policy links, in small type.
|
|
28
|
+
* @slot social - Links to the site's profiles, usually `wc-icon-button shape="round"` with an `aria-label` each.
|
|
29
|
+
*
|
|
30
|
+
* @csspart base - The `<footer>` element.
|
|
31
|
+
* @csspart top - The row of the brand and the columns.
|
|
32
|
+
* @csspart groups - The columns.
|
|
33
|
+
* @csspart bottom - The row of the legal and social slots.
|
|
34
|
+
*
|
|
35
|
+
* @cssprop --site-footer-background - Background of the footer. Defaults to `--color-surface-container-low`.
|
|
36
|
+
* @cssprop --site-footer-max-width - Width the footer's content is centred in. Defaults to `none`.
|
|
37
|
+
*
|
|
38
|
+
* @example
|
|
39
|
+
* ```html
|
|
40
|
+
* <wc-site-footer>
|
|
41
|
+
* <a slot="brand" href="/">Redvars</a>
|
|
42
|
+
* <p slot="brand">Code less. Scale everywhere. Build natively.</p>
|
|
43
|
+
* <wc-site-footer-group label="Product">
|
|
44
|
+
* <a href="/tables">Tables and forms</a>
|
|
45
|
+
* <a href="/pricing">Pricing</a>
|
|
46
|
+
* </wc-site-footer-group>
|
|
47
|
+
* <wc-site-footer-group label="Company">
|
|
48
|
+
* <a href="/about">About</a>
|
|
49
|
+
* <a href="/blog">Blog</a>
|
|
50
|
+
* </wc-site-footer-group>
|
|
51
|
+
* <span slot="legal">© 2026 Redvars</span>
|
|
52
|
+
* <a slot="legal" href="/privacy">Privacy</a>
|
|
53
|
+
* <wc-icon-button slot="social" variant="text" shape="round" href="https://github.com/redvars" aria-label="GitHub">
|
|
54
|
+
* <wc-icon name="code"></wc-icon>
|
|
55
|
+
* </wc-icon-button>
|
|
56
|
+
* </wc-site-footer>
|
|
57
|
+
* ```
|
|
58
|
+
* @example
|
|
59
|
+
* ```html
|
|
60
|
+
* <wc-site-footer>
|
|
61
|
+
* <span slot="legal">© Acme Corp. Support hours 08:00–18:00 CET.</span>
|
|
62
|
+
* <a slot="legal" href="/p/support/contact">Contact us</a>
|
|
63
|
+
* <a slot="legal" href="/p/support/privacy">Privacy</a>
|
|
64
|
+
* </wc-site-footer>
|
|
65
|
+
* ```
|
|
66
|
+
* @tags navigation layout
|
|
67
|
+
*/
|
|
68
|
+
@IndividualComponent
|
|
69
|
+
export class SiteFooter extends LitElement {
|
|
70
|
+
// ── Static ───────────────────────────────────────────────────────────────
|
|
71
|
+
|
|
72
|
+
static styles = [styles];
|
|
73
|
+
|
|
74
|
+
static Group = SiteFooterGroup;
|
|
75
|
+
|
|
76
|
+
// ── State ────────────────────────────────────────────────────────────────
|
|
77
|
+
|
|
78
|
+
/** Which slots have content. */
|
|
79
|
+
@state() private filled = {
|
|
80
|
+
brand: false,
|
|
81
|
+
groups: false,
|
|
82
|
+
legal: false,
|
|
83
|
+
social: false,
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
// ── Private fields ───────────────────────────────────────────────────────
|
|
87
|
+
|
|
88
|
+
/** Watches the children, so the rows show and hide with their content. */
|
|
89
|
+
private readonly childObserver = new MutationObserver(() => this.syncSlots());
|
|
90
|
+
|
|
91
|
+
// ── Lifecycle ────────────────────────────────────────────────────────────
|
|
92
|
+
|
|
93
|
+
override connectedCallback() {
|
|
94
|
+
super.connectedCallback();
|
|
95
|
+
this.syncSlots();
|
|
96
|
+
this.childObserver.observe(this, {
|
|
97
|
+
childList: true,
|
|
98
|
+
attributes: true,
|
|
99
|
+
attributeFilter: ['slot'],
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
override disconnectedCallback() {
|
|
104
|
+
this.childObserver.disconnect();
|
|
105
|
+
super.disconnectedCallback();
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
// ── Private methods ──────────────────────────────────────────────────────
|
|
109
|
+
|
|
110
|
+
private syncSlots() {
|
|
111
|
+
const slots = Array.from(this.children).map(
|
|
112
|
+
child => child.getAttribute('slot') ?? '',
|
|
113
|
+
);
|
|
114
|
+
const filled = {
|
|
115
|
+
brand: slots.includes('brand'),
|
|
116
|
+
groups: slots.includes(''),
|
|
117
|
+
legal: slots.includes('legal'),
|
|
118
|
+
social: slots.includes('social'),
|
|
119
|
+
};
|
|
120
|
+
const changed = (Object.keys(filled) as (keyof typeof filled)[]).some(
|
|
121
|
+
key => filled[key] !== this.filled[key],
|
|
122
|
+
);
|
|
123
|
+
if (changed) this.filled = filled;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
// ── Render ───────────────────────────────────────────────────────────────
|
|
127
|
+
|
|
128
|
+
render() {
|
|
129
|
+
const { brand, groups, legal, social } = this.filled;
|
|
130
|
+
const top = brand || groups;
|
|
131
|
+
return html`<footer
|
|
132
|
+
class=${classMap({ footer: true, slim: !top })}
|
|
133
|
+
part="base"
|
|
134
|
+
>
|
|
135
|
+
<div class="inner">
|
|
136
|
+
<div class="top" part="top" ?hidden=${!top}>
|
|
137
|
+
<div class="brand" ?hidden=${!brand}><slot name="brand"></slot></div>
|
|
138
|
+
<div class="groups" part="groups" ?hidden=${!groups}>
|
|
139
|
+
<slot></slot>
|
|
140
|
+
</div>
|
|
141
|
+
</div>
|
|
142
|
+
<div class="bottom" part="bottom" ?hidden=${!legal && !social}>
|
|
143
|
+
<div class="legal" ?hidden=${!legal}><slot name="legal"></slot></div>
|
|
144
|
+
<div class="social" ?hidden=${!social}>
|
|
145
|
+
<slot name="social"></slot>
|
|
146
|
+
</div>
|
|
147
|
+
</div>
|
|
148
|
+
</div>
|
|
149
|
+
</footer>`;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { SiteHeader, type SiteHeaderCloseDetail } from './site-header.js';
|
|
2
|
+
export {
|
|
3
|
+
SiteNavMenu,
|
|
4
|
+
type SiteNavMenuCloseDetail,
|
|
5
|
+
type SiteNavMenuCloseReason,
|
|
6
|
+
} from './site-nav-menu.js';
|
|
7
|
+
export { SiteNavGroup } from './site-nav-group.js';
|
|
8
|
+
export { SiteNavLink } from './site-nav-link.js';
|