@auriel/peppertino 0.1.1 → 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.
Files changed (45) hide show
  1. package/CHANGELOG.txt +136 -0
  2. package/README.md +343 -30
  3. package/build.js +27 -12
  4. package/dist/carousel.js +152 -0
  5. package/dist/carousel.js.map +7 -0
  6. package/dist/header.js +69 -0
  7. package/dist/header.js.map +7 -0
  8. package/dist/main.css +2780 -0
  9. package/dist/main.css.map +1 -0
  10. package/dist/modal.js +112 -0
  11. package/dist/modal.js.map +7 -0
  12. package/dist/peppertino.js +637 -0
  13. package/dist/peppertino.js.map +7 -0
  14. package/dist/select.js +99 -0
  15. package/dist/select.js.map +7 -0
  16. package/dist/tabs.js +79 -0
  17. package/dist/tabs.js.map +7 -0
  18. package/dist/validation.js +130 -0
  19. package/dist/validation.js.map +7 -0
  20. package/index.html +1137 -22
  21. package/package.json +1 -1
  22. package/src/js/carousel.js +148 -0
  23. package/src/js/header.js +43 -4
  24. package/src/js/modal.js +134 -0
  25. package/src/js/peppertino.js +9 -0
  26. package/src/js/select.js +103 -0
  27. package/src/js/tabs.js +94 -0
  28. package/src/js/validation.js +132 -0
  29. package/src/scss/base.scss +26 -6
  30. package/src/scss/button.scss +87 -20
  31. package/src/scss/card.scss +121 -0
  32. package/src/scss/carousel.scss +313 -0
  33. package/src/scss/footer.scss +224 -0
  34. package/src/scss/forms/fieldset.scss +127 -0
  35. package/src/scss/forms/form-instructions.scss +133 -0
  36. package/src/scss/forms/label.scss +115 -0
  37. package/src/scss/forms/text-field.scss +240 -0
  38. package/src/scss/forms/validation.scss +215 -0
  39. package/src/scss/forms.scss +8 -0
  40. package/src/scss/header.scss +27 -6
  41. package/src/scss/main.scss +7 -0
  42. package/src/scss/modal.scss +188 -0
  43. package/src/scss/section.scss +1 -1
  44. package/src/scss/select.scss +210 -0
  45. package/src/scss/tabs.scss +156 -0
@@ -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
+ })();
@@ -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 ────────────────────────────────────────────────────────────
@@ -1,7 +1,9 @@
1
1
  // PeppertinoCSS — Button
2
2
 
3
+ @use 'sass:map';
3
4
  @use 'base' as *;
4
5
 
6
+ // ─── Base ─────────────────────────────────────────────────────────────────────
5
7
  .button {
6
8
  cursor: pointer;
7
9
  display: inline-block;
@@ -20,35 +22,100 @@
20
22
  background: $color-primary;
21
23
  color: #fff;
22
24
  border-color: transparent;
25
+ transition: background $transition-fast, border-color $transition-fast, opacity $transition-fast;
23
26
  --sk-button-margin-horizontal: 14px;
24
27
  --sk-button-margin-vertical: 14px;
25
28
 
26
- &:hover {
27
- background: $color-primary-light;
28
- }
29
-
30
- &:active {
31
- background: $color-primary-dark;
32
- opacity: 0.85;
33
- }
29
+ &:hover { background: $color-primary-light; }
30
+ &:active { background: $color-primary-dark; opacity: 0.85; }
34
31
  }
35
32
 
33
+ // ─── Outline base ────────────────────────────────────────────────────────────
36
34
  .button-outline {
37
35
  @extend .button;
38
-
39
36
  background: transparent;
40
37
  color: $color-primary;
41
38
  border-color: $color-primary;
42
39
 
43
- &:hover {
44
- background: $color-primary;
45
- color: #fff;
46
- }
47
-
48
- &:active {
49
- background: $color-primary-dark;
50
- border-color: $color-primary-dark;
51
- color: #fff;
52
- opacity: 0.85;
53
- }
40
+ &:hover { background: $color-primary; color: #fff; }
41
+ &:active { background: $color-primary-dark; border-color: $color-primary-dark; color: #fff; opacity: 0.85; }
42
+ }
43
+
44
+ // ─── Variant mixin ───────────────────────────────────────────────────────────
45
+ @mixin button-variant($bg, $bg-hover, $bg-active) {
46
+ background: $bg;
47
+ border-color: transparent;
48
+ color: #fff;
49
+ &:hover { background: $bg-hover; }
50
+ &:active { background: $bg-active; opacity: 0.85; }
51
+ }
52
+
53
+ @mixin button-outline-variant($color, $color-hover) {
54
+ background: transparent;
55
+ border-color: $color;
56
+ color: $color;
57
+ &:hover { background: $color; color: #fff; }
58
+ &:active { background: $color-hover; border-color: $color-hover; color: #fff; opacity: 0.85; }
59
+ }
60
+
61
+ // ─── Filled variants ─────────────────────────────────────────────────────────
62
+ .button-success {
63
+ @extend .button;
64
+ @include button-variant(#16a34a, #15803d, #166534);
65
+ }
66
+
67
+ .button-warning {
68
+ @extend .button;
69
+ @include button-variant(#d97706, #b45309, #92400e);
70
+ color: #fff;
71
+ }
72
+
73
+ .button-error {
74
+ @extend .button;
75
+ @include button-variant($color-error, #dc2626, #b91c1c);
76
+ }
77
+
78
+ .button-dark {
79
+ @extend .button;
80
+ @include button-variant($color-neutral-900, $color-neutral-700, $color-neutral-800);
81
+ }
82
+
83
+ .button-ghost {
84
+ @extend .button;
85
+ background: transparent;
86
+ color: $color-on-surface;
87
+ border-color: $color-border;
88
+
89
+ &:hover { background: $color-neutral-100; border-color: $color-neutral-300; }
90
+ &:active { background: $color-neutral-200; opacity: 0.85; }
91
+ }
92
+
93
+ .button-gradient {
94
+ @extend .button;
95
+ background: linear-gradient(135deg, $gradient-start, $gradient-end);
96
+ border-color: transparent;
97
+
98
+ &:hover { background: linear-gradient(135deg, $gradient-end, $gradient-start); }
99
+ &:active { opacity: 0.85; }
100
+ }
101
+
102
+ // ─── Outline variants ────────────────────────────────────────────────────────
103
+ .button-outline-success {
104
+ @extend .button;
105
+ @include button-outline-variant(#16a34a, #15803d);
106
+ }
107
+
108
+ .button-outline-warning {
109
+ @extend .button;
110
+ @include button-outline-variant(#d97706, #b45309);
111
+ }
112
+
113
+ .button-outline-error {
114
+ @extend .button;
115
+ @include button-outline-variant($color-error, #dc2626);
116
+ }
117
+
118
+ .button-outline-dark {
119
+ @extend .button;
120
+ @include button-outline-variant($color-neutral-900, $color-neutral-700);
54
121
  }
@@ -0,0 +1,121 @@
1
+ // PeppertinoCSS — Card
2
+
3
+ @use 'sass:map';
4
+ @use 'base' as *;
5
+
6
+ .pp-card {
7
+ background: #fff;
8
+ border-radius: 16px;
9
+ padding: spacing(6);
10
+ box-shadow: $shadow-md;
11
+ display: flex;
12
+ flex-direction: column;
13
+ gap: spacing(3);
14
+ transition: box-shadow $transition-base, transform $transition-base;
15
+
16
+ &:hover {
17
+ box-shadow: $shadow-xl;
18
+ transform: translateY(-2px);
19
+ }
20
+ }
21
+
22
+ // ─── Parts ───────────────────────────────────────────────────────────────────
23
+ .pp-card__eyebrow {
24
+ font-family: $font-sans;
25
+ font-size: font-size('xs');
26
+ font-weight: map.get($font-weights, 'semibold');
27
+ letter-spacing: 0.08em;
28
+ text-transform: uppercase;
29
+ color: $color-primary;
30
+ }
31
+
32
+ .pp-card__title {
33
+ font-family: $font-sans;
34
+ font-size: font-size('xl');
35
+ font-weight: map.get($font-weights, 'bold');
36
+ color: $color-neutral-900;
37
+ line-height: 1.25;
38
+ }
39
+
40
+ .pp-card__body {
41
+ font-family: $font-sans;
42
+ font-size: font-size('sm');
43
+ font-weight: map.get($font-weights, 'regular');
44
+ color: $color-neutral-500;
45
+ line-height: 1.6;
46
+ }
47
+
48
+ .pp-card__footer {
49
+ display: flex;
50
+ align-items: center;
51
+ gap: spacing(3);
52
+ padding-top: spacing(2);
53
+ border-top: 1px solid $color-border;
54
+ margin-top: auto;
55
+ }
56
+
57
+ .pp-card__media {
58
+ width: 100%;
59
+ aspect-ratio: 16 / 9;
60
+ object-fit: cover;
61
+ border-radius: 10px;
62
+ background: $color-neutral-100;
63
+ margin: 0 calc(-1 * spacing(6));
64
+ width: calc(100% + spacing(12));
65
+ }
66
+
67
+ // ─── Variants ────────────────────────────────────────────────────────────────
68
+ .pp-card--primary {
69
+ background: $color-primary;
70
+
71
+ .pp-card__eyebrow { color: rgba(#fff, 0.6); }
72
+ .pp-card__title { color: #fff; }
73
+ .pp-card__body { color: rgba(#fff, 0.75); }
74
+ .pp-card__footer { border-color: rgba(#fff, 0.2); }
75
+ }
76
+
77
+ .pp-card--dark {
78
+ background: $color-neutral-900;
79
+
80
+ .pp-card__eyebrow { color: $color-primary-light; }
81
+ .pp-card__title { color: #fff; }
82
+ .pp-card__body { color: $color-neutral-400; }
83
+ .pp-card__footer { border-color: $color-neutral-700; }
84
+ }
85
+
86
+ .pp-card--gradient {
87
+ background: linear-gradient(135deg, $gradient-start, $gradient-end);
88
+
89
+ .pp-card__eyebrow { color: rgba(#fff, 0.7); }
90
+ .pp-card__title { color: #fff; }
91
+ .pp-card__body { color: rgba(#fff, 0.8); }
92
+ .pp-card__footer { border-color: rgba(#fff, 0.25); }
93
+ }
94
+
95
+ .pp-card--ghost {
96
+ background: transparent;
97
+ box-shadow: none;
98
+ border: 1px solid $color-border;
99
+
100
+ &:hover {
101
+ box-shadow: $shadow-md;
102
+ background: #fff;
103
+ }
104
+ }
105
+
106
+ // ─── Grid helper ─────────────────────────────────────────────────────────────
107
+ .pp-card-grid {
108
+ display: grid;
109
+ gap: spacing(6);
110
+ width: 100%;
111
+
112
+ &--2 { grid-template-columns: repeat(2, 1fr); }
113
+ &--3 { grid-template-columns: repeat(3, 1fr); }
114
+ &--4 { grid-template-columns: repeat(4, 1fr); }
115
+
116
+ @media (max-width: 767px) {
117
+ &--2,
118
+ &--3,
119
+ &--4 { grid-template-columns: 1fr; }
120
+ }
121
+ }