diff --git a/.storybook/preview.tsx b/.storybook/preview.tsx index b4234ec..f62fde1 100644 --- a/.storybook/preview.tsx +++ b/.storybook/preview.tsx @@ -50,6 +50,17 @@ const preview: Preview = { }, parameters: { backgrounds: { disable: true }, + a11y: { + // Page-level rules can't apply to an isolated component: a story has no + //
, no

and no landmarks of its own. Everything else runs. + config: { + rules: [ + { id: 'landmark-one-main', enabled: false }, + { id: 'page-has-heading-one', enabled: false }, + { id: 'region', enabled: false }, + ], + }, + }, docs: { theme: tansyTheme, }, diff --git a/CHANGELOG.md b/CHANGELOG.md index 589f267..43018b4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,32 @@ All notable changes to Tansy UI are recorded here. The format follows ## [Unreleased] +## [0.3.1] - 2026-09-28 + +Every component and the landing page now work from 320px phones to wide +desktops without scrolling sideways. + +### Fixed + +- **Inputs:** Input, FeaturedInput, NumberInput and Combobox shrink to fit + narrow containers. Inputs no longer hold their ~20-character native width + inside flex rows. +- **Tabs:** a row of tabs that doesn't fit scrolls sideways within itself, and + vertical tabs stack above their panel on phones. +- **ToggleGroup:** scrolls within itself when wider than the screen; its focus + ring is drawn inset so scrolling can't clip it. +- **Popups:** menus, selects, popovers and tooltips never grow past the screen + edge (they cap at Base UI's `--available-width`). +- **Landing page:** the header no longer crowds at tablet widths, and the code + sample fits its card at 1024px. +- **Storybook:** the Accessibility panel no longer counts page-level rules + (`
`, `

`, landmarks) that can't apply to an isolated component. + +### Added + +- `scripts/check-stories.mjs --width ` fails any story that makes the page + scroll sideways at that width. + ## [0.3.0] - 2026-09-28 A rebuild on Base UI with one consistent API, dark mode, and 28 new components. diff --git a/docs/CONVENTIONS.md b/docs/CONVENTIONS.md index 4990b5d..ff78c99 100644 --- a/docs/CONVENTIONS.md +++ b/docs/CONVENTIONS.md @@ -83,6 +83,20 @@ comment; Storybook's docs table reads them. as the WAI-ARIA pattern describes. Base UI does this when used as documented. - Respect `motion-reduce:` for animations. +## Responsive + +Every component must work from a 320px phone up without making the page +scroll sideways: + +- Inputs inside flex rows use `w-0 min-w-0 flex-1` so they can shrink. +- Rows of items (tabs, segmented controls) scroll within themselves on narrow + screens rather than widening the page. +- Positioned popups cap at `max-w-(--available-width)`; never give them a + `min-width` larger than that. +- Story layouts wrap (`flex-wrap`) instead of assuming a wide canvas. + +Check with `node scripts/check-stories.mjs --width 320` (and 375 and 768). + ## Stories - `title`: `Group/Name`. Groups: `Actions`, `Forms`, `Overlays`, `Navigation`, diff --git a/package-lock.json b/package-lock.json index 5f7480c..3ffa8e3 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "tansy-ui", - "version": "0.3.0", + "version": "0.3.1", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "tansy-ui", - "version": "0.3.0", + "version": "0.3.1", "dependencies": { "@base-ui/react": "^1.8.0", "clsx": "^2.1.1", diff --git a/package.json b/package.json index e800b98..51e5ce9 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "tansy-ui", "private": true, - "version": "0.3.0", + "version": "0.3.1", "description": "A themeable, accessible React component kit built on Base UI and Tailwind CSS v4.", "type": "module", "sideEffects": [ diff --git a/scripts/check-stories.mjs b/scripts/check-stories.mjs index f5a38be..1915f51 100644 --- a/scripts/check-stories.mjs +++ b/scripts/check-stories.mjs @@ -9,7 +9,7 @@ * - saves a screenshot. * * npm run build-storybook - * node scripts/check-stories.mjs [--filter forms-] [--mode dark] [--palette emerald] [--out dir] [--no-shots] + * node scripts/check-stories.mjs [--filter forms-] [--mode dark] [--palette emerald] [--width 375] [--out dir] [--no-shots] * * Exits non-zero when any story has an error or an axe violation. * Uses the system Chrome (CHROME_PATH, default /usr/bin/google-chrome). @@ -29,7 +29,8 @@ const DIR = resolve(opt('dir', 'storybook-static')) const FILTER = opt('filter', '') const MODE = opt('mode', 'light') const PALETTE = opt('palette', '') -const OUT = resolve(opt('out', `/tmp/tansy-story-check/${MODE}${PALETTE ? `-${PALETTE}` : ''}`)) +const WIDTH = Number(opt('width', 1100)) +const OUT = resolve(opt('out', `/tmp/tansy-story-check/${MODE}${PALETTE ? `-${PALETTE}` : ''}${WIDTH !== 1100 ? `-${WIDTH}` : ''}`)) const SHOTS = !args.includes('--no-shots') const CONCURRENCY = Number(opt('concurrency', 4)) @@ -71,7 +72,7 @@ await mkdir(OUT, { recursive: true }) const browser = await chromium.launch({ executablePath: process.env.CHROME_PATH ?? '/usr/bin/google-chrome' }) // Each story gets its own context: shared contexts leaked theme state and // axe runs between parallel pages. -const newContext = () => browser.newContext({ viewport: { width: 1100, height: 760 }, reducedMotion: 'reduce' }) +const newContext = () => browser.newContext({ viewport: { width: WIDTH, height: 760 }, reducedMotion: 'reduce' }) const results = [] async function check(story, attempt = 1) { @@ -128,6 +129,19 @@ async function check(story, attempt = 1) { return el ? el.textContent : null }) if (sbError) errors.push(`storybook: ${sbError.slice(0, 300)}`) + // Responsive: nothing may make the page scroll sideways at this width. + const overflow = await page.evaluate(() => document.documentElement.scrollWidth - document.documentElement.clientWidth) + if (overflow > 1) { + const culprits = await page.evaluate(() => { + const vw = document.documentElement.clientWidth + return [...document.querySelectorAll('body *')] + .filter((el) => el.getBoundingClientRect().right > vw + 1 && getComputedStyle(el).position !== 'fixed') + .filter((el) => ![...el.children].some((c) => c.getBoundingClientRect().right > vw + 1)) + .slice(0, 3) + .map((el) => `${el.tagName.toLowerCase()}${el.className && typeof el.className === 'string' ? '.' + el.className.split(' ').slice(0, 3).join('.') : ''}`) + }) + errors.push(`overflow: page scrolls ${overflow}px sideways at ${WIDTH}px → ${culprits.join(' | ')}`) + } await page.addScriptTag({ content: AXE }) axe = await page.evaluate(async () => { const r = await window.axe.run(document.body, { @@ -175,7 +189,7 @@ for (const r of bad) { for (const v of r.axe) console.log(` axe ${v.impact} ${v.id}: ${v.help} → ${v.nodes.join(' | ')}`) } console.log( - `\n${results.length} stories checked in ${MODE} mode${PALETTE ? `, ${PALETTE} palette` : ''}: ${results.length - bad.length} clean, ${bad.length} with problems.`, + `\n${results.length} stories checked in ${MODE} mode${PALETTE ? `, ${PALETTE} palette` : ''} at ${WIDTH}px: ${results.length - bad.length} clean, ${bad.length} with problems.`, ) console.log(`Screenshots and report.json in ${OUT}`) process.exit(bad.length ? 1 : 0) diff --git a/src/components/Avatar.stories.tsx b/src/components/Avatar.stories.tsx index 126794e..2045719 100644 --- a/src/components/Avatar.stories.tsx +++ b/src/components/Avatar.stories.tsx @@ -93,7 +93,7 @@ export const Fallbacks: Story = { export const WithStatus: Story = { render: (args) => (
-
+
{AVATAR_STATUSES.map((status) => (
@@ -101,7 +101,7 @@ export const WithStatus: Story = {
))}
-
+
{AVATAR_SIZES_LIST.map((size) => ( ))} diff --git a/src/components/Combobox.tsx b/src/components/Combobox.tsx index 5472f75..870a581 100644 --- a/src/components/Combobox.tsx +++ b/src/components/Combobox.tsx @@ -156,7 +156,7 @@ export function Combobox({ aria-invalid={invalid || undefined} aria-busy={loading || undefined} className={cn( - 'min-w-0 flex-1 bg-transparent text-fg outline-none placeholder:text-fg-muted disabled:cursor-not-allowed', + 'w-0 min-w-0 flex-1 bg-transparent text-fg outline-none placeholder:text-fg-muted disabled:cursor-not-allowed', multiple ? cn('min-w-16 px-1', CHIP_INPUT_HEIGHT[size]) : cn('h-full', controlPaddingX[size]), !multiple && startIcon != null && 'pl-2', inputClassName, @@ -206,7 +206,7 @@ export function Combobox({ )} {multiple ? ( - + {selectedOptions.map((option) => ( )} -
+
onValueChange(value) : undefined} className={cn( - 'min-w-0 flex-1 bg-transparent text-fg outline-none placeholder:text-fg-subtle disabled:cursor-not-allowed', + 'w-0 min-w-0 flex-1 bg-transparent text-fg outline-none placeholder:text-fg-subtle disabled:cursor-not-allowed', variant === 'underline' ? 'px-0.5' : controlPaddingX[size], startIcon != null && 'pl-2', endIcon != null && 'pr-2', diff --git a/src/components/NativeSelect.stories.tsx b/src/components/NativeSelect.stories.tsx index 9c4a150..4b6cff5 100644 --- a/src/components/NativeSelect.stories.tsx +++ b/src/components/NativeSelect.stories.tsx @@ -99,7 +99,7 @@ export const AlignedWithInput: Story = { render: (args) => (
{SIZES.map((size) => ( -
+
diff --git a/src/components/NumberInput.tsx b/src/components/NumberInput.tsx index 8687e1f..1a79a23 100644 --- a/src/components/NumberInput.tsx +++ b/src/components/NumberInput.tsx @@ -110,7 +110,7 @@ export function NumberInput({ {startAddon != null && {startAddon}} ( -
+
{POPUP_SIDES.map((side) => (
(
{SIZES.map((size) => ( -
+