@auriel/peppertino 0.2.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.txt +122 -56
- package/README.md +333 -38
- package/dist/accordion.js +51 -0
- package/dist/accordion.js.map +7 -0
- package/dist/carousel.js +152 -0
- package/dist/carousel.js.map +7 -0
- package/dist/header.js +30 -3
- package/dist/header.js.map +2 -2
- package/dist/main.css +4660 -710
- package/dist/main.css.map +1 -1
- package/dist/modal.js +61 -2
- package/dist/modal.js.map +2 -2
- package/dist/peppertino.js +477 -17
- package/dist/peppertino.js.map +4 -4
- package/dist/select.js +25 -8
- package/dist/select.js.map +3 -3
- package/dist/tabs.js +31 -4
- package/dist/tabs.js.map +2 -2
- package/dist/validation.js +130 -0
- package/dist/validation.js.map +7 -0
- package/index.html +1493 -42
- package/package.json +1 -1
- package/src/js/accordion.js +61 -0
- package/src/js/carousel.js +148 -0
- package/src/js/peppertino.js +4 -0
- package/src/js/validation.js +132 -0
- package/src/scss/accordion.scss +156 -0
- package/src/scss/alert.scss +204 -0
- package/src/scss/base.scss +130 -16
- package/src/scss/card.scss +4 -4
- package/src/scss/carousel.scss +313 -0
- package/src/scss/dark-mode.scss +474 -0
- package/src/scss/footer.scss +224 -0
- package/src/scss/forms/fieldset.scss +127 -0
- package/src/scss/forms/form-instructions.scss +133 -0
- package/src/scss/forms/label.scss +115 -0
- package/src/scss/forms/text-field.scss +240 -0
- package/src/scss/forms/validation.scss +215 -0
- package/src/scss/forms.scss +8 -0
- package/src/scss/header.scss +8 -8
- package/src/scss/main.scss +7 -0
- package/src/scss/section.scss +1 -1
- package/src/scss/select.scss +5 -5
- package/src/scss/table.scss +5 -5
- package/src/scss/utilities.scss +243 -0
- package/.claude/settings.local.json +0 -8
package/package.json
CHANGED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
(function () {
|
|
2
|
+
document.querySelectorAll('.pp-accordion').forEach((accordion) => {
|
|
3
|
+
const allowMultiple = accordion.hasAttribute('data-allow-multiple');
|
|
4
|
+
|
|
5
|
+
accordion.querySelectorAll('.pp-accordion__trigger').forEach((trigger) => {
|
|
6
|
+
const panelId = trigger.getAttribute('aria-controls');
|
|
7
|
+
const panel = panelId
|
|
8
|
+
? document.getElementById(panelId)
|
|
9
|
+
: trigger.nextElementSibling;
|
|
10
|
+
|
|
11
|
+
if (!panel) return;
|
|
12
|
+
|
|
13
|
+
// Ensure ARIA state matches DOM on init
|
|
14
|
+
const isOpen = trigger.getAttribute('aria-expanded') === 'true';
|
|
15
|
+
panel.setAttribute('aria-hidden', isOpen ? 'false' : 'true');
|
|
16
|
+
if (isOpen) panel.classList.add('is-open');
|
|
17
|
+
|
|
18
|
+
trigger.addEventListener('click', () => {
|
|
19
|
+
const expanded = trigger.getAttribute('aria-expanded') === 'true';
|
|
20
|
+
|
|
21
|
+
if (!allowMultiple) {
|
|
22
|
+
accordion.querySelectorAll('.pp-accordion__trigger').forEach((t) => {
|
|
23
|
+
if (t === trigger) return;
|
|
24
|
+
t.setAttribute('aria-expanded', 'false');
|
|
25
|
+
const p = t.getAttribute('aria-controls')
|
|
26
|
+
? document.getElementById(t.getAttribute('aria-controls'))
|
|
27
|
+
: t.nextElementSibling;
|
|
28
|
+
if (p) {
|
|
29
|
+
p.setAttribute('aria-hidden', 'true');
|
|
30
|
+
p.classList.remove('is-open');
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const next = !expanded;
|
|
36
|
+
trigger.setAttribute('aria-expanded', String(next));
|
|
37
|
+
panel.setAttribute('aria-hidden', String(!next));
|
|
38
|
+
panel.classList.toggle('is-open', next);
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
// Keyboard: Home/End focus management within accordion
|
|
42
|
+
trigger.addEventListener('keydown', (e) => {
|
|
43
|
+
const triggers = [...accordion.querySelectorAll('.pp-accordion__trigger')];
|
|
44
|
+
const idx = triggers.indexOf(trigger);
|
|
45
|
+
if (e.key === 'ArrowDown') {
|
|
46
|
+
e.preventDefault();
|
|
47
|
+
triggers[(idx + 1) % triggers.length].focus();
|
|
48
|
+
} else if (e.key === 'ArrowUp') {
|
|
49
|
+
e.preventDefault();
|
|
50
|
+
triggers[(idx - 1 + triggers.length) % triggers.length].focus();
|
|
51
|
+
} else if (e.key === 'Home') {
|
|
52
|
+
e.preventDefault();
|
|
53
|
+
triggers[0].focus();
|
|
54
|
+
} else if (e.key === 'End') {
|
|
55
|
+
e.preventDefault();
|
|
56
|
+
triggers[triggers.length - 1].focus();
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
});
|
|
60
|
+
});
|
|
61
|
+
})();
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
// PeppertinoCSS — Carousel
|
|
2
|
+
|
|
3
|
+
(function () {
|
|
4
|
+
function initCarousel(root, rootIdx) {
|
|
5
|
+
const track = root.querySelector('.pp-carousel__track');
|
|
6
|
+
const slides = [...root.querySelectorAll('.pp-carousel__slide')];
|
|
7
|
+
const dots = [...root.querySelectorAll('.pp-carousel__dot')];
|
|
8
|
+
const prevBtn = root.querySelector('.pp-carousel__prev');
|
|
9
|
+
const nextBtn = root.querySelector('.pp-carousel__next');
|
|
10
|
+
const autoplayBtn = root.querySelector('.pp-carousel__autoplay');
|
|
11
|
+
|
|
12
|
+
if (!track || !slides.length) return;
|
|
13
|
+
|
|
14
|
+
const total = slides.length;
|
|
15
|
+
let current = 0;
|
|
16
|
+
|
|
17
|
+
if (!root.getAttribute('role')) root.setAttribute('role', 'region');
|
|
18
|
+
if (!root.getAttribute('aria-roledescription')) root.setAttribute('aria-roledescription', 'carousel');
|
|
19
|
+
if (!root.getAttribute('aria-label') && !root.getAttribute('aria-labelledby')) {
|
|
20
|
+
root.setAttribute('aria-label', root.dataset.label || `Carousel ${rootIdx + 1}`);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
track.setAttribute('aria-live', 'off');
|
|
24
|
+
|
|
25
|
+
slides.forEach((slide, i) => {
|
|
26
|
+
slide.setAttribute('role', 'group');
|
|
27
|
+
if (!slide.getAttribute('aria-roledescription')) slide.setAttribute('aria-roledescription', 'slide');
|
|
28
|
+
if (!slide.getAttribute('aria-label')) slide.setAttribute('aria-label', `${i + 1} of ${total}`);
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
let announcer = root.querySelector('.pp-carousel__announcer');
|
|
32
|
+
if (!announcer) {
|
|
33
|
+
announcer = document.createElement('div');
|
|
34
|
+
announcer.className = 'pp-carousel__announcer';
|
|
35
|
+
root.appendChild(announcer);
|
|
36
|
+
}
|
|
37
|
+
announcer.setAttribute('aria-live', 'polite');
|
|
38
|
+
announcer.setAttribute('aria-atomic', 'true');
|
|
39
|
+
|
|
40
|
+
dots.forEach((dot, i) => {
|
|
41
|
+
if (!dot.id) dot.id = `pp-carousel-${rootIdx}-dot-${i}`;
|
|
42
|
+
if (!dot.getAttribute('aria-label')) dot.setAttribute('aria-label', `Go to slide ${i + 1}`);
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
if (prevBtn && !prevBtn.getAttribute('aria-label')) prevBtn.setAttribute('aria-label', 'Previous slide');
|
|
46
|
+
if (nextBtn && !nextBtn.getAttribute('aria-label')) nextBtn.setAttribute('aria-label', 'Next slide');
|
|
47
|
+
|
|
48
|
+
function syncUI(idx) {
|
|
49
|
+
current = idx;
|
|
50
|
+
|
|
51
|
+
slides.forEach((slide, i) => slide.setAttribute('aria-hidden', String(i !== idx)));
|
|
52
|
+
|
|
53
|
+
dots.forEach((dot, i) => {
|
|
54
|
+
dot.classList.toggle('is-active', i === idx);
|
|
55
|
+
dot.setAttribute('aria-current', String(i === idx));
|
|
56
|
+
dot.setAttribute('tabindex', i === idx ? '0' : '-1');
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
if (prevBtn) {
|
|
60
|
+
prevBtn.disabled = idx === 0;
|
|
61
|
+
prevBtn.setAttribute('aria-disabled', String(idx === 0));
|
|
62
|
+
}
|
|
63
|
+
if (nextBtn) {
|
|
64
|
+
nextBtn.disabled = idx === total - 1;
|
|
65
|
+
nextBtn.setAttribute('aria-disabled', String(idx === total - 1));
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
const label = slides[idx].getAttribute('aria-label') || `Slide ${idx + 1}`;
|
|
69
|
+
announcer.textContent = '';
|
|
70
|
+
requestAnimationFrame(() => { announcer.textContent = label; });
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
const observer = new IntersectionObserver(
|
|
74
|
+
(entries) => {
|
|
75
|
+
entries.forEach((entry) => {
|
|
76
|
+
if (entry.isIntersecting) {
|
|
77
|
+
const idx = slides.indexOf(entry.target);
|
|
78
|
+
if (idx !== -1 && idx !== current) syncUI(idx);
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
},
|
|
82
|
+
{ root: track, threshold: 0.5 }
|
|
83
|
+
);
|
|
84
|
+
slides.forEach((slide) => observer.observe(slide));
|
|
85
|
+
|
|
86
|
+
function goTo(idx) {
|
|
87
|
+
const clamped = Math.max(0, Math.min(total - 1, idx));
|
|
88
|
+
slides[clamped].scrollIntoView({ behavior: 'smooth', block: 'nearest', inline: 'start' });
|
|
89
|
+
syncUI(clamped);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
if (prevBtn) prevBtn.addEventListener('click', () => goTo(current - 1));
|
|
93
|
+
if (nextBtn) nextBtn.addEventListener('click', () => goTo(current + 1));
|
|
94
|
+
|
|
95
|
+
dots.forEach((dot, i) => {
|
|
96
|
+
dot.addEventListener('click', () => goTo(i));
|
|
97
|
+
dot.addEventListener('keydown', (e) => {
|
|
98
|
+
if (e.key === 'ArrowRight' || e.key === 'ArrowDown') {
|
|
99
|
+
e.preventDefault(); goTo((i + 1) % total); dots[(i + 1) % total].focus();
|
|
100
|
+
}
|
|
101
|
+
if (e.key === 'ArrowLeft' || e.key === 'ArrowUp') {
|
|
102
|
+
e.preventDefault(); goTo((i - 1 + total) % total); dots[(i - 1 + total) % total].focus();
|
|
103
|
+
}
|
|
104
|
+
if (e.key === 'Home') { e.preventDefault(); goTo(0); dots[0].focus(); }
|
|
105
|
+
if (e.key === 'End') { e.preventDefault(); goTo(total - 1); dots[total - 1].focus(); }
|
|
106
|
+
});
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
if (autoplayBtn) {
|
|
110
|
+
autoplayBtn.addEventListener('click', () => {
|
|
111
|
+
const playing = root.classList.contains('pp-carousel--playing');
|
|
112
|
+
root.classList.toggle('pp-carousel--playing', !playing);
|
|
113
|
+
root.classList.toggle('pp-carousel--paused', playing);
|
|
114
|
+
autoplayBtn.setAttribute('aria-pressed', String(!playing));
|
|
115
|
+
autoplayBtn.setAttribute('aria-label', playing ? 'Start autoplay' : 'Pause autoplay');
|
|
116
|
+
root.dispatchEvent(new CustomEvent('pp-carousel:autoplay', { bubbles: true, detail: { playing: !playing } }));
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
track.setAttribute('tabindex', '0');
|
|
121
|
+
track.addEventListener('keydown', (e) => {
|
|
122
|
+
if (e.key === 'ArrowRight') { e.preventDefault(); goTo(current + 1); }
|
|
123
|
+
if (e.key === 'ArrowLeft') { e.preventDefault(); goTo(current - 1); }
|
|
124
|
+
if (e.key === 'Home') { e.preventDefault(); goTo(0); }
|
|
125
|
+
if (e.key === 'End') { e.preventDefault(); goTo(total - 1); }
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
syncUI(0);
|
|
129
|
+
|
|
130
|
+
return { goTo, current: () => current, total };
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
const instances = {};
|
|
134
|
+
document.querySelectorAll('.pp-carousel').forEach((el, i) => {
|
|
135
|
+
const id = el.id || `pp-carousel-${i}`;
|
|
136
|
+
const api = initCarousel(el, i);
|
|
137
|
+
if (api) instances[id] = api;
|
|
138
|
+
});
|
|
139
|
+
|
|
140
|
+
window.ppCarousel = {
|
|
141
|
+
get(ref) {
|
|
142
|
+
if (typeof ref === 'string') return instances[ref];
|
|
143
|
+
if (ref instanceof Element) return instances[ref.id] || Object.values(instances).find((_, k) => document.getElementById(Object.keys(instances)[k]) === ref);
|
|
144
|
+
return null;
|
|
145
|
+
},
|
|
146
|
+
instances,
|
|
147
|
+
};
|
|
148
|
+
})();
|
package/src/js/peppertino.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
// PeppertinoCSS — aggregator
|
|
2
2
|
// Imports all JS components so users can include a single <script> tag.
|
|
3
|
+
// Each component is a self-contained IIFE in its own file — import only what you need.
|
|
3
4
|
|
|
5
|
+
import './accordion.js';
|
|
6
|
+
import './carousel.js';
|
|
4
7
|
import './header.js';
|
|
5
8
|
import './modal.js';
|
|
6
9
|
import './select.js';
|
|
7
10
|
import './tabs.js';
|
|
11
|
+
import './validation.js';
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
// PeppertinoCSS — Validation
|
|
2
|
+
|
|
3
|
+
(function () {
|
|
4
|
+
function getField(input) { return input.closest('.pp-field'); }
|
|
5
|
+
function getMessageEl(field) { return field ? field.querySelector('.pp-field__message') : null; }
|
|
6
|
+
function getHintEl(field) { return field ? field.querySelector('.pp-field__hint') : null; }
|
|
7
|
+
|
|
8
|
+
function buildDescribedBy(field) {
|
|
9
|
+
const ids = [];
|
|
10
|
+
const hint = getHintEl(field);
|
|
11
|
+
const msg = getMessageEl(field);
|
|
12
|
+
if (hint && hint.id) ids.push(hint.id);
|
|
13
|
+
if (msg && msg.id) ids.push(msg.id);
|
|
14
|
+
return ids.join(' ');
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
function ensureIds(field, input) {
|
|
18
|
+
const base = input.id || `pp-field-${Math.random().toString(36).slice(2, 7)}`;
|
|
19
|
+
const hint = getHintEl(field);
|
|
20
|
+
const msg = getMessageEl(field);
|
|
21
|
+
if (hint && !hint.id) hint.id = `${base}-hint`;
|
|
22
|
+
if (msg && !msg.id) msg.id = `${base}-msg`;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function setError(input, message) {
|
|
26
|
+
const field = getField(input);
|
|
27
|
+
if (!field) return;
|
|
28
|
+
ensureIds(field, input);
|
|
29
|
+
field.classList.remove('pp-field--success', 'pp-field--warning', 'pp-field--validating');
|
|
30
|
+
field.classList.add('pp-field--error');
|
|
31
|
+
input.setAttribute('aria-invalid', 'true');
|
|
32
|
+
let msg = getMessageEl(field);
|
|
33
|
+
if (!msg) {
|
|
34
|
+
msg = document.createElement('span');
|
|
35
|
+
msg.className = 'pp-field__message';
|
|
36
|
+
msg.id = `${input.id || 'field'}-msg`;
|
|
37
|
+
msg.setAttribute('role', 'alert');
|
|
38
|
+
field.appendChild(msg);
|
|
39
|
+
}
|
|
40
|
+
msg.textContent = message;
|
|
41
|
+
input.setAttribute('aria-describedby', buildDescribedBy(field));
|
|
42
|
+
field.dispatchEvent(new CustomEvent('pp-field:error', { bubbles: true, detail: { input, message } }));
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function clearError(input) {
|
|
46
|
+
const field = getField(input);
|
|
47
|
+
if (!field) return;
|
|
48
|
+
field.classList.remove('pp-field--error', 'pp-field--validating');
|
|
49
|
+
input.setAttribute('aria-invalid', 'false');
|
|
50
|
+
const msg = getMessageEl(field);
|
|
51
|
+
if (msg) msg.textContent = '';
|
|
52
|
+
input.setAttribute('aria-describedby', buildDescribedBy(field));
|
|
53
|
+
field.dispatchEvent(new CustomEvent('pp-field:clear', { bubbles: true, detail: { input } }));
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function setSuccess(input, message) {
|
|
57
|
+
const field = getField(input);
|
|
58
|
+
if (!field) return;
|
|
59
|
+
ensureIds(field, input);
|
|
60
|
+
field.classList.remove('pp-field--error', 'pp-field--warning', 'pp-field--validating');
|
|
61
|
+
field.classList.add('pp-field--success');
|
|
62
|
+
input.setAttribute('aria-invalid', 'false');
|
|
63
|
+
let msg = getMessageEl(field);
|
|
64
|
+
if (message) {
|
|
65
|
+
if (!msg) {
|
|
66
|
+
msg = document.createElement('span');
|
|
67
|
+
msg.className = 'pp-field__message';
|
|
68
|
+
msg.id = `${input.id || 'field'}-msg`;
|
|
69
|
+
field.appendChild(msg);
|
|
70
|
+
}
|
|
71
|
+
msg.textContent = message;
|
|
72
|
+
}
|
|
73
|
+
input.setAttribute('aria-describedby', buildDescribedBy(field));
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
function setValidating(input) {
|
|
77
|
+
const field = getField(input);
|
|
78
|
+
if (!field) return;
|
|
79
|
+
field.classList.remove('pp-field--error', 'pp-field--success', 'pp-field--warning');
|
|
80
|
+
field.classList.add('pp-field--validating');
|
|
81
|
+
input.removeAttribute('aria-invalid');
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
function setSummary(errors, summaryEl) {
|
|
85
|
+
if (!summaryEl) return;
|
|
86
|
+
const list = summaryEl.querySelector('.pp-validation-summary__list');
|
|
87
|
+
if (!list) return;
|
|
88
|
+
list.innerHTML = '';
|
|
89
|
+
if (!errors || errors.length === 0) {
|
|
90
|
+
summaryEl.classList.remove('is-visible');
|
|
91
|
+
summaryEl.setAttribute('aria-hidden', 'true');
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
errors.forEach(({ input, message }) => {
|
|
95
|
+
const inputEl = typeof input === 'string' ? document.getElementById(input) : input;
|
|
96
|
+
const li = document.createElement('li');
|
|
97
|
+
li.className = 'pp-validation-summary__item';
|
|
98
|
+
if (inputEl && inputEl.id) {
|
|
99
|
+
const a = document.createElement('a');
|
|
100
|
+
a.href = `#${inputEl.id}`;
|
|
101
|
+
a.textContent = message;
|
|
102
|
+
a.addEventListener('click', (e) => {
|
|
103
|
+
e.preventDefault();
|
|
104
|
+
inputEl.focus();
|
|
105
|
+
inputEl.scrollIntoView({ behavior: 'smooth', block: 'center' });
|
|
106
|
+
});
|
|
107
|
+
li.appendChild(a);
|
|
108
|
+
} else {
|
|
109
|
+
li.textContent = message;
|
|
110
|
+
}
|
|
111
|
+
list.appendChild(li);
|
|
112
|
+
});
|
|
113
|
+
summaryEl.classList.add('is-visible');
|
|
114
|
+
summaryEl.setAttribute('aria-hidden', 'false');
|
|
115
|
+
summaryEl.setAttribute('tabindex', '-1');
|
|
116
|
+
summaryEl.focus();
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
document.querySelectorAll('.pp-field').forEach((field) => {
|
|
120
|
+
const input = field.querySelector('.pp-field__input, .pp-field__textarea');
|
|
121
|
+
if (!input) return;
|
|
122
|
+
ensureIds(field, input);
|
|
123
|
+
const refs = buildDescribedBy(field);
|
|
124
|
+
if (refs) {
|
|
125
|
+
const existing = input.getAttribute('aria-describedby') || '';
|
|
126
|
+
const merged = [...new Set([...existing.split(' '), ...refs.split(' ')].filter(Boolean))].join(' ');
|
|
127
|
+
input.setAttribute('aria-describedby', merged);
|
|
128
|
+
}
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
window.ppValidation = { setError, clearError, setSuccess, setValidating, setSummary };
|
|
132
|
+
})();
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
// PeppertinoCSS — Accordion
|
|
2
|
+
|
|
3
|
+
@use 'sass:map';
|
|
4
|
+
@use 'base' as *;
|
|
5
|
+
|
|
6
|
+
// ─── Container ────────────────────────────────────────────────────────────────
|
|
7
|
+
.pp-accordion {
|
|
8
|
+
display: flex;
|
|
9
|
+
flex-direction: column;
|
|
10
|
+
width: 100%;
|
|
11
|
+
border-radius: 16px;
|
|
12
|
+
overflow: hidden;
|
|
13
|
+
border: 1px solid $color-border;
|
|
14
|
+
background: var(--pp-bg-card);
|
|
15
|
+
box-shadow: $shadow-sm;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
// ─── Item ─────────────────────────────────────────────────────────────────────
|
|
19
|
+
.pp-accordion__item {
|
|
20
|
+
border-bottom: 1px solid $color-border;
|
|
21
|
+
|
|
22
|
+
&:last-child {
|
|
23
|
+
border-bottom: none;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
// ─── Trigger ──────────────────────────────────────────────────────────────────
|
|
28
|
+
.pp-accordion__trigger {
|
|
29
|
+
display: flex;
|
|
30
|
+
align-items: center;
|
|
31
|
+
justify-content: space-between;
|
|
32
|
+
width: 100%;
|
|
33
|
+
padding: spacing(4) spacing(5);
|
|
34
|
+
background: transparent;
|
|
35
|
+
border: none;
|
|
36
|
+
cursor: pointer;
|
|
37
|
+
font-family: $font-sans;
|
|
38
|
+
font-size: font-size('base');
|
|
39
|
+
font-weight: map.get($font-weights, 'medium');
|
|
40
|
+
color: $color-on-surface;
|
|
41
|
+
text-align: left;
|
|
42
|
+
transition: background $transition-fast, color $transition-fast;
|
|
43
|
+
gap: spacing(3);
|
|
44
|
+
|
|
45
|
+
&:hover {
|
|
46
|
+
background: $color-neutral-50;
|
|
47
|
+
color: $color-primary;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
&[aria-expanded='true'] {
|
|
51
|
+
color: $color-primary;
|
|
52
|
+
background: $color-neutral-50;
|
|
53
|
+
|
|
54
|
+
.pp-accordion__icon {
|
|
55
|
+
transform: rotate(180deg);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
// ─── Icon (chevron) ───────────────────────────────────────────────────────────
|
|
61
|
+
.pp-accordion__icon {
|
|
62
|
+
flex-shrink: 0;
|
|
63
|
+
width: 18px;
|
|
64
|
+
height: 18px;
|
|
65
|
+
stroke: currentColor;
|
|
66
|
+
stroke-width: 2;
|
|
67
|
+
fill: none;
|
|
68
|
+
transition: transform $transition-base;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
// ─── Panel ────────────────────────────────────────────────────────────────────
|
|
72
|
+
.pp-accordion__panel {
|
|
73
|
+
overflow: hidden;
|
|
74
|
+
max-height: 0;
|
|
75
|
+
transition: max-height $transition-slow, padding $transition-base;
|
|
76
|
+
padding: 0 spacing(5);
|
|
77
|
+
|
|
78
|
+
&[aria-hidden='false'],
|
|
79
|
+
&.is-open {
|
|
80
|
+
max-height: 1000px;
|
|
81
|
+
padding: 0 spacing(5) spacing(4);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
// ─── Content ──────────────────────────────────────────────────────────────────
|
|
86
|
+
.pp-accordion__content {
|
|
87
|
+
font-family: $font-sans;
|
|
88
|
+
font-size: font-size('sm');
|
|
89
|
+
font-weight: map.get($font-weights, 'regular');
|
|
90
|
+
color: $color-neutral-500;
|
|
91
|
+
line-height: $line-height-base;
|
|
92
|
+
padding-top: spacing(1);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
// ─── Variant: flush (no outer border/radius) ─────────────────────────────────
|
|
96
|
+
.pp-accordion--flush {
|
|
97
|
+
border: none;
|
|
98
|
+
border-radius: 0;
|
|
99
|
+
box-shadow: none;
|
|
100
|
+
background: transparent;
|
|
101
|
+
|
|
102
|
+
.pp-accordion__item {
|
|
103
|
+
border-bottom: 1px solid $color-border;
|
|
104
|
+
|
|
105
|
+
&:first-child {
|
|
106
|
+
border-top: 1px solid $color-border;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
.pp-accordion__trigger:hover,
|
|
111
|
+
.pp-accordion__trigger[aria-expanded='true'] {
|
|
112
|
+
background: transparent;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
// ─── Variant: dark ────────────────────────────────────────────────────────────
|
|
117
|
+
.pp-accordion--dark {
|
|
118
|
+
background: $color-neutral-900;
|
|
119
|
+
border-color: $color-neutral-700;
|
|
120
|
+
|
|
121
|
+
.pp-accordion__item {
|
|
122
|
+
border-color: $color-neutral-700;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
.pp-accordion__trigger {
|
|
126
|
+
color: rgba(#fff, 0.85);
|
|
127
|
+
|
|
128
|
+
&:hover {
|
|
129
|
+
background: $color-neutral-800;
|
|
130
|
+
color: #fff;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
&[aria-expanded='true'] {
|
|
134
|
+
color: $color-primary-light;
|
|
135
|
+
background: $color-neutral-800;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
.pp-accordion__content {
|
|
140
|
+
color: rgba(#fff, 0.55);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
// ─── Variant: primary accent trigger ─────────────────────────────────────────
|
|
145
|
+
.pp-accordion--primary {
|
|
146
|
+
.pp-accordion__trigger[aria-expanded='true'] {
|
|
147
|
+
background: $color-primary;
|
|
148
|
+
color: #fff;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
.pp-accordion__item:has(.pp-accordion__trigger[aria-expanded='true']) {
|
|
152
|
+
.pp-accordion__panel {
|
|
153
|
+
background: rgba($color-primary, 0.04);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
}
|