lanre-ds 0.2.1 → 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,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.1",
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": [
@@ -35,6 +35,10 @@
35
35
  @media (prefers-reduced-motion: reduce) { .mp-trail-fill-grow, .mp-step-pop { animation: none; } }
36
36
  /* RadioCard presses down like a bevelled button (CSS, so a key press does it too). */
37
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); }
38
42
  @media (prefers-reduced-motion: reduce) {
39
43
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; scroll-behavior: auto !important; }
40
44
  }