@apliteni/apliteni-ui 0.142.1 → 0.142.4
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/README.md +24 -36
- package/guidelines/state-set.md +4 -4
- package/package.json +3 -3
- package/react/dist/index.css +7 -3
- package/react/dist/index.js +12 -5
- package/src/index.d.ts +13 -96
- package/src/index.js +17 -30
- package/src/styles/command-palette.css +9 -5
- package/src/styles/drawer.css +8 -0
- package/src/styles/dropdown.css +30 -8
- package/src/styles/feedback.css +1 -1
- package/src/styles/filter-bar.css +5 -2
- package/src/styles/input.css +14 -15
- package/src/styles/layout.css +5 -2
- package/src/styles/table.css +28 -2
- package/src/styles/tap-zone.css +9 -4
- package/src/styles/topbar.css +8 -6
- package/src/components/account-nav.js +0 -37
- package/src/components/avatar.js +0 -53
- package/src/components/back.js +0 -57
- package/src/components/button-busy.js +0 -69
- package/src/components/command-palette.js +0 -471
- package/src/components/confirm.js +0 -131
- package/src/components/drawer.js +0 -169
- package/src/components/dropdown.js +0 -1055
- package/src/components/feedback.js +0 -171
- package/src/components/filter-bar.js +0 -86
- package/src/components/footer.js +0 -102
- package/src/components/index.js +0 -352
- package/src/components/loading.js +0 -127
- package/src/components/nav.js +0 -220
- package/src/components/overlay.js +0 -263
- package/src/components/pagination.js +0 -323
- package/src/components/segmented.js +0 -33
- package/src/components/shell.js +0 -511
- package/src/components/stat.js +0 -82
- package/src/components/success.js +0 -131
- package/src/components/table-values.js +0 -32
- package/src/components/tabs.js +0 -82
- package/src/components/toasts.js +0 -118
- package/src/components/tooltip.js +0 -347
- package/src/components/topbar.js +0 -270
|
@@ -1,171 +0,0 @@
|
|
|
1
|
-
// Inline feedback widget. Select a passage inside a content area, a "Give
|
|
2
|
-
// feedback" pill appears, click it to open a composer (quoted excerpt + note),
|
|
3
|
-
// Send calls your onSend() and shows a success / error state.
|
|
4
|
-
//
|
|
5
|
-
// document.body.insertAdjacentHTML('beforeend', feedbackWidget());
|
|
6
|
-
// wireFeedback({ container: 'main', onSend: async (p) => ({ ok: true }) });
|
|
7
|
-
//
|
|
8
|
-
// The kit owns everything visual + interactive; the app owns the backend
|
|
9
|
-
// (onSend does the POST / issue / whatever) and any deep-link shaping. Styles
|
|
10
|
-
// ship in styles/feedback.css (part of the kit stylesheet). Accent-aware.
|
|
11
|
-
import { esc } from './index.js';
|
|
12
|
-
import { playEntrance } from '../motion.js';
|
|
13
|
-
import { nearestSection } from '../logic/feedback.js';
|
|
14
|
-
|
|
15
|
-
export { nearestSection };
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
// Decorative, like every glyph in the kit — the pill and the buttons carry their
|
|
19
|
-
// own text or aria-label, so the SVGs stay out of the accessibility tree.
|
|
20
|
-
const IC_MSG = '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" focusable="false"><path d="M21 15a2 2 0 0 1-2 2H8l-4 4V5a2 2 0 0 1 2-2h13a2 2 0 0 1 2 2z"/></svg>';
|
|
21
|
-
const IC_LINES = '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" aria-hidden="true" focusable="false"><path d="M4 5h16M4 12h10M4 19h7"/></svg>';
|
|
22
|
-
const IC_X = '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" aria-hidden="true" focusable="false"><path d="M6 6l12 12M18 6L6 18"/></svg>';
|
|
23
|
-
const CHECK = '<svg class="ui-fbck" viewBox="0 0 150 150" aria-hidden="true"><path class="ui-fbck-t" d="M40 78l24 24 46-50"/><path class="ui-fbck-m" d="M40 78l24 24 46-50"/><path class="ui-fbck-s" d="M40 78l24 24 46-50"/></svg>';
|
|
24
|
-
// The widget markup — append once to the page (e.g. document.body). Copy is
|
|
25
|
-
// static here; behaviour + the dynamic chip/quote come from wireFeedback().
|
|
26
|
-
export function feedbackWidget({
|
|
27
|
-
label = 'Give feedback',
|
|
28
|
-
placeholder = "What's off, missing, or worth adding here?",
|
|
29
|
-
doneTitle = 'Feedback sent. Thank you!',
|
|
30
|
-
doneBody = 'Thanks — your note is on its way.',
|
|
31
|
-
} = {}) {
|
|
32
|
-
// The composer's Cancel/Send/Close use .ui-fbbtn, NOT the kit's button() — an
|
|
33
|
-
// intentional exception. They're internal to this self-contained widget and
|
|
34
|
-
// carry composer-scoped treatment button() doesn't model: a tighter footer
|
|
35
|
-
// size, the inline send-spinner, and a disabled-until-valid state wired by
|
|
36
|
-
// data-attributes. Promoting them to .ui-btn would regress the widget's look
|
|
37
|
-
// for no consumer gain, since the app never renders these buttons directly.
|
|
38
|
-
return `
|
|
39
|
-
<div class="ui-fbpill" data-fb-pill>${IC_MSG}${esc(label)}</div>
|
|
40
|
-
<div class="ui-fbscrim" data-fb-scrim></div>
|
|
41
|
-
<div class="ui-fbcomposer" data-fb-composer role="dialog" aria-modal="true" aria-label="Leave feedback">
|
|
42
|
-
<div data-fb-form>
|
|
43
|
-
<div class="ui-fbc__head">
|
|
44
|
-
<span class="ui-fbc__chip">${IC_LINES}<span data-fb-chip>this page</span></span>
|
|
45
|
-
<button type="button" class="ui-fbc__x" data-fb-close aria-label="Close">${IC_X}</button>
|
|
46
|
-
</div>
|
|
47
|
-
<div class="ui-fbc__quote"><span class="ui-fbc__qm">“</span><q data-fb-quote></q></div>
|
|
48
|
-
<div class="ui-fbc__body"><textarea data-fb-note maxlength="6000" placeholder="${esc(placeholder)}" aria-label="Your note"></textarea></div>
|
|
49
|
-
<div class="ui-fbc__err" data-fb-err></div>
|
|
50
|
-
<div class="ui-fbc__foot">
|
|
51
|
-
<button type="button" class="ui-fbbtn ghost" data-fb-cancel>Cancel</button>
|
|
52
|
-
<button type="button" class="ui-fbbtn primary" data-fb-send disabled><span class="ui-fbc__send" data-fb-sendlb>Send feedback</span></button>
|
|
53
|
-
</div>
|
|
54
|
-
</div>
|
|
55
|
-
<div class="ui-fbc__done" data-fb-done style="display:none">
|
|
56
|
-
<div class="ui-fbc__ck">${CHECK}</div>
|
|
57
|
-
<h4>${esc(doneTitle)}</h4>
|
|
58
|
-
<p>${esc(doneBody)}</p>
|
|
59
|
-
<div class="row"><button type="button" class="ui-fbbtn ghost" data-fb-done-close>Close</button></div>
|
|
60
|
-
</div>
|
|
61
|
-
</div>`;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
const defaultSection = (h) => {
|
|
65
|
-
if (!h) return { label: 'this page', title: '', anchor: '' };
|
|
66
|
-
const t = (h.textContent || '').replace(/\s+/g, ' ').trim();
|
|
67
|
-
return { label: t, title: t, anchor: h.id || '' };
|
|
68
|
-
};
|
|
69
|
-
|
|
70
|
-
// Wire the widget's behaviour. Call once after the markup is mounted.
|
|
71
|
-
// opts.container selector or element to watch (default 'main')
|
|
72
|
-
// opts.onSend async (payload) => { ok, error? } — required to submit
|
|
73
|
-
// opts.minChars minimum selection length to offer the pill (default 3)
|
|
74
|
-
// opts.section (headingEl) => { label, title, anchor } — override formatting
|
|
75
|
-
// payload = { note, excerpt, anchor, sectionLabel, sectionTitle }
|
|
76
|
-
export function wireFeedback(opts = {}) {
|
|
77
|
-
const container = typeof opts.container === 'string'
|
|
78
|
-
? document.querySelector(opts.container)
|
|
79
|
-
: (opts.container || document.querySelector('main'));
|
|
80
|
-
const pill = document.querySelector('[data-fb-pill]');
|
|
81
|
-
const scrim = document.querySelector('[data-fb-scrim]');
|
|
82
|
-
const composer = document.querySelector('[data-fb-composer]');
|
|
83
|
-
if (!container || !pill || !scrim || !composer) return; // widget not mounted
|
|
84
|
-
|
|
85
|
-
const q = (sel) => composer.querySelector(sel);
|
|
86
|
-
const chip = q('[data-fb-chip]'), quoteEl = q('[data-fb-quote]'), note = q('[data-fb-note]');
|
|
87
|
-
const form = q('[data-fb-form]'), done = q('[data-fb-done]');
|
|
88
|
-
const sendBtn = q('[data-fb-send]'), sendLb = q('[data-fb-sendlb]'), errEl = q('[data-fb-err]');
|
|
89
|
-
const minChars = opts.minChars == null ? 3 : opts.minChars;
|
|
90
|
-
const sectionFn = typeof opts.section === 'function' ? opts.section : defaultSection;
|
|
91
|
-
const onSend = typeof opts.onSend === 'function' ? opts.onSend : async () => ({ ok: false, error: 'No submit handler configured.' });
|
|
92
|
-
let pending = null, markSpan = null, opening = 0;
|
|
93
|
-
|
|
94
|
-
function showPill(range) {
|
|
95
|
-
const r = range.getBoundingClientRect();
|
|
96
|
-
if (!r.width && !r.height) return;
|
|
97
|
-
pill.style.left = (window.scrollX + r.left + r.width / 2) + 'px';
|
|
98
|
-
pill.style.top = (window.scrollY + r.top) + 'px';
|
|
99
|
-
pill.classList.add('show');
|
|
100
|
-
}
|
|
101
|
-
const hidePill = () => pill.classList.remove('show');
|
|
102
|
-
|
|
103
|
-
function onSelect() {
|
|
104
|
-
const sel = window.getSelection();
|
|
105
|
-
if (!sel || sel.isCollapsed || !sel.rangeCount) return hidePill();
|
|
106
|
-
const range = sel.getRangeAt(0);
|
|
107
|
-
if (!container.contains(range.commonAncestorContainer)) return hidePill();
|
|
108
|
-
const text = sel.toString().trim();
|
|
109
|
-
if (text.length < minChars) return hidePill();
|
|
110
|
-
const s = sectionFn(nearestSection(range.startContainer, container)) || {};
|
|
111
|
-
pending = { text, anchor: s.anchor || '', label: s.label || '', title: s.title || '', range: range.cloneRange() };
|
|
112
|
-
showPill(range);
|
|
113
|
-
}
|
|
114
|
-
container.addEventListener('mouseup', () => setTimeout(onSelect, 0));
|
|
115
|
-
container.addEventListener('keyup', (e) => { if (e.shiftKey || e.key === 'Shift') setTimeout(onSelect, 0); });
|
|
116
|
-
window.addEventListener('scroll', hidePill, { passive: true });
|
|
117
|
-
|
|
118
|
-
function highlight(range) {
|
|
119
|
-
try { markSpan = document.createElement('span'); markSpan.className = 'ui-fbmark'; range.surroundContents(markSpan); }
|
|
120
|
-
catch (e) { markSpan = null; }
|
|
121
|
-
}
|
|
122
|
-
function clearHighlight() {
|
|
123
|
-
if (markSpan && markSpan.parentNode) {
|
|
124
|
-
const p = markSpan.parentNode;
|
|
125
|
-
markSpan.replaceWith(document.createTextNode(markSpan.textContent));
|
|
126
|
-
p.normalize && p.normalize();
|
|
127
|
-
}
|
|
128
|
-
markSpan = null;
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
function open() {
|
|
132
|
-
if (!pending) return;
|
|
133
|
-
opening++;
|
|
134
|
-
hidePill();
|
|
135
|
-
quoteEl.textContent = pending.text.length > 200 ? pending.text.slice(0, 200) + '…' : pending.text;
|
|
136
|
-
chip.textContent = pending.label || 'this page';
|
|
137
|
-
note.value = ''; sendBtn.disabled = true; errEl.classList.remove('show');
|
|
138
|
-
form.style.display = ''; done.style.display = 'none'; sendLb.textContent = 'Send feedback';
|
|
139
|
-
highlight(pending.range);
|
|
140
|
-
window.getSelection().removeAllRanges();
|
|
141
|
-
scrim.classList.add('show'); composer.classList.add('show');
|
|
142
|
-
setTimeout(() => note.focus(), 60);
|
|
143
|
-
}
|
|
144
|
-
pill.addEventListener('mousedown', (e) => e.preventDefault());
|
|
145
|
-
pill.addEventListener('click', open);
|
|
146
|
-
|
|
147
|
-
function close() { opening++; composer.classList.remove('show'); scrim.classList.remove('show'); clearHighlight(); pending = null; }
|
|
148
|
-
q('[data-fb-close]').addEventListener('click', close);
|
|
149
|
-
q('[data-fb-cancel]').addEventListener('click', close);
|
|
150
|
-
q('[data-fb-done-close]').addEventListener('click', close);
|
|
151
|
-
scrim.addEventListener('click', close);
|
|
152
|
-
document.addEventListener('keydown', (e) => { if (e.key === 'Escape' && composer.classList.contains('show')) close(); });
|
|
153
|
-
note.addEventListener('input', () => { sendBtn.disabled = note.value.trim().length === 0; });
|
|
154
|
-
|
|
155
|
-
function fail(msg) {
|
|
156
|
-
errEl.textContent = msg || 'Could not send just now — try again in a moment.';
|
|
157
|
-
errEl.classList.add('show'); playEntrance(errEl); sendLb.textContent = 'Send feedback'; sendBtn.disabled = false;
|
|
158
|
-
}
|
|
159
|
-
sendBtn.addEventListener('click', async () => {
|
|
160
|
-
if (sendBtn.disabled || !pending) return;
|
|
161
|
-
const sentOpening = opening;
|
|
162
|
-
errEl.classList.remove('show'); sendBtn.disabled = true; sendLb.innerHTML = '<span class="ui-fbspin"></span>Sending';
|
|
163
|
-
const payload = { note: note.value.trim(), excerpt: pending.text, anchor: pending.anchor, sectionLabel: pending.label, sectionTitle: pending.title };
|
|
164
|
-
try {
|
|
165
|
-
const res = await onSend(payload);
|
|
166
|
-
if (opening !== sentOpening) return;
|
|
167
|
-
if (!res || !res.ok) { fail(res && res.error); return; }
|
|
168
|
-
form.style.display = 'none'; done.style.display = ''; clearHighlight();
|
|
169
|
-
} catch (e) { if (opening === sentOpening) fail(); }
|
|
170
|
-
});
|
|
171
|
-
}
|
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
import { button, esc } from './index.js';
|
|
2
|
-
import { dropdown, wireDropdown } from './dropdown.js';
|
|
3
|
-
import { filterChipText, filterChipName, filterChipUnset, filterChipItems, focusNextStop } from '../logic/filter-bar.js';
|
|
4
|
-
|
|
5
|
-
export function filterBar({ filters = [], label = 'Filters', clearLabel = 'Clear all', clearVariant = 'ghost', disabled = false, busy = false } = {}) {
|
|
6
|
-
return `<fieldset class="ui-filter-bar" data-filter-bar${disabled || busy ? ' disabled' : ''}${busy ? ' aria-busy="true"' : ''}>`
|
|
7
|
-
+ `<legend class="ui-filter-bar__legend">${esc(label)}</legend>`
|
|
8
|
-
+ filters.map(filter => `<fieldset class="ui-filter-bar__chip" data-filter-id="${esc(filter.id)}"${filter.disabled ? ' disabled' : ''}>`
|
|
9
|
-
+ `<legend class="ui-filter-bar__legend">${esc(filter.label)}</legend>`
|
|
10
|
-
+ dropdown({ items: filterChipItems(filter), variant: 'select',
|
|
11
|
-
// The chip prints one line; the field's name reaches a reader through the
|
|
12
|
-
// trigger's name and the chip's own legend. why: docs/components.md#dense-financial-tables
|
|
13
|
-
triggerContent: `<span class="${filterChipUnset(filter) ? 'ui-dropdown__value is-placeholder' : 'ui-dropdown__value'}">${esc(filterChipText(filter))}</span>`,
|
|
14
|
-
ariaLabel: filterChipName(filter), open: !!filter.open && !disabled && !busy && !filter.disabled })
|
|
15
|
-
+ `<button type="button" class="ui-filter-bar__remove" data-filter-remove aria-label="${esc(`Remove ${filter.label} filter`)}">×</button></fieldset>`).join('')
|
|
16
|
-
// Nothing to clear, no control: an unavailable action standing in an empty
|
|
17
|
-
// row is the only thing in it, and it reads as a bar that has been turned
|
|
18
|
-
// off rather than one with no filters on it. It is the kit's own `one-page`
|
|
19
|
-
// rule — a control with no action to offer is not shown. It returns with
|
|
20
|
-
// the first chip, as a quiet text action.
|
|
21
|
-
// why: docs/components.md#a-filter-row-holds-its-panels
|
|
22
|
-
+ (filters.length
|
|
23
|
-
? `<span data-filter-clear>${button({ label: clearLabel, size: 'sm', variant: clearVariant })}</span>`
|
|
24
|
-
: '')
|
|
25
|
-
+ '</fieldset>';
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
// The host stays mounted; update() restores the action's focus after controlled removal.
|
|
29
|
-
export function initFilterBar(host, options = {}) {
|
|
30
|
-
let current = options;
|
|
31
|
-
const focusKey = () => {
|
|
32
|
-
const active = host.ownerDocument.activeElement;
|
|
33
|
-
if (!host.contains(active)) return null;
|
|
34
|
-
const chip = active.closest('[data-filter-id]');
|
|
35
|
-
return { id: chip?.dataset.filterId, remove: active.hasAttribute('data-filter-remove'),
|
|
36
|
-
index: [...host.querySelectorAll('[data-filter-id]')].indexOf(chip) };
|
|
37
|
-
};
|
|
38
|
-
const wire = () => wireDropdown(host);
|
|
39
|
-
const update = next => {
|
|
40
|
-
const focus = focusKey();
|
|
41
|
-
current = next;
|
|
42
|
-
host.innerHTML = filterBar(next); wire();
|
|
43
|
-
if (!focus) return;
|
|
44
|
-
const chips = [...host.querySelectorAll('[data-filter-id]')].filter(c => !c.disabled);
|
|
45
|
-
const same = chips.find(c => c.dataset.filterId === focus.id);
|
|
46
|
-
const target = same || chips[Math.min(Math.max(focus.index, 0), chips.length - 1)];
|
|
47
|
-
const control = target?.querySelector(same && focus.remove ? '[data-filter-remove]' : '[data-dropdown-trigger]')
|
|
48
|
-
|| host.querySelector('[data-filter-clear] button');
|
|
49
|
-
if (control && !control.disabled && !control.closest('fieldset:disabled')) control.focus();
|
|
50
|
-
// No control of its own left to hold it: the shared pair decides where the
|
|
51
|
-
// focus goes and checks that it arrived. why: src/logic/filter-bar.js
|
|
52
|
-
else focusNextStop(host);
|
|
53
|
-
};
|
|
54
|
-
const emit = (type, detail) => host.dispatchEvent(new host.ownerDocument.defaultView.CustomEvent(type, { bubbles: true, detail }));
|
|
55
|
-
const click = e => {
|
|
56
|
-
if (e.target.closest('fieldset:disabled')) return;
|
|
57
|
-
const chip = e.target.closest('[data-filter-id]');
|
|
58
|
-
if (e.target.closest('[data-filter-remove]')) emit('ui-filter-remove', { id: chip.dataset.filterId });
|
|
59
|
-
else if (e.target.closest('[data-filter-clear] button')) emit('ui-filter-clear', {});
|
|
60
|
-
// A chip's menu only. The catalogue a vanilla page draws under `data-filter-add` is the
|
|
61
|
-
// page's own, and a pick in it names no chip: reported as a change, it had a consumer
|
|
62
|
-
// mapping over its filters and writing the catalogue's value into every one of them. #518
|
|
63
|
-
else if (e.target.closest('[data-dd-item]') && !e.target.closest('[data-filter-add]')) {
|
|
64
|
-
const item = e.target.closest('[data-dd-item]');
|
|
65
|
-
if (item.getAttribute('aria-disabled') !== 'true') {
|
|
66
|
-
const id = chip?.dataset.filterId, value = item.dataset.value;
|
|
67
|
-
// Dropdown completes its own close/focus before the consumer replaces the markup.
|
|
68
|
-
queueMicrotask(() => {
|
|
69
|
-
// Dropdown writes the picked row's label into the trigger; the name it is
|
|
70
|
-
// read by follows it, so the two cannot disagree while the consumer answers.
|
|
71
|
-
const filter = (current.filters || []).find(f => f.id === id);
|
|
72
|
-
const trigger = chip?.querySelector('[data-dropdown-trigger]');
|
|
73
|
-
const span = trigger?.querySelector('.ui-dropdown__value');
|
|
74
|
-
const shown = span?.textContent;
|
|
75
|
-
if (filter && trigger) trigger.setAttribute('aria-label', filterChipName({ ...filter, value: shown }));
|
|
76
|
-
// A chip that was empty stops being a placeholder the moment it shows a pick.
|
|
77
|
-
if (span) span.classList.toggle('is-placeholder', filterChipUnset({ value: shown }));
|
|
78
|
-
emit('ui-filter-change', { id, value });
|
|
79
|
-
});
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
};
|
|
83
|
-
if (!host.querySelector('[data-filter-bar]')) host.innerHTML = filterBar(current);
|
|
84
|
-
host.addEventListener('click', click, true); wire();
|
|
85
|
-
return { update, destroy: () => host.removeEventListener('click', click, true) };
|
|
86
|
-
}
|
package/src/components/footer.js
DELETED
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
// Footer factory — the canonical site/app footer as an HTML string, matching the
|
|
2
|
-
// topbar idiom so any server-render consumer adopts it with no framework.
|
|
3
|
-
// Composes a brand lockup, grouped link columns, a legal/copyright row, optional
|
|
4
|
-
// social icons and an optional theme/accent switcher slot. Three variants:
|
|
5
|
-
// full — multi-column marketing footer (brand + columns + legal bar)
|
|
6
|
-
// slim — a single legal/copyright row
|
|
7
|
-
// app — compact, in-product (tight padding, surface background)
|
|
8
|
-
import { brand as brandLockup } from '../assets/brand.js';
|
|
9
|
-
import { esc } from './index.js';
|
|
10
|
-
import { safeUrl } from '../html.js';
|
|
11
|
-
const cx = (...a) => a.filter(Boolean).join(' ');
|
|
12
|
-
|
|
13
|
-
// Minimal brand-glyph set for the optional social row. Feather-ish where generic,
|
|
14
|
-
// simplified brand marks otherwise. Kept local so the footer is self-contained
|
|
15
|
-
// (the shared icon set is line-only and has no brand glyphs).
|
|
16
|
-
// LinkedIn: Font Awesome Free brands/linkedin.svg, CC BY 4.0.
|
|
17
|
-
const SOCIAL = {
|
|
18
|
-
github: '<path d="M12 2a10 10 0 0 0-3.16 19.49c.5.09.68-.22.68-.48v-1.7c-2.78.6-3.37-1.34-3.37-1.34-.45-1.16-1.11-1.47-1.11-1.47-.9-.62.07-.6.07-.6 1 .07 1.53 1.03 1.53 1.03.9 1.53 2.34 1.09 2.91.83.09-.65.35-1.09.63-1.34-2.22-.25-4.55-1.11-4.55-4.94 0-1.09.39-1.98 1.03-2.68-.1-.25-.45-1.27.1-2.64 0 0 .84-.27 2.75 1.02a9.5 9.5 0 0 1 5 0c1.91-1.29 2.75-1.02 2.75-1.02.55 1.37.2 2.39.1 2.64.64.7 1.03 1.59 1.03 2.68 0 3.84-2.34 4.68-4.57 4.93.36.31.68.92.68 1.85v2.74c0 .27.18.58.69.48A10 10 0 0 0 12 2z"/>',
|
|
19
|
-
x: '<path d="M4 3h4.5l4 5.5L17.5 3H21l-6.5 8.5L21 21h-4.5l-4.3-5.9L7 21H3.5l6.8-8.9z"/>',
|
|
20
|
-
linkedin: '<path d="M416 32H31.9C14.3 32 0 46.5 0 64.3v383.4C0 465.5 14.3 480 31.9 480H416c17.6 0 32-14.5 32-32.3V64.3c0-17.8-14.4-32.3-32-32.3zM135.4 416H69V202.2h66.5V416zm-33.2-243c-21.3 0-38.5-17.3-38.5-38.5S80.9 96 102.2 96c21.2 0 38.5 17.3 38.5 38.5 0 21.3-17.2 38.5-38.5 38.5zm282.1 243h-66.4V312c0-24.8-.5-56.7-34.5-56.7-34.6 0-39.9 27-39.9 54.9V416h-66.4V202.2h63.7v29.2h.9c8.9-16.8 30.6-34.5 62.9-34.5 67.2 0 79.7 44.3 79.7 101.9V416z"/>',
|
|
21
|
-
mail: '<rect x="3" y="5" width="18" height="14" rx="2" fill="none" stroke="currentColor" stroke-width="1.7"/><path d="m3 7 9 6 9-6" fill="none" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round"/>',
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
function socialLink({ label, href = '#', icon: ic = 'github' } = {}) {
|
|
25
|
-
const glyph = SOCIAL[ic] || SOCIAL.github;
|
|
26
|
-
const fill = ic === 'mail' ? 'none' : 'currentColor';
|
|
27
|
-
const viewBox = ic === 'linkedin' ? '0 0 448 512' : '0 0 24 24';
|
|
28
|
-
return `<a class="ui-footer__social" href="${esc(safeUrl(href))}" aria-label="${esc(label || ic)}">` +
|
|
29
|
-
`<svg viewBox="${viewBox}" fill="${fill}" aria-hidden="true">${glyph}</svg></a>`;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
function linkList(links = []) {
|
|
33
|
-
return `<ul class="ui-footer__links">${links.map(({ label, href = '#', target }) =>
|
|
34
|
-
`<li><a href="${esc(safeUrl(href))}"${target ? ` target="${esc(target)}" rel="noreferrer"` : ''}>${esc(label)}</a></li>`).join('')}</ul>`;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
// The column title is an h2: it names a top-level section of the page's end
|
|
38
|
-
// matter, and h2 is the one rank that cannot skip whatever heading came before
|
|
39
|
-
// it. It was an h4 — the only h4 the kit drew — which read h2 → h4 on the
|
|
40
|
-
// landing page and left a rank a reader hears missing. The look is the class's,
|
|
41
|
-
// not the tag's. why: guidelines/the-page.md#the-page
|
|
42
|
-
function column({ title, links = [] } = {}) {
|
|
43
|
-
return `<div class="ui-footer__col">` +
|
|
44
|
-
(title ? `<h2 class="ui-footer__col-title">${esc(title)}</h2>` : '') +
|
|
45
|
-
linkList(links) + `</div>`;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
// Inline legal row (label + legal links + switcher slot). Shared by every variant.
|
|
49
|
-
function legalBar({ legal, legalLinks = [], switcher = '' } = {}) {
|
|
50
|
-
const links = legalLinks.length
|
|
51
|
-
? `<nav class="ui-footer__legal-links" aria-label="Legal">` +
|
|
52
|
-
legalLinks.map(({ label, href = '#' }) => `<a href="${esc(safeUrl(href))}">${esc(label)}</a>`).join('') + `</nav>`
|
|
53
|
-
: '';
|
|
54
|
-
const sw = switcher ? `<div class="ui-footer__switcher">${switcher}</div>` : '';
|
|
55
|
-
return `<div class="ui-footer__bar">` +
|
|
56
|
-
`<span class="ui-footer__legal">${esc(legal)}</span>` +
|
|
57
|
-
`${links}${sw}</div>`;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
// Full footer. Pass which pieces to include; everything but `variant` is optional.
|
|
61
|
-
// brand — lockup options object ({ word, href }) or false to hide it
|
|
62
|
-
// tagline — short line under the brand (full variant only)
|
|
63
|
-
// columns — [{ title, links: [{ label, href, target }] }]
|
|
64
|
-
// social — [{ label, href, icon }] (icon: github|x|linkedin|mail)
|
|
65
|
-
// legal — copyright text (defaults to "© <year> Apliteni")
|
|
66
|
-
// legalLinks — [{ label, href }] inline row links
|
|
67
|
-
// switcher — trusted HTML slot (e.g. accentPicker()+themeToggle()), or ''
|
|
68
|
-
export function footer({
|
|
69
|
-
variant = 'full',
|
|
70
|
-
brand = { word: 'Strategy' },
|
|
71
|
-
tagline = '',
|
|
72
|
-
columns = [],
|
|
73
|
-
social = [],
|
|
74
|
-
legal = `© ${new Date().getFullYear()} Apliteni`,
|
|
75
|
-
legalLinks = [],
|
|
76
|
-
switcher = '',
|
|
77
|
-
} = {}) {
|
|
78
|
-
const cls = cx('ui-footer', `ui-footer--${variant}`);
|
|
79
|
-
|
|
80
|
-
// slim + app: a single legal row, no brand block or columns.
|
|
81
|
-
if (variant === 'slim' || variant === 'app') {
|
|
82
|
-
return `<footer class="${esc(cls)}" role="contentinfo"><div class="ui-footer__in">` +
|
|
83
|
-
legalBar({ legal, legalLinks, switcher }) +
|
|
84
|
-
`</div></footer>`;
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
// full: brand block + link columns on top, legal bar below a divider.
|
|
88
|
-
const socialRow = social.length
|
|
89
|
-
? `<div class="ui-footer__socials">${social.map(socialLink).join('')}</div>` : '';
|
|
90
|
-
const brandBlock = brand !== false
|
|
91
|
-
? `<div class="ui-footer__brand">${brandLockup(brand)}` +
|
|
92
|
-
(tagline ? `<p class="ui-footer__tagline">${esc(tagline)}</p>` : '') +
|
|
93
|
-
socialRow + `</div>`
|
|
94
|
-
: '';
|
|
95
|
-
const nav = columns.length
|
|
96
|
-
? `<nav class="ui-footer__nav" aria-label="Footer">${columns.map(column).join('')}</nav>` : '';
|
|
97
|
-
|
|
98
|
-
return `<footer class="${esc(cls)}" role="contentinfo"><div class="ui-footer__in">` +
|
|
99
|
-
`<div class="ui-footer__top">${brandBlock}${nav}</div>` +
|
|
100
|
-
legalBar({ legal, legalLinks, switcher }) +
|
|
101
|
-
`</div></footer>`;
|
|
102
|
-
}
|