lanre-ds 0.2.0 → 0.2.2

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, { useState } from '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, onPointerDown, onPointerUp, onPointerCancel, onPointerLeave, title, description, media, style, ...rest }) {
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)', transform: down ? 'translateY(3px)' : undefined, ...style }} {...rest}>
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', animation: 'mp-trail-grow var(--dur-slow) var(--ease-out) 260ms both' } : null) }} />
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>
@@ -1,5 +1,5 @@
1
1
  'use client';
2
- import React, { useEffect, useLayoutEffect, useRef, useState } from 'react';
2
+ import React, { useEffect, useLayoutEffect, useRef } from 'react';
3
3
  import { Button } from '../buttons/Button';
4
4
 
5
5
  const useBrowserEffect = typeof window === 'undefined' ? useEffect : useLayoutEffect;
@@ -11,18 +11,10 @@ const LINE = { display: 'inline-flex', alignItems: 'center', gap: 4 };
11
11
  const FONT = { fontFamily: 'inherit', fontStyle: 'inherit', lineHeight: 'inherit' };
12
12
 
13
13
  // Square cream key for moving and removing a block. One that can't act is aria-disabled rather than disabled,
14
- // so it keeps focus when its block reaches the top or the bottom.
14
+ // so it keeps focus when its block reaches the top or the bottom. Its press is CSS (.mp-block-key:active), so a key press does it too.
15
15
  function Key({ label, disabled, onClick, buttonRef, children }) {
16
- const [down, setDown] = useState(false);
17
- const pressed = down && !disabled;
18
16
  return (
19
- <button type="button" ref={buttonRef} aria-label={label} aria-disabled={disabled || undefined} onClick={disabled ? undefined : onClick}
20
- onPointerDown={() => setDown(true)} onPointerUp={() => setDown(false)} onPointerCancel={() => setDown(false)} onPointerLeave={() => setDown(false)}
21
- style={{ appearance: 'none', boxSizing: 'border-box', border: '2px solid var(--cream-300)', background: 'linear-gradient(180deg, #fff, var(--cream-100))',
22
- boxShadow: pressed ? '0 1px 0 var(--cream-300)' : '0 3px 0 var(--cream-300), inset 0 2px 0 oklch(1 0 0 / 0.45)', width: 44, height: 44, borderRadius: 12,
23
- display: 'grid', placeItems: 'center', ...FONT, fontWeight: 'inherit', fontSize: 18, color: 'var(--ink-700)', cursor: disabled ? 'default' : 'pointer', flex: 'none',
24
- opacity: disabled ? 0.4 : undefined, transform: pressed ? 'translateY(2px)' : undefined,
25
- transition: 'transform var(--dur-fast) var(--ease-out), box-shadow var(--dur-fast) var(--ease-out)' }}>
17
+ <button type="button" ref={buttonRef} className="mp-block-key" aria-label={label} aria-disabled={disabled || undefined} onClick={disabled ? undefined : onClick}>
26
18
  {children}
27
19
  </button>
28
20
  );
@@ -16,6 +16,8 @@ export interface WhoButtonProps extends Omit<React.ButtonHTMLAttributes<HTMLButt
16
16
  /** What it says before the reveal. Default "Ready to guess". */
17
17
  text?: string;
18
18
  onClick?: () => void;
19
+ /** The button itself, for putting focus back on it when the tray closes. */
20
+ ref?: React.Ref<HTMLButtonElement>;
19
21
  }
20
22
 
21
23
  export function WhoButton(props: WhoButtonProps): React.JSX.Element;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lanre-ds",
3
- "version": "0.2.0",
3
+ "version": "0.2.2",
4
4
  "description": "Lanre: a design system for a casual exploration game. React components and CSS tokens.",
5
5
  "license": "MIT",
6
6
  "keywords": [
@@ -29,6 +29,16 @@
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); }
38
+ /* UploadTile's move and remove keys press down like a bevelled button. One that can't act (aria-disabled) stays still. */
39
+ .mp-block-key { appearance: none; box-sizing: border-box; flex: none; width: 44px; height: 44px; border: 2px solid var(--cream-300); border-radius: 12px; background: linear-gradient(180deg, #fff, var(--cream-100)); box-shadow: 0 3px 0 var(--cream-300), inset 0 2px 0 oklch(1 0 0 / 0.45); display: grid; place-items: center; font-family: inherit; font-style: inherit; font-weight: inherit; line-height: inherit; font-size: 18px; color: var(--ink-700); cursor: pointer; transition: transform var(--dur-fast) var(--ease-out), box-shadow var(--dur-fast) var(--ease-out); }
40
+ .mp-block-key[aria-disabled='true'] { opacity: 0.4; cursor: default; }
41
+ .mp-block-key:active:not([aria-disabled='true']) { transform: translateY(2px); box-shadow: 0 1px 0 var(--cream-300); }
32
42
  @media (prefers-reduced-motion: reduce) {
33
43
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; scroll-behavior: auto !important; }
34
44
  }