@auriel/peppertino 0.2.0 → 0.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/CHANGELOG.txt +76 -10
- package/README.md +236 -43
- 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 +1359 -8
- package/dist/main.css.map +1 -1
- package/dist/modal.js +61 -2
- package/dist/modal.js.map +2 -2
- package/dist/peppertino.js +427 -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 +921 -39
- package/package.json +1 -1
- package/src/js/carousel.js +148 -0
- package/src/js/peppertino.js +2 -0
- package/src/js/validation.js +132 -0
- package/src/scss/base.scss +26 -6
- package/src/scss/carousel.scss +313 -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/main.scss +3 -0
- package/.claude/settings.local.json +0 -8
package/package.json
CHANGED
|
@@ -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
|
@@ -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
|
+
})();
|
package/src/scss/base.scss
CHANGED
|
@@ -102,13 +102,33 @@ $shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1) !d
|
|
|
102
102
|
$shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1) !default;
|
|
103
103
|
$shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1) !default;
|
|
104
104
|
|
|
105
|
-
// ─── Breakpoints
|
|
105
|
+
// ─── Breakpoints (Tailwind-compatible) ───────────────────────────────────────
|
|
106
106
|
$breakpoints: (
|
|
107
|
-
'sm': 640px,
|
|
108
|
-
'md': 768px,
|
|
109
|
-
'lg': 1024px,
|
|
110
|
-
'xl': 1280px,
|
|
111
|
-
'2xl': 1536px,
|
|
107
|
+
'sm': 640px, // small devices (landscape phones)
|
|
108
|
+
'md': 768px, // medium devices (tablets)
|
|
109
|
+
'lg': 1024px, // large devices (small laptops / iPad Pro)
|
|
110
|
+
'xl': 1280px, // extra large (desktops / MacBook Air)
|
|
111
|
+
'2xl': 1536px, // 2x extra large (wide desktops)
|
|
112
|
+
) !default;
|
|
113
|
+
|
|
114
|
+
// ─── Apple / Mac device breakpoints ──────────────────────────────────────────
|
|
115
|
+
// Viewport widths matched to real Apple hardware at default scale
|
|
116
|
+
$mac-breakpoints: (
|
|
117
|
+
// — iPhone —
|
|
118
|
+
'iphone-se': 375px, // iPhone SE (2nd/3rd gen), iPhone 13 mini
|
|
119
|
+
'iphone': 390px, // iPhone 14 / 15 / 16
|
|
120
|
+
'iphone-plus': 430px, // iPhone 14 Plus / 15 Plus / 16 Plus
|
|
121
|
+
'iphone-pro-max': 440px, // iPhone 15 Pro Max / 16 Pro Max
|
|
122
|
+
// — iPad —
|
|
123
|
+
'ipad-mini': 768px, // iPad mini (6th gen)
|
|
124
|
+
'ipad-air': 820px, // iPad Air (4th/5th gen) portrait
|
|
125
|
+
'ipad-pro-11': 834px, // iPad Pro 11" portrait
|
|
126
|
+
'ipad-pro-13': 1024px, // iPad Pro 13" portrait
|
|
127
|
+
// — Mac —
|
|
128
|
+
'macbook-air-13': 1280px, // MacBook Air 13" (M1/M2/M3)
|
|
129
|
+
'macbook-pro-14': 1512px, // MacBook Pro 14" (M1 Pro / M3 Pro)
|
|
130
|
+
'macbook-pro-16': 1728px, // MacBook Pro 16" (M1 Max / M3 Max)
|
|
131
|
+
'imac': 2560px, // iMac 24"
|
|
112
132
|
) !default;
|
|
113
133
|
|
|
114
134
|
// ─── Z-index scale ────────────────────────────────────────────────────────────
|
|
@@ -0,0 +1,313 @@
|
|
|
1
|
+
// PeppertinoCSS — Carousel
|
|
2
|
+
//
|
|
3
|
+
// CSS-driven by default: scroll-snap + overflow-x handles all motion.
|
|
4
|
+
// JS shim (carousel.js) wires ARIA roles, live region, and exposes a small
|
|
5
|
+
// ppCarousel API — but it is strictly optional. Users can replace it entirely.
|
|
6
|
+
|
|
7
|
+
@use 'sass:map';
|
|
8
|
+
@use 'base' as *;
|
|
9
|
+
|
|
10
|
+
// ─── Root ─────────────────────────────────────────────────────────────────────
|
|
11
|
+
.pp-carousel {
|
|
12
|
+
position: relative;
|
|
13
|
+
width: 100%;
|
|
14
|
+
// Contain the overflow so prev/next controls sit outside the scroll track
|
|
15
|
+
overflow: hidden;
|
|
16
|
+
border-radius: 16px;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
// ─── Track ────────────────────────────────────────────────────────────────────
|
|
20
|
+
// The scrollable strip. Pure CSS scroll-snap — no JS scroll needed.
|
|
21
|
+
.pp-carousel__track {
|
|
22
|
+
display: flex;
|
|
23
|
+
overflow-x: auto;
|
|
24
|
+
scroll-snap-type: x mandatory;
|
|
25
|
+
scroll-behavior: smooth;
|
|
26
|
+
-webkit-overflow-scrolling: touch;
|
|
27
|
+
|
|
28
|
+
// Hide scrollbar visually; keep it functional for assistive pointer users
|
|
29
|
+
scrollbar-width: none;
|
|
30
|
+
&::-webkit-scrollbar { display: none; }
|
|
31
|
+
|
|
32
|
+
// Prevent layout thrash during scroll
|
|
33
|
+
will-change: scroll-position;
|
|
34
|
+
|
|
35
|
+
// pause CSS autoplay on hover / keyboard focus-within
|
|
36
|
+
&:hover,
|
|
37
|
+
&:focus-within {
|
|
38
|
+
animation-play-state: paused;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// ─── Slide ────────────────────────────────────────────────────────────────────
|
|
43
|
+
.pp-carousel__slide {
|
|
44
|
+
flex: 0 0 100%; // full-width by default
|
|
45
|
+
scroll-snap-align: start;
|
|
46
|
+
scroll-snap-stop: always; // prevent momentum skipping on iOS
|
|
47
|
+
position: relative;
|
|
48
|
+
min-height: 280px;
|
|
49
|
+
user-select: none;
|
|
50
|
+
|
|
51
|
+
// Content inside slides shouldn't be focusable while hidden
|
|
52
|
+
&[aria-hidden='true'] * { visibility: hidden; }
|
|
53
|
+
&[aria-hidden='false'] * { visibility: visible; }
|
|
54
|
+
&:not([aria-hidden]) * { visibility: visible; }
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// ─── Slide variants — percentage widths ──────────────────────────────────────
|
|
58
|
+
// Use .pp-carousel--peek-2, --peek-3 on the root to show partial next slides
|
|
59
|
+
.pp-carousel--peek-2 .pp-carousel__slide { flex: 0 0 85%; }
|
|
60
|
+
.pp-carousel--peek-3 .pp-carousel__slide { flex: 0 0 72%; }
|
|
61
|
+
|
|
62
|
+
// ─── Slide media (image / video) ─────────────────────────────────────────────
|
|
63
|
+
.pp-carousel__media {
|
|
64
|
+
display: block;
|
|
65
|
+
width: 100%;
|
|
66
|
+
height: 100%;
|
|
67
|
+
object-fit: cover;
|
|
68
|
+
border-radius: inherit;
|
|
69
|
+
pointer-events: none;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
// ─── Slide caption ────────────────────────────────────────────────────────────
|
|
73
|
+
.pp-carousel__caption {
|
|
74
|
+
position: absolute;
|
|
75
|
+
inset: auto 0 0;
|
|
76
|
+
padding: spacing(6) spacing(6) spacing(5);
|
|
77
|
+
|
|
78
|
+
background: linear-gradient(
|
|
79
|
+
to top,
|
|
80
|
+
rgba(0, 0, 0, 0.65) 0%,
|
|
81
|
+
rgba(0, 0, 0, 0.2) 60%,
|
|
82
|
+
transparent 100%
|
|
83
|
+
);
|
|
84
|
+
border-radius: 0 0 16px 16px;
|
|
85
|
+
color: #fff;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
.pp-carousel__caption-title {
|
|
89
|
+
font-size: font-size('xl');
|
|
90
|
+
font-weight: map.get($font-weights, 'semibold');
|
|
91
|
+
letter-spacing: -0.02em;
|
|
92
|
+
line-height: 1.25;
|
|
93
|
+
margin-bottom: spacing(1);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
.pp-carousel__caption-body {
|
|
97
|
+
font-size: font-size('sm');
|
|
98
|
+
color: rgba(#fff, 0.75);
|
|
99
|
+
line-height: 1.5;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
// ─── Prev / Next controls ────────────────────────────────────────────────────
|
|
103
|
+
.pp-carousel__prev,
|
|
104
|
+
.pp-carousel__next {
|
|
105
|
+
position: absolute;
|
|
106
|
+
top: 50%;
|
|
107
|
+
transform: translateY(-50%);
|
|
108
|
+
z-index: z('raised');
|
|
109
|
+
|
|
110
|
+
display: flex;
|
|
111
|
+
align-items: center;
|
|
112
|
+
justify-content: center;
|
|
113
|
+
width: 36px;
|
|
114
|
+
height: 36px;
|
|
115
|
+
border-radius: 50%;
|
|
116
|
+
border: none;
|
|
117
|
+
cursor: pointer;
|
|
118
|
+
|
|
119
|
+
background: rgba(255, 255, 255, 0.85);
|
|
120
|
+
backdrop-filter: blur(8px) saturate(160%);
|
|
121
|
+
-webkit-backdrop-filter: blur(8px) saturate(160%);
|
|
122
|
+
box-shadow: $shadow-md;
|
|
123
|
+
color: $color-neutral-800;
|
|
124
|
+
transition:
|
|
125
|
+
background $transition-fast,
|
|
126
|
+
box-shadow $transition-fast,
|
|
127
|
+
opacity $transition-fast,
|
|
128
|
+
transform $transition-fast;
|
|
129
|
+
|
|
130
|
+
svg {
|
|
131
|
+
width: 18px;
|
|
132
|
+
height: 18px;
|
|
133
|
+
flex-shrink: 0;
|
|
134
|
+
stroke: currentColor;
|
|
135
|
+
fill: none;
|
|
136
|
+
stroke-width: 2;
|
|
137
|
+
stroke-linecap: round;
|
|
138
|
+
stroke-linejoin: round;
|
|
139
|
+
pointer-events: none;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
&:hover {
|
|
143
|
+
background: #fff;
|
|
144
|
+
box-shadow: $shadow-lg;
|
|
145
|
+
transform: translateY(-50%) scale(1.08);
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
&:active {
|
|
149
|
+
transform: translateY(-50%) scale(0.96);
|
|
150
|
+
box-shadow: $shadow;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
&:focus-visible {
|
|
154
|
+
outline: 2px solid $color-primary;
|
|
155
|
+
outline-offset: 2px;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
&:disabled,
|
|
159
|
+
&[aria-disabled='true'] {
|
|
160
|
+
opacity: 0.3;
|
|
161
|
+
pointer-events: none;
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
.pp-carousel__prev { left: spacing(3); }
|
|
166
|
+
.pp-carousel__next { right: spacing(3); }
|
|
167
|
+
|
|
168
|
+
// ─── Dots (pagination indicators) ────────────────────────────────────────────
|
|
169
|
+
.pp-carousel__dots {
|
|
170
|
+
display: flex;
|
|
171
|
+
align-items: center;
|
|
172
|
+
justify-content: center;
|
|
173
|
+
gap: spacing(2);
|
|
174
|
+
padding: spacing(4) 0 spacing(2);
|
|
175
|
+
list-style: none;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
.pp-carousel__dot {
|
|
179
|
+
display: block;
|
|
180
|
+
width: 6px;
|
|
181
|
+
height: 6px;
|
|
182
|
+
border-radius: 50%;
|
|
183
|
+
background: $color-neutral-300;
|
|
184
|
+
border: none;
|
|
185
|
+
cursor: pointer;
|
|
186
|
+
padding: 0;
|
|
187
|
+
transition:
|
|
188
|
+
background $transition-base,
|
|
189
|
+
width $transition-base,
|
|
190
|
+
border-radius $transition-base;
|
|
191
|
+
|
|
192
|
+
&:focus-visible {
|
|
193
|
+
outline: 2px solid $color-primary;
|
|
194
|
+
outline-offset: 2px;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
&.is-active,
|
|
198
|
+
&[aria-current='true'] {
|
|
199
|
+
background: $color-primary;
|
|
200
|
+
width: 20px;
|
|
201
|
+
border-radius: 3px;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
&:hover:not(.is-active):not([aria-current='true']) {
|
|
205
|
+
background: $color-neutral-500;
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
// ─── Live region (screen-reader slide announcements) ─────────────────────────
|
|
210
|
+
.pp-carousel__announcer {
|
|
211
|
+
position: absolute;
|
|
212
|
+
width: 1px;
|
|
213
|
+
height: 1px;
|
|
214
|
+
padding: 0;
|
|
215
|
+
margin: -1px;
|
|
216
|
+
overflow: hidden;
|
|
217
|
+
clip: rect(0, 0, 0, 0);
|
|
218
|
+
white-space: nowrap;
|
|
219
|
+
border: 0;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
// ─── Autoplay toggle ─────────────────────────────────────────────────────────
|
|
223
|
+
.pp-carousel__autoplay {
|
|
224
|
+
position: absolute;
|
|
225
|
+
top: spacing(3);
|
|
226
|
+
right: spacing(3);
|
|
227
|
+
z-index: z('raised');
|
|
228
|
+
|
|
229
|
+
display: flex;
|
|
230
|
+
align-items: center;
|
|
231
|
+
justify-content: center;
|
|
232
|
+
width: 30px;
|
|
233
|
+
height: 30px;
|
|
234
|
+
border-radius: 50%;
|
|
235
|
+
border: none;
|
|
236
|
+
cursor: pointer;
|
|
237
|
+
|
|
238
|
+
background: rgba(255, 255, 255, 0.75);
|
|
239
|
+
backdrop-filter: blur(8px);
|
|
240
|
+
-webkit-backdrop-filter: blur(8px);
|
|
241
|
+
color: $color-neutral-700;
|
|
242
|
+
transition: background $transition-fast, color $transition-fast;
|
|
243
|
+
|
|
244
|
+
svg {
|
|
245
|
+
width: 14px;
|
|
246
|
+
height: 14px;
|
|
247
|
+
fill: currentColor;
|
|
248
|
+
pointer-events: none;
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
&:hover { background: rgba(255, 255, 255, 0.95); color: $color-on-surface; }
|
|
252
|
+
|
|
253
|
+
&:focus-visible {
|
|
254
|
+
outline: 2px solid $color-primary;
|
|
255
|
+
outline-offset: 2px;
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
// Icon swap: show pause icon when playing, play icon when paused
|
|
259
|
+
.pp-carousel--playing & .pp-carousel__autoplay-icon--play { display: none; }
|
|
260
|
+
.pp-carousel--playing & .pp-carousel__autoplay-icon--pause { display: block; }
|
|
261
|
+
.pp-carousel--paused & .pp-carousel__autoplay-icon--play { display: block; }
|
|
262
|
+
.pp-carousel--paused & .pp-carousel__autoplay-icon--pause { display: none; }
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
// ─── Dark variant ────────────────────────────────────────────────────────────
|
|
266
|
+
.pp-carousel--dark {
|
|
267
|
+
background: $color-neutral-900;
|
|
268
|
+
|
|
269
|
+
.pp-carousel__prev,
|
|
270
|
+
.pp-carousel__next {
|
|
271
|
+
background: rgba(0, 0, 0, 0.6);
|
|
272
|
+
color: #fff;
|
|
273
|
+
&:hover { background: rgba(0, 0, 0, 0.85); }
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
.pp-carousel__dot {
|
|
277
|
+
background: $color-neutral-600;
|
|
278
|
+
&.is-active, &[aria-current='true'] { background: $color-primary-light; }
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
.pp-carousel__autoplay {
|
|
282
|
+
background: rgba(0, 0, 0, 0.5);
|
|
283
|
+
color: rgba(#fff, 0.8);
|
|
284
|
+
&:hover { background: rgba(0, 0, 0, 0.8); color: #fff; }
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
// ─── Flush variant (no border-radius) ────────────────────────────────────────
|
|
289
|
+
.pp-carousel--flush {
|
|
290
|
+
border-radius: 0;
|
|
291
|
+
.pp-carousel__slide { border-radius: 0; }
|
|
292
|
+
.pp-carousel__caption { border-radius: 0; }
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
// ─── Responsive ───────────────────────────────────────────────────────────────
|
|
296
|
+
@media (max-width: 767px) {
|
|
297
|
+
// Controls move closer to edges on small screens
|
|
298
|
+
.pp-carousel__prev { left: spacing(2); }
|
|
299
|
+
.pp-carousel__next { right: spacing(2); }
|
|
300
|
+
|
|
301
|
+
.pp-carousel__prev,
|
|
302
|
+
.pp-carousel__next {
|
|
303
|
+
width: 32px;
|
|
304
|
+
height: 32px;
|
|
305
|
+
svg { width: 16px; height: 16px; }
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
// Peek variants collapse to near-full width on mobile
|
|
309
|
+
.pp-carousel--peek-2 .pp-carousel__slide,
|
|
310
|
+
.pp-carousel--peek-3 .pp-carousel__slide {
|
|
311
|
+
flex: 0 0 92%;
|
|
312
|
+
}
|
|
313
|
+
}
|