diff --git a/.changeset/banner-solid-sticky.md b/.changeset/banner-solid-sticky.md new file mode 100644 index 00000000..2608137f --- /dev/null +++ b/.changeset/banner-solid-sticky.md @@ -0,0 +1,12 @@ +--- +'@wirecore/wirelayer-recipes': minor +'@wirecore/wirelayer-css': minor +'@wirecore/wirelayer-vue': minor +'@wirecore/wirelayer-react': minor +'@wirecore/wirelayer-native': minor +--- + +Banner for permanent, page-wide notices ("TEST SYSTEM", maintenance): `solid` fills it opaquely in the colour of the +variant with the matching text colour (info → `bg-info text-on-info`, …, neutral → `bg-fg text-bg`); `position="sticky"` +keeps it in the flow and at the top edge while the page scrolls (opaque also without `solid`, below dialogs and +drawers). React Native gets `solid` (no `sticky`). Stories _Solid_ and _Sticky_. diff --git a/.changeset/tabs-lazy-mount-keeps-panel.md b/.changeset/tabs-lazy-mount-keeps-panel.md new file mode 100644 index 00000000..d8d75f0b --- /dev/null +++ b/.changeset/tabs-lazy-mount-keeps-panel.md @@ -0,0 +1,7 @@ +--- +'@wirecore/wirelayer-vue': patch +--- + +Tabs with `lazyMount`: the panel that was open when the tabs mounted stays mounted (hidden) when its tab is left, as +documented – only `unmountOnExit` removes a panel again. Ark's Vue presence forgot that panel and removed it, so e.g. +form fields in it were gone on submit. TabsContent now mounts the panels itself with the same rules. diff --git a/.changeset/textarea-autoresize-hidden.md b/.changeset/textarea-autoresize-hidden.md new file mode 100644 index 00000000..4ec4608a --- /dev/null +++ b/.changeset/textarea-autoresize-hidden.md @@ -0,0 +1,8 @@ +--- +'@wirecore/wirelayer-vue': patch +'@wirecore/wirelayer-react': patch +--- + +Textarea with `autoResize`: measures its height again once it becomes visible and whenever its width changes. Mounted +hidden (an inactive tab, a closed accordion, a popover before it opens) it measured 0 and stayed one line high. A +hidden textarea now keeps its rows until it can be measured. Story _Textarea in Tabs_. diff --git a/packages/mcp/data/components.json b/packages/mcp/data/components.json index 2fe68e4a..36281473 100644 --- a/packages/mcp/data/components.json +++ b/packages/mcp/data/components.json @@ -2233,7 +2233,13 @@ "name": "position", "type": "BannerPosition", "optional": true, - "description": "`inline` (default): in the flow; `top`/`bottom`: fixed to that edge of the window" + "description": "`inline` (default): in the flow; `top`/`bottom`: fixed to that edge of the window; `sticky`: in the flow, stays at the top edge while the page scrolls (opaque, below dialogs and drawers)" + }, + { + "name": "solid", + "type": "boolean", + "optional": true, + "description": "Full fill in the colour of the variant (opaque) – for permanent notices like \"TEST SYSTEM\" or maintenance" }, { "name": "dismissible", @@ -2314,7 +2320,13 @@ "name": "position", "type": "BannerPosition", "optional": true, - "description": "`inline` (default): in the flow; `top`/`bottom`: fixed to that edge of the window" + "description": "`inline` (default): in the flow; `top`/`bottom`: fixed to that edge of the window; `sticky`: in the flow, stays at the top edge while the page scrolls (opaque, below dialogs and drawers)" + }, + { + "name": "solid", + "type": "boolean", + "optional": true, + "description": "Full fill in the colour of the variant (opaque) – for permanent notices like \"TEST SYSTEM\" or maintenance" }, { "name": "dismissible", @@ -38863,9 +38875,15 @@ }, { "name": "position", - "type": "BannerPosition", + "type": "Exclude", + "optional": true, + "description": "`inline` (default) in the layout, `top`/`bottom` over that edge of the screen (`sticky` is web only)" + }, + { + "name": "solid", + "type": "boolean", "optional": true, - "description": "`inline` (default) in the layout, `top`/`bottom` over that edge of the screen" + "description": "Full fill in the colour of the variant (opaque) – for permanent notices like \"TEST SYSTEM\" or maintenance" }, { "name": "dismissible", diff --git a/packages/native/src/components/Banner/Banner.stories.tsx b/packages/native/src/components/Banner/Banner.stories.tsx index 29f7498a..68b7f970 100644 --- a/packages/native/src/components/Banner/Banner.stories.tsx +++ b/packages/native/src/components/Banner/Banner.stories.tsx @@ -48,3 +48,27 @@ export const Variants: Story = { ), }; + +/** Full fill in the colour of the variant – for permanent notices like "TEST SYSTEM" */ +export const Solid: Story = { + name: 'Solid', + render: () => ( + + + New: download invoices as PDF. + + + Your changes are live. + + + Data is reset every night. + + + Payments are currently not being processed. + + + Trial ends in 5 days. + + + ), +}; diff --git a/packages/native/src/components/Banner/Banner.tsx b/packages/native/src/components/Banner/Banner.tsx index 8c47920d..b4c5fd22 100644 --- a/packages/native/src/components/Banner/Banner.tsx +++ b/packages/native/src/components/Banner/Banner.tsx @@ -11,8 +11,10 @@ export interface BannerProps extends ViewProps { variant?: BannerVariant; /** Bold text before the message */ title?: string; - /** `inline` (default) in the layout, `top`/`bottom` over that edge of the screen */ - position?: BannerPosition; + /** `inline` (default) in the layout, `top`/`bottom` over that edge of the screen (`sticky` is web only) */ + position?: Exclude; + /** Full fill in the colour of the variant (opaque) – for permanent notices like "TEST SYSTEM" or maintenance */ + solid?: boolean; /** Shows a close button */ dismissible?: boolean; /** Controlled visibility */ @@ -40,6 +42,7 @@ export function Banner({ variant = 'info', title, position, + solid = false, dismissible = false, open, onOpenChange, @@ -54,7 +57,7 @@ export function Banner({ }: BannerProps) { const translations = useTranslations(); const [internal, setInternal] = useState(true); - const styles = banner({ variant, position }); + const styles = banner({ variant, position, solid }); if (!(open ?? internal)) return null; const dismiss = () => { setInternal(false); diff --git a/packages/parity/e2e/controls.spec.ts b/packages/parity/e2e/controls.spec.ts index bd31a646..e3302942 100644 --- a/packages/parity/e2e/controls.spec.ts +++ b/packages/parity/e2e/controls.spec.ts @@ -118,6 +118,20 @@ test.describe('Textarea', () => { expect(scroll).toBeLessThanOrEqual(1); }); + test('autoResize in a tab that was hidden when it mounted: as high as its text once the tab opens', async ({ + page, + }) => { + await openStory(page, 'forms-textarea--in-tabs'); + await page.getByRole('tab', { name: 'Notes' }).click(); + const area = page.getByRole('textbox', { name: 'Notes' }); + await expect(area).toBeVisible(); + // Four lines, not one: the height was measured again once the tab became visible + const line = await area.evaluate((element) => parseFloat(getComputedStyle(element).lineHeight)); + await expect.poll(async () => (await area.boundingBox())!.height).toBeGreaterThan(3 * line); + const scroll = await area.evaluate((element) => element.scrollHeight - element.clientHeight); + expect(scroll).toBeLessThanOrEqual(1); + }); + test('defaultValue arrives without v-model; the counter counts it', async ({ page }) => { await openStory(page, 'forms-textarea--initial-value'); const area = page.getByRole('textbox', { name: 'Comment' }); diff --git a/packages/parity/e2e/visual/__screenshots__/native-feedback-banner--solid.png b/packages/parity/e2e/visual/__screenshots__/native-feedback-banner--solid.png new file mode 100644 index 00000000..09af1b31 Binary files /dev/null and b/packages/parity/e2e/visual/__screenshots__/native-feedback-banner--solid.png differ diff --git a/packages/parity/e2e/visual/__screenshots__/react-feedback-banner--solid.png b/packages/parity/e2e/visual/__screenshots__/react-feedback-banner--solid.png new file mode 100644 index 00000000..1fed2b1c Binary files /dev/null and b/packages/parity/e2e/visual/__screenshots__/react-feedback-banner--solid.png differ diff --git a/packages/parity/e2e/visual/__screenshots__/react-feedback-banner--sticky.png b/packages/parity/e2e/visual/__screenshots__/react-feedback-banner--sticky.png new file mode 100644 index 00000000..d68472af Binary files /dev/null and b/packages/parity/e2e/visual/__screenshots__/react-feedback-banner--sticky.png differ diff --git a/packages/parity/e2e/visual/__screenshots__/react-forms-textarea--in-tabs.png b/packages/parity/e2e/visual/__screenshots__/react-forms-textarea--in-tabs.png new file mode 100644 index 00000000..0315f68b Binary files /dev/null and b/packages/parity/e2e/visual/__screenshots__/react-forms-textarea--in-tabs.png differ diff --git a/packages/parity/src/behavior.test.ts b/packages/parity/src/behavior.test.ts index 067c231c..dcfd190b 100644 --- a/packages/parity/src/behavior.test.ts +++ b/packages/parity/src/behavior.test.ts @@ -262,6 +262,48 @@ describe.each(frameworks)('%s', (framework) => { expect(screen.getByRole('tab', { name: 'Process' })).toHaveAttribute('aria-selected', 'true'); expect(screen.getByRole('tabpanel', { name: 'Process' })).toHaveTextContent('Content B'); }); + + it.each([ + // lazyMount: a panel from its first selection on, kept (hidden) when its tab is left + [{ lazyMount: true }, { a: true, c: false }], + // unmountOnExit as well: removed again when its tab is left + [ + { lazyMount: true, unmountOnExit: true }, + { a: false, c: false }, + ], + // Neither: every panel is there from the start + [{}, { a: true, c: true }], + ])('%o: which panels stay in the DOM after a switch from A to B', async (props, expected) => { + await render( + framework, + el( + 'Tabs', + { defaultValue: 'a', label: 'Project', ...props }, + el( + 'TabsList', + {}, + el('TabsTrigger', { value: 'a' }, 'Overview'), + el('TabsTrigger', { value: 'b' }, 'Process'), + el('TabsTrigger', { value: 'c' }, 'Team') + ), + el('TabsContent', { value: 'a' }, 'Content A'), + el('TabsContent', { value: 'b' }, 'Content B'), + el('TabsContent', { value: 'c' }, 'Content C') + ) + ); + await userEvent.click(screen.getByRole('tab', { name: 'Process' })); + expect(screen.getByRole('tabpanel', { name: 'Process' })).toHaveTextContent('Content B'); + // Ark hides or removes the panel that was left once its exit finished + await waitFor(() => { + const a = screen.queryByText('Content A'); + expect(!!a).toBe(expected.a); + if (a) expect(a).not.toBeVisible(); + }); + expect(!!screen.queryByText('Content C')).toBe(expected.c); + // Back on A: shown again either way + await userEvent.click(screen.getByRole('tab', { name: 'Overview' })); + expect(screen.getByRole('tabpanel', { name: 'Overview' })).toHaveTextContent('Content A'); + }); }); describe('Steps', () => { diff --git a/packages/parity/src/cases.ts b/packages/parity/src/cases.ts index 0428c698..f63781be 100644 --- a/packages/parity/src/cases.ts +++ b/packages/parity/src/cases.ts @@ -2263,6 +2263,15 @@ export const cases: [string, El][] = [ 'Banner without icon, bottom', el('Banner', { hideIcon: true, position: 'bottom', dismissLabel: 'Dismiss' }, 'Cookies'), ], + ...(['info', 'success', 'warn', 'danger', 'neutral'] as const).map((variant): [string, El] => [ + `Banner ${variant} solid`, + el('Banner', { variant, solid: true, dismissible: true, title: 'Test system' }, 'Data is reset every night.'), + ]), + ['Banner sticky', el('Banner', { variant: 'warn', position: 'sticky' }, 'Maintenance on Saturday.')], + [ + 'Banner sticky solid', + el('Banner', { variant: 'warn', position: 'sticky', solid: true, title: 'TEST SYSTEM' }, 'Not for real data.'), + ], ...(['success', 'info', 'warn', 'error', '403', '404', '500'] as const).map((status): [string, El] => [ `Result ${status}`, el('Result', { status }), diff --git a/packages/react/src/components/Banner/Banner.stories.tsx b/packages/react/src/components/Banner/Banner.stories.tsx index 79589850..f5e3aa79 100644 --- a/packages/react/src/components/Banner/Banner.stories.tsx +++ b/packages/react/src/components/Banner/Banner.stories.tsx @@ -13,7 +13,7 @@ const meta = { }, argTypes: { variant: { control: 'inline-radio', options: ['info', 'success', 'warn', 'danger', 'neutral'] }, - position: { control: 'inline-radio', options: ['inline', 'top', 'bottom'] }, + position: { control: 'inline-radio', options: ['inline', 'top', 'bottom', 'sticky'] }, }, parameters: { layout: 'fullscreen' }, } satisfies Meta; @@ -75,3 +75,42 @@ export const Top: Story = { ), }; + +/** Full fill in the colour of the variant – for permanent notices; the close button and icon take the text colour */ +export const Solid: Story = { + render: () => ( +
+ + New features in the customer portal – available to everyone today. + + + Your data has been transferred. + + + Data is reset every night. + + + Payment processing is down. We are working on it. + + + Trial ends in 5 days. + +
+ ), +}; + +/** In the flow above the content, stays at the top edge while the page scrolls – opaque, also without solid */ +export const Sticky: Story = { + render: () => ( +
+ + Not for real data. + +
+ {Array.from({ length: 12 }, (_, index) => ( +

Page content, row {index + 1} – scroll down, the banner stays.

+ ))} +
+
+ ), +}; diff --git a/packages/react/src/components/Banner/Banner.tsx b/packages/react/src/components/Banner/Banner.tsx index 3a7e960b..0a7d979a 100644 --- a/packages/react/src/components/Banner/Banner.tsx +++ b/packages/react/src/components/Banner/Banner.tsx @@ -17,8 +17,13 @@ export interface BannerProps extends Omit, 'title'> { variant?: BannerVariant; /** Bold text before the message */ title?: string; - /** `inline` (default): in the flow; `top`/`bottom`: fixed to that edge of the window */ + /** + * `inline` (default): in the flow; `top`/`bottom`: fixed to that edge of the window; `sticky`: in the flow, stays at + * the top edge while the page scrolls (opaque, below dialogs and drawers) + */ position?: BannerPosition; + /** Full fill in the colour of the variant (opaque) – for permanent notices like "TEST SYSTEM" or maintenance */ + solid?: boolean; /** Shows a close button */ dismissible?: boolean; /** Controlled visibility */ @@ -56,6 +61,7 @@ export function Banner({ variant, title, position, + solid, dismissible, open, onOpenChange, @@ -70,7 +76,7 @@ export function Banner({ ...props }: BannerProps) { const banner = useRecipe('banner', bannerRecipe, classes); - const styles = banner({ variant, position }); + const styles = banner({ variant, position, solid }); const translations = useTranslations(); const [internal, setInternal] = useState(true); // A remembered dismissal is only known in the browser (after the server-rendered first paint) diff --git a/packages/react/src/components/Textarea/Textarea.stories.tsx b/packages/react/src/components/Textarea/Textarea.stories.tsx index fb9176a3..1fd9c05b 100644 --- a/packages/react/src/components/Textarea/Textarea.stories.tsx +++ b/packages/react/src/components/Textarea/Textarea.stories.tsx @@ -1,6 +1,7 @@ import type { Meta, StoryObj } from '@storybook/react-vite'; import { useState } from 'react'; import { Field } from '../Field/Field.js'; +import { Tabs, TabsContent, TabsList, TabsTrigger } from '../Tabs/Tabs.js'; import { Textarea, type TextareaProps } from './Textarea.js'; function Demo(args: TextareaProps) { @@ -89,3 +90,26 @@ export const SizesAndStates: Story = { ), }; + +function InTabsDemo() { + const [text, setText] = useState('Line 1\nLine 2\nLine 3\nLine 4'); + return ( + + + General + Notes + + + Name and e-mail address. + + + +