Make every component and the landing page responsive (v0.3.1)

Every story and the landing page now fit from a 320px phone to a wide
desktop without scrolling sideways.

- Inputs in flex rows (Input, FeaturedInput, NumberInput, Combobox) shrink
  instead of holding their native width
- Tab rows and ToggleGroup scroll within themselves on narrow screens;
  vertical tabs stack above their panel on phones
- Positioned popups cap at Base UI's --available-width
- Landing page: tablet header no longer crowds; code sample fits at 1024px
- Storybook a11y panel skips page-level rules that can't apply to a story
- check-stories.mjs gains --width and fails on horizontal overflow; all
  423 stories pass at 320, 375, 768 and desktop widths in both modes
This commit is contained in:
thekhalidsha committed 2026-09-28 22:47:26 +05:30
1 parent f01de83733
commit 694815d4d5
24 files changed
+136 -31

No files matched your search

+11
View File
@@ -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
// <main>, no <h1> 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,
},
+26
View File
@@ -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
(`<main>`, `<h1>`, landmarks) that can't apply to an isolated component.
### Added
- `scripts/check-stories.mjs --width <px>` 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.
+14
View File
@@ -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`,
+2 -2
View File
@@ -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",
+1 -1
View File
@@ -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": [
+18 -4
View File
@@ -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)
+2 -2
View File
@@ -93,7 +93,7 @@ export const Fallbacks: Story = {
export const WithStatus: Story = {
render: (args) => (
<div className="grid gap-5">
<div className="flex items-center gap-5">
<div className="flex flex-wrap items-center gap-5">
{AVATAR_STATUSES.map((status) => (
<div key={status} className="flex flex-col items-center gap-2">
<Avatar {...args} status={status} />
@@ -101,7 +101,7 @@ export const WithStatus: Story = {
</div>
))}
</div>
<div className="flex items-end gap-4">
<div className="flex flex-wrap items-end gap-4">
{AVATAR_SIZES_LIST.map((size) => (
<Avatar key={size} name="John Smith" src={PORTRAITS.john} size={size} status="online" />
))}
+2 -2
View File
@@ -156,7 +156,7 @@ export function Combobox<Multiple extends boolean | undefined = false>({
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 extends boolean | undefined = false>({
</span>
)}
{multiple ? (
<BaseCombobox.Chips className="flex min-w-0 flex-1 flex-wrap items-center gap-1 py-1 pl-1.5">
<BaseCombobox.Chips className="flex w-0 min-w-0 flex-1 flex-wrap items-center gap-1 py-1 pl-1.5">
{selectedOptions.map((option) => (
<BaseCombobox.Chip
key={option.value}
+1 -1
View File
@@ -125,7 +125,7 @@ export function FeaturedInput({
{startIcon}
</span>
)}
<div className="relative min-w-0 flex-1">
<div className="relative w-0 min-w-0 flex-1">
<BaseInput
ref={setRefs}
type={isPassword && revealed ? 'text' : type}
+1 -1
View File
@@ -92,7 +92,7 @@ export function Input({
disabled={disabled}
onValueChange={onValueChange ? (value) => 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',
+1 -1
View File
@@ -99,7 +99,7 @@ export const AlignedWithInput: Story = {
render: (args) => (
<div className="grid gap-4">
{SIZES.map((size) => (
<div key={size} className="flex items-end gap-3">
<div key={size} className="flex flex-wrap items-end gap-3">
<Input label={`Name (${size})`} size={size} placeholder="Jane Doe" className="w-56" />
<NativeSelect {...args} size={size} className="w-56" />
</div>
+1 -1
View File
@@ -110,7 +110,7 @@ export function NumberInput({
{startAddon != null && <span className={cn(NUMBER_ADDON, 'border-r')}>{startAddon}</span>}
<NumberField.Input
className={cn(
'min-w-0 flex-1 bg-transparent text-fg tabular-nums outline-none placeholder:text-fg-subtle disabled:cursor-not-allowed',
'w-0 min-w-0 flex-1 bg-transparent text-fg tabular-nums outline-none placeholder:text-fg-subtle disabled:cursor-not-allowed',
controlPaddingX[size],
inputClassName,
)}
+1 -1
View File
@@ -119,7 +119,7 @@ export const Sides: Story = {
docs: { ...ownFrame(460).docs, description: { story: 'Each side, open. A popover flips when the preferred side has no room.' } },
},
render: (args) => (
<div className="mx-auto grid w-fit grid-cols-3 grid-rows-3 place-items-center gap-x-56 gap-y-24 py-6">
<div className="mx-auto grid w-fit grid-cols-3 grid-rows-3 place-items-center gap-x-12 gap-y-24 py-6 sm:gap-x-56">
{POPUP_SIDES.map((side) => (
<div
key={side}
+1 -1
View File
@@ -125,7 +125,7 @@ export const AlignedWithInput: Story = {
render: (args) => (
<div className="grid gap-4">
{SIZES.map((size) => (
<div key={size} className="flex items-end gap-3">
<div key={size} className="flex flex-wrap items-end gap-3">
<Input label={`Search (${size})`} size={size} placeholder="Jane Doe" className="w-56" />
<Select {...args} size={size} label="Department" className="w-56" />
<Button size={size}>Filter</Button>
+1 -1
View File
@@ -31,7 +31,7 @@ export const Playground: Story = {}
export const Shapes: Story = {
render: () => (
<div className="flex items-center gap-6">
<div className="flex flex-wrap items-center gap-6">
<Skeleton variant="circle" />
<Skeleton variant="circle" width={56} height={56} />
<Skeleton width={160} height={96} className="rounded-xl" />
+18 -1
View File
@@ -100,11 +100,13 @@ function TabsRoot({
function TabsList({ className, children, ...props }: TabsListProps) {
const { variant, orientation, fullWidth } = useContext(TabsStyleContext)
return (
const list = (
<BaseTabs.List
className={cn(
TABS_LIST_STYLES[variant][orientation],
orientation === 'horizontal' && 'min-w-max',
fullWidth ? 'w-full' : orientation === 'horizontal' && variant !== 'underline' && 'w-fit',
orientation === 'horizontal' && variant === 'underline' && 'min-w-full',
orientation === 'vertical' && 'shrink-0 self-start',
className,
)}
@@ -114,6 +116,21 @@ function TabsList({ className, children, ...props }: TabsListProps) {
<BaseTabs.Indicator className={TABS_INDICATOR_STYLES[variant][orientation]} />
</BaseTabs.List>
)
if (orientation === 'vertical') return list
// When the tabs don't fit (phones), the row scrolls sideways instead of
// widening the page. The padding keeps focus rings and the underline
// indicator, which sits 1px below the list, from being clipped.
return (
<div
className={cn(
'-m-1 min-w-0 max-w-[calc(100%+0.5rem)] overflow-x-auto overscroll-x-contain p-1 [scrollbar-width:none] [&::-webkit-scrollbar]:hidden',
!fullWidth && variant !== 'underline' && 'w-fit',
)}
>
{list}
</div>
)
}
function TabsTab({ value, icon, badge, className, children, ...props }: TabsTabProps) {
+1 -1
View File
@@ -101,7 +101,7 @@ export const Variants: Story = {
export const Sizes: Story = {
render: (args) => (
<div className="grid justify-items-start gap-4">
<div className="grid grid-cols-[minmax(0,1fr)] gap-4">
{SIZES.map((size) => (
<div key={size} className="flex flex-wrap items-center gap-4">
<ToggleGroup {...args} size={size} aria-label={`Date range, size ${size}`} />
+4 -1
View File
@@ -150,6 +150,8 @@ export function ToggleGroup({
'items-stretch',
fullWidth ? 'flex' : 'inline-flex',
orientation === 'vertical' && 'flex-col',
// Scrolls within itself on narrow screens instead of widening the page.
orientation === 'horizontal' && 'max-w-full overflow-x-auto [scrollbar-width:none] [&::-webkit-scrollbar]:hidden',
TOGGLE_GROUP_FRAME[variant],
TOGGLE_GROUP_HEIGHTS[size],
className,
@@ -164,7 +166,8 @@ export function ToggleGroup({
aria-label={iconOnly ? item.label : undefined}
className={cn(
itemBase,
'outline-hidden focus-visible:relative focus-visible:z-10 focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-primary-500',
// Inset ring: the group can scroll, which would clip an outer one.
'outline-hidden focus-visible:relative focus-visible:z-10 focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-primary-500',
TOGGLE_GROUP_ITEM[variant],
TOGGLE_ITEM_SIZES[size],
iconOnly && TOGGLE_ICON_ITEM_SIZES[size],
+3 -3
View File
@@ -104,7 +104,7 @@ export const Sides: Story = {
export const Alignment: Story = {
parameters: pinnedOpen(),
render: (args) => (
<div className="flex gap-24 pt-10">
<div className="flex flex-wrap gap-x-24 gap-y-16 pt-10">
{POPUP_ALIGNS.map((align) => (
<Tooltip key={align} {...args} align={align} content={`align="${align}"`} open>
<Button variant="outline" color="neutral">
@@ -122,7 +122,7 @@ export const Colors: Story = {
'`neutral` inverts the page (dark in light mode), `primary` uses the brand colour, `light` is a bordered surface. Pinned open for reference.',
),
render: (args) => (
<div className="flex gap-16 pt-10">
<div className="flex flex-wrap gap-x-16 gap-y-14 pt-10">
{TOOLTIP_COLORS_LIST.map((color) => (
<Tooltip key={color} {...args} color={color} content={`${color[0].toUpperCase()}${color.slice(1)} tooltip`} open>
<Button variant="outline" color="neutral">
@@ -242,7 +242,7 @@ export const InfoTipNextToLabel: Story = {
export const InfoTipColors: Story = {
parameters: ownFrame(),
render: () => (
<div className="flex gap-24 pt-14">
<div className="flex flex-wrap gap-x-24 gap-y-16 pt-14">
{TOOLTIP_COLORS_LIST.map((color) => (
<span key={color} className="inline-flex items-center gap-1.5 text-sm text-fg">
{color}
+1 -1
View File
@@ -69,7 +69,7 @@ export type DropdownMenuItemData =
| DropdownMenuLabel
| DropdownMenuSubmenu
export const menuPopupClass = 'min-w-48 max-h-(--available-height) overflow-y-auto p-1'
export const menuPopupClass = 'min-w-[min(12rem,var(--available-width,12rem))] max-h-(--available-height) overflow-y-auto p-1'
export const menuDangerItem =
'text-danger-700 data-highlighted:bg-danger-50 dark:text-danger-300 dark:data-highlighted:bg-danger-500/15 ' +
+2 -1
View File
@@ -11,7 +11,8 @@ export type TabsOrientation = 'horizontal' | 'vertical'
export const TABS_VARIANTS: TabsVariant[] = ['underline', 'pills', 'enclosed']
export const tabsRoot = 'flex flex-col gap-4 data-[orientation=vertical]:flex-row data-[orientation=vertical]:gap-6'
/** Vertical tabs sit beside their panel from `sm` up; on phones they stack above it. */
export const tabsRoot = 'flex min-w-0 flex-col gap-4 sm:data-[orientation=vertical]:flex-row sm:data-[orientation=vertical]:gap-6'
/** variant → orientation → list classes. */
export const TABS_LIST_STYLES: Record<TabsVariant, Record<TabsOrientation, string>> = {
+3 -3
View File
@@ -25,9 +25,9 @@ export const TOOLTIP_ARROW_COLORS: Record<TooltipColor, string> = {
}
export const TOOLTIP_SIZES: Record<TooltipSize, string> = {
sm: 'max-w-56 rounded-md px-2 py-1 text-xs leading-4',
md: 'max-w-72 rounded-lg px-2.5 py-1.5 text-[0.8125rem] leading-5',
lg: 'max-w-80 rounded-lg px-3.5 py-2.5 text-sm leading-5',
sm: 'max-w-[min(14rem,var(--available-width,14rem))] rounded-md px-2 py-1 text-xs leading-4',
md: 'max-w-[min(18rem,var(--available-width,18rem))] rounded-lg px-2.5 py-1.5 text-[0.8125rem] leading-5',
lg: 'max-w-[min(20rem,var(--available-width,20rem))] rounded-lg px-3.5 py-2.5 text-sm leading-5',
}
/** Help icon button next to a label. */
+15
View File
@@ -152,6 +152,7 @@
}
.brand-by {
white-space: nowrap;
padding-left: 0.6rem;
border-left: 1px solid var(--line-strong);
font-size: 0.8125rem;
@@ -805,6 +806,20 @@
/* ---------- Responsive ---------- */
/* Tablets: the nav needs the room the tagline was using. */
@media (max-width: 900px) {
.brand-by {
display: none;
}
}
/* Three narrow "Why" cards: keep the longest code line inside its card. */
@media (min-width: 961px) and (max-width: 1199px) {
.code-sample pre {
font-size: 0.6875rem;
}
}
@media (max-width: 960px) {
.hero,
.playground-grid {
+6 -2
View File
@@ -54,9 +54,13 @@ export const controlBox =
'data-disabled:cursor-not-allowed data-disabled:opacity-55 disabled:cursor-not-allowed disabled:opacity-55'
/** Popups: menus, selects, popovers, dialogs. */
/** In dark mode popups sit a step lighter than the card behind them. */
/**
* In dark mode popups sit a step lighter than the card behind them.
* `--available-width` comes from Base UI's positioner, so a menu or select never
* grows past the screen edge; where it isn't set (dialogs) the cap is ignored.
*/
export const popupSurface =
'rounded-xl border border-border bg-surface text-fg shadow-popup outline-hidden dark:bg-surface-muted'
'rounded-xl border border-border bg-surface text-fg shadow-popup outline-hidden dark:bg-surface-muted max-w-(--available-width)'
/** Enter and exit motion for popups that grow from their trigger. */
export const popupMotion =