lanre-ds 0.2.0 → 0.2.1
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.
|
@@ -1,22 +1,18 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import React
|
|
2
|
+
import React from 'react';
|
|
3
3
|
|
|
4
4
|
const DROP = '0 14px 24px oklch(0.22 0.05 60 / 0.3)';
|
|
5
5
|
const GLOW = '0 0 0 4px oklch(0.76 0.13 180 / 0.5), 0 0 28px oklch(0.76 0.13 180 / 0.6)';
|
|
6
6
|
|
|
7
|
-
export function RadioCard({ checked = false, onChange, onClick,
|
|
8
|
-
const [down, setDown] = useState(false);
|
|
9
|
-
// Your own handlers run alongside the card's, so passing one never breaks choosing or the press.
|
|
10
|
-
const press = (on, yours) => e => { setDown(on); if (yours) yours(e); };
|
|
7
|
+
export function RadioCard({ checked = false, onChange, onClick, title, description, media, style, className, ...rest }) {
|
|
11
8
|
return (
|
|
12
|
-
<button type="button" role="radio" aria-checked={checked} onClick={e => { if (onClick) onClick(e); if (onChange) onChange(true); }}
|
|
13
|
-
onPointerDown={press(true, onPointerDown)} onPointerUp={press(false, onPointerUp)} onPointerCancel={press(false, onPointerCancel)} onPointerLeave={press(false, onPointerLeave)}
|
|
9
|
+
<button type="button" role="radio" aria-checked={checked} className={'mp-radio-card' + (className ? ' ' + className : '')} onClick={e => { if (onClick) onClick(e); if (onChange) onChange(true); }}
|
|
14
10
|
style={{ appearance: 'none', position: 'relative', display: 'flex', flexDirection: 'column', alignItems: 'center', gap: 10, padding: '22px 12px 16px', boxSizing: 'border-box',
|
|
15
11
|
borderRadius: 'var(--radius-lg)', border: '4px solid ' + (checked ? 'var(--teal-500)' : 'var(--cream-300)'),
|
|
16
12
|
background: checked ? 'linear-gradient(180deg, var(--teal-100), #fff)' : 'linear-gradient(180deg, #fff, var(--cream-100))',
|
|
17
13
|
boxShadow: checked ? '0 5px 0 var(--teal-700), ' + DROP + ', ' + GLOW : '0 5px 0 var(--cream-300), ' + DROP,
|
|
18
14
|
font: 'inherit', textAlign: 'center', cursor: 'pointer', WebkitTapHighlightColor: 'transparent',
|
|
19
|
-
transition: 'transform var(--dur-fast) var(--ease-out)',
|
|
15
|
+
transition: 'transform var(--dur-fast) var(--ease-out)', ...style }} {...rest}>
|
|
20
16
|
<span aria-hidden="true" style={{ position: 'absolute', right: 10, top: 10, width: 28, height: 28, boxSizing: 'border-box', borderRadius: '50%',
|
|
21
17
|
border: '3px solid ' + (checked ? 'var(--teal-500)' : 'var(--stone-500)'), background: checked ? 'var(--teal-500)' : '#fff', boxShadow: 'inset 0 2px 3px oklch(0 0 0 / 0.1)',
|
|
22
18
|
display: 'grid', placeItems: 'center', color: '#fff', fontSize: 14, animation: checked ? 'mp-radio-pop var(--dur-base) var(--ease-bounce) both' : undefined }}>
|
|
@@ -25,16 +25,15 @@ export function StepBar({ steps = [], current = 0, labels = false, style, ...res
|
|
|
25
25
|
<div style={{ position: 'relative' }}>
|
|
26
26
|
<span aria-hidden="true" style={{ position: 'absolute', top: 12, left: slot / 2, right: slot / 2, height: 12, borderRadius: 999,
|
|
27
27
|
background: 'var(--world-path)', boxShadow: '0 0 0 3px var(--world-path-edge), 0 4px 0 3px oklch(0.25 0.05 60 / 0.2)' }} />
|
|
28
|
-
<span aria-hidden="true" style={{ position: 'absolute', top: 16, left: slot / 2, width: slot * filled, height: 4, borderRadius: 999,
|
|
28
|
+
<span aria-hidden="true" className={advanced ? 'mp-trail-fill-grow' : undefined} style={{ position: 'absolute', top: 16, left: slot / 2, width: slot * filled, height: 4, borderRadius: 999,
|
|
29
29
|
background: 'var(--green-500)', transition: 'width var(--dur-slow) var(--ease-out)',
|
|
30
|
-
...(advanced ? { '--from': slot * Math.min(current - 1, filled) + 'px', '--to': slot * filled + 'px'
|
|
30
|
+
...(advanced ? { '--from': slot * Math.min(current - 1, filled) + 'px', '--to': slot * filled + 'px' } : null) }} />
|
|
31
31
|
<ol style={{ position: 'relative', listStyle: 'none', margin: 0, padding: 0, display: 'flex' }}>
|
|
32
32
|
{steps.map((label, i) => {
|
|
33
33
|
const done = i < current, cur = i === current, justDone = advanced && i === current - 1;
|
|
34
34
|
return (
|
|
35
35
|
<li key={i} aria-current={cur ? 'step' : undefined} style={{ width: slot, display: 'flex', flexDirection: 'column', alignItems: 'center', gap: 6 }}>
|
|
36
|
-
<span aria-hidden="true" className={'mp-step' + (done ? ' mp-step-done' : cur ? ' mp-step-current' : '')}
|
|
37
|
-
style={justDone ? { animation: 'mp-pop var(--dur-slow) var(--ease-bounce) 560ms both' } : undefined}>
|
|
36
|
+
<span aria-hidden="true" className={'mp-step' + (done ? ' mp-step-done' : cur ? ' mp-step-current' : '') + (justDone ? ' mp-step-pop' : '')}>
|
|
38
37
|
{done ? <i className="ph-bold ph-check" /> : i + 1}
|
|
39
38
|
{cur && <span style={{ position: 'absolute', inset: -4, borderRadius: '50%', animation: 'mp-pulse-ring 1.6s ease-out infinite' }} />}
|
|
40
39
|
</span>
|
package/package.json
CHANGED
package/tokens/utilities.css
CHANGED
|
@@ -29,6 +29,12 @@
|
|
|
29
29
|
.mp-step-done { --step-highlight: var(--step-done-highlight); --step-fill: var(--step-done-fill); --step-edge: var(--step-done-edge); --step-outline: var(--step-done-outline); }
|
|
30
30
|
.mp-step-current { --step-highlight: var(--step-current-highlight); --step-fill: var(--step-current-fill); --step-edge: var(--step-current-edge); --step-outline: var(--step-current-outline); transform: translateY(-3px); }
|
|
31
31
|
.mp-step-lg { width: 40px; height: 25px; font-size: 17px; transform: none; }
|
|
32
|
+
/* StepBar's celebration: the fill grows, then the new marker pops. Classes, so reduced motion can switch them off (the rule below only shortens animations, and these wait before they start). */
|
|
33
|
+
.mp-trail-fill-grow { animation: mp-trail-grow var(--dur-slow) var(--ease-out) 260ms both; }
|
|
34
|
+
.mp-step-pop { animation: mp-pop var(--dur-slow) var(--ease-bounce) 560ms both; }
|
|
35
|
+
@media (prefers-reduced-motion: reduce) { .mp-trail-fill-grow, .mp-step-pop { animation: none; } }
|
|
36
|
+
/* RadioCard presses down like a bevelled button (CSS, so a key press does it too). */
|
|
37
|
+
.mp-radio-card:active { transform: translateY(3px); }
|
|
32
38
|
@media (prefers-reduced-motion: reduce) {
|
|
33
39
|
*, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; scroll-behavior: auto !important; }
|
|
34
40
|
}
|