diff --git a/@navikt/core/react/src/dropdown/dropdown.stories.tsx b/@navikt/core/react/src/dropdown/dropdown.stories.tsx index c8b5c61d6d..c67bb9a149 100644 --- a/@navikt/core/react/src/dropdown/dropdown.stories.tsx +++ b/@navikt/core/react/src/dropdown/dropdown.stories.tsx @@ -1,4 +1,4 @@ -import { Meta } from "@storybook/react"; +import { Meta, StoryObj } from "@storybook/react"; import React, { useState } from "react"; import { Button } from "../button"; import Dropdown from "./Dropdown"; @@ -6,10 +6,15 @@ import Dropdown from "./Dropdown"; export default { title: "ds-react/Dropdown", component: Dropdown, -} as Meta; + parameters: { + chromatic: { disable: true }, + }, +} satisfies Meta; -export const Default = () => { - return ( +type Story = StoryObj; + +export const Default: Story = { + render: () => ( console.log(event)}> Toggle @@ -33,10 +38,10 @@ export const Default = () => { - ); + ), }; -export const DefaultOpen = { +export const DefaultOpen: Story = { render: () => ( console.log(event)} defaultOpen> @@ -57,20 +62,41 @@ export const DefaultOpen = { ), - args: { chromatic: { delay: 300 } }, }; -export const ControlledOpen = () => { - const [openState, setOpenState] = useState(true); - return ( - console.log(event)} open={openState}> - - console.log("ONCLOSE CONTROLLED")} - > +export const ControlledOpen: Story = { + render: () => { + const [openState, setOpenState] = useState(true); + return ( + console.log(event)} open={openState}> + + console.log("ONCLOSE CONTROLLED")} + > + + + Systemer og oppslagsverk + + console.log("GroupedList.Item-click")} + > + Gosys + + + + + ); + }, +}; + +export const Chromatic: Story = { + render: () => ( + console.log(event)} open> + Toggle + Systemer og oppslagsverk @@ -81,8 +107,18 @@ export const ControlledOpen = () => { Gosys + + + console.log("Item-click")}> + Gosys + + Psys + Infotrygd + - ); + ), + parameters: { + chromatic: { disable: false, delay: 300 }, + }, }; -ControlledOpen.args = { chromatic: { delay: 300 } }; diff --git a/@navikt/core/react/src/form/error-summary/error-summary.stories.tsx b/@navikt/core/react/src/form/error-summary/error-summary.stories.tsx index a7ba240646..290757941d 100644 --- a/@navikt/core/react/src/form/error-summary/error-summary.stories.tsx +++ b/@navikt/core/react/src/form/error-summary/error-summary.stories.tsx @@ -1,5 +1,6 @@ -import { Meta } from "@storybook/react"; +import { Meta, StoryObj } from "@storybook/react"; import React from "react"; +import { VStack } from "../../layout/stack"; import { ErrorSummary } from "./ErrorSummary"; export default { @@ -18,9 +19,14 @@ export default { }, }, }, -} as Meta; + parameters: { + chromatic: { disable: true }, + }, +} satisfies Meta; + +type Story = StoryObj; -export const Default = { +export const Default: Story = { render: (props) => ( ( - - Checkbox må fylles ut - - Tekstfeltet må ha en godkjent e-mail - - -); +export const Small: Story = { + render: () => ( + + Checkbox må fylles ut + + Tekstfeltet må ha en godkjent e-mail + + + ), +}; + +export const Chromatic: Story = { + render: () => ( + +
+

Default

+ + Checkbox må fylles ut + + Tekstfeltet må ha en godkjent e-mail + + +
+
+

Small

+ + Checkbox må fylles ut + + Tekstfeltet må ha en godkjent e-mail + + +
+
+ ), + parameters: { + chromatic: { disable: false }, + }, +}; diff --git a/@navikt/core/react/src/form/fieldset/fieldset.stories.tsx b/@navikt/core/react/src/form/fieldset/fieldset.stories.tsx index f7581d9c6a..51d0ab3be9 100644 --- a/@navikt/core/react/src/form/fieldset/fieldset.stories.tsx +++ b/@navikt/core/react/src/form/fieldset/fieldset.stories.tsx @@ -1,5 +1,6 @@ -import { Meta } from "@storybook/react"; +import { Meta, StoryObj } from "@storybook/react"; import React from "react"; +import { VStack } from "../../layout/stack"; import TextField from "../textfield/TextField"; import { Fieldset } from "./index"; @@ -26,7 +27,12 @@ export default { type: "boolean", }, }, -} as Meta; + parameters: { + chromatic: { disable: true }, + }, +} satisfies Meta; + +type Story = StoryObj; const content = ( <> @@ -35,88 +41,117 @@ const content = ( ); -export const Default = { - render: (props) => { - return ( -
- {content} -
- ); - }, +const contentWithError = ( + <> + + + +); +export const Default: Story = { args: { + legend: "Mollit eiusmod", + description: + "Do ullamco amet mollit labore tempor minim cupidatat dolore voluptate velit irure.", errorPropagation: true, + children: content, }, }; -export const Small = () => ( -
- {content} -
-); +export const Small: Story = { + args: { + legend: "Mollit eiusmod", + description: + "Do ullamco amet mollit labore tempor minim cupidatat dolore voluptate velit irure.", + errorPropagation: true, + children: content, + size: "small", + }, +}; -export const Description = () => ( -
- - -
-); +export const ErrorPropagation: Story = { + args: { + legend: "Mollit eiusmod", + description: + "Do ullamco amet mollit labore tempor minim cupidatat dolore voluptate velit irure.", + errorPropagation: false, + children: contentWithError, + }, +}; -export const ErrorPropagation = () => ( -
- - -
-); +export const Error: Story = { + args: { + legend: "Mollit eiusmod", + description: + "Do ullamco amet mollit labore tempor minim cupidatat dolore voluptate velit irure.", + children: content, + error: "Laborum officia nisi aliqua esse minim in amet.", + }, +}; -export const Error = () => ( -
-
- {content} -
-
- {content} -
-
-); +export const Disabled: Story = { + args: { + legend: "Mollit eiusmod", + description: + "Do ullamco amet mollit labore tempor minim cupidatat dolore voluptate velit irure.", + children: content, + disabled: true, + }, +}; -export const Disabled = () => ( -
-
- {content} -
-
- {content} -
-
-); +export const HideLegend: Story = { + args: { + legend: "Mollit eiusmod", + description: + "Do ullamco amet mollit labore tempor minim cupidatat dolore voluptate velit irure.", + children: content, + hideLegend: true, + }, +}; -export const HideLegend = () => ( -
- {content} -
-); +export const Chromatic: Story = { + render: () => { + return ( + +
+

Default

+ {/* @ts-expect-error Args are Partial here */} +
+
+
+

Small

+ {/* @ts-expect-error Args are Partial here */} +
+
+
+

ErrorPropagation

+ {/* @ts-expect-error Args are Partial here */} +
+
+
+

Error

+ {/* @ts-expect-error Args are Partial here */} +
+
+
+

Error small

+ {/* @ts-expect-error Args are Partial here */} +
+
+
+

Disabled

+ {/* @ts-expect-error Args are Partial here */} +
+
+
+

HideLegend

+ {/* @ts-expect-error Args are Partial here */} +
+
+
+ ); + }, + parameters: { + chromatic: { disable: false }, + }, +}; diff --git a/@navikt/core/react/src/form/radio/radio.stories.tsx b/@navikt/core/react/src/form/radio/radio.stories.tsx index 6e18c005cd..615242d27a 100644 --- a/@navikt/core/react/src/form/radio/radio.stories.tsx +++ b/@navikt/core/react/src/form/radio/radio.stories.tsx @@ -49,6 +49,7 @@ export const Default = (props) => { ); }; + Default.args = { controlled: false, error: false, diff --git a/@navikt/core/react/src/form/switch/switch.stories.tsx b/@navikt/core/react/src/form/switch/switch.stories.tsx index 2769139011..4c3283f67b 100644 --- a/@navikt/core/react/src/form/switch/switch.stories.tsx +++ b/@navikt/core/react/src/form/switch/switch.stories.tsx @@ -1,5 +1,6 @@ -import { Meta } from "@storybook/react"; +import { Meta, StoryObj } from "@storybook/react"; import React from "react"; +import { VStack } from "../../layout/stack"; import Switch from "./Switch"; export default { @@ -31,70 +32,59 @@ export default { type: "boolean", }, }, -} as Meta; - -export const Default = { - render: (props) => { - return Label text; + parameters: { + chromatic: { disable: true }, }, +} satisfies Meta; + +type Story = StoryObj; +export const Default: Story = { args: { - position: "right", + children: "Label text", }, }; -export const Small = () => { - return ( -
- Label text - - Label text - -
- ); +export const Small: Story = { + args: { + children: "Label text", + size: "small", + }, }; -export const Description = () => { - return ( -
- - Label text - - - Label text - -
- ); +export const Description: Story = { + args: { + children: "Label text", + description: "Cillum sint exercitation ut cillum.", + }, }; -export const Loading = () => { - return ( -
+export const Loading: Story = { + render: () => { + return (
- Label text +
+ Label text - - Label text - -
-
- - Label text - - - Label text - + + Label text + +
+
+ + Label text + + + Label text + +
-
- ); + ); + }, }; -export const Disabled = () => { - return ( +export const Disabled: Story = { + render: () => (
Label text @@ -102,11 +92,11 @@ export const Disabled = () => { Label text
- ); + ), }; -export const HideLabel = () => { - return ( +export const HideLabel: Story = { + render: () => (
Label text @@ -114,11 +104,11 @@ export const HideLabel = () => { Label text
- ); + ), }; -export const Readonly = () => { - return ( +export const Readonly: Story = { + render: () => (
Notifikasjoner @@ -128,5 +118,54 @@ export const Readonly = () => { Notifikasjoner
- ); + ), +}; + +export const Chromatic: Story = { + render: () => ( + +
+

Default

+ {/* @ts-expect-error Args are Partial here */} + +
+
+

Small

+ {/* @ts-expect-error Args are Partial here */} + + {/* @ts-expect-error Args are Partial here */} + +
+
+

Description

+ {/* @ts-expect-error Args are Partial here */} + + {/* @ts-expect-error Args are Partial here */} + +
+
+

Loading

+ {/* @ts-expect-error Args are Partial here */} + +
+
+

Disabled

+ {/* @ts-expect-error Args are Partial here */} + +
+
+

HideLabel

+ {/* @ts-expect-error Args are Partial here */} + +
+
+

Readonly

+ {/* @ts-expect-error Args are Partial here */} + +
+
+ ), + parameters: { + chromatic: { disable: false }, + }, };