@navikt/ds-react 6.3.2 → 6.3.4

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,65 +1,91 @@
1
- import { Meta, StoryFn } from "@storybook/react";
2
- import React, { useState } from "react";
1
+ import { Meta, StoryObj } from "@storybook/react";
2
+ import { fn } from "@storybook/test";
3
+ import React from "react";
3
4
  import { ReadMore } from ".";
5
+ import { VStack } from "../layout/stack";
4
6
 
5
- const meta: Meta<typeof ReadMore> = {
7
+ export default {
6
8
  title: "ds-react/ReadMore",
7
9
  component: ReadMore,
8
- };
9
- export default meta;
10
+ parameters: {
11
+ chromatic: { disable: true },
12
+ },
13
+ } satisfies Meta<typeof ReadMore>;
10
14
 
11
- export const Default: StoryFn<{
12
- controlled: boolean;
13
- size: "medium" | "small";
14
- defaultOpen: boolean;
15
- }> = (props) => {
16
- const [state, setState] = useState(false);
15
+ type Story = StoryObj<typeof ReadMore>;
16
+
17
+ const Content = (
18
+ <div style={{ maxWidth: 300 }}>
19
+ Lorem ipsum dolor sit amet consectetur adipisicing elit. Mollitia, tempore
20
+ corporis exercitationem minus dignissimos eius aspernatur fugiat iusto.
21
+ </div>
22
+ );
17
23
 
18
- return (
19
- <ReadMore
20
- open={props.controlled ? state : undefined}
21
- onClick={() => setState((x) => !x)}
22
- header="Grunnen til at vi spør om dette og i tillegg ber om vedlegg"
23
- size={props.size}
24
- onOpenChange={console.log}
25
- defaultOpen={props.defaultOpen}
26
- >
27
- <div style={{ maxWidth: 300 }}>
28
- Lorem ipsum dolor sit amet consectetur adipisicing elit. Mollitia,
29
- tempore corporis exercitationem minus dignissimos eius aspernatur fugiat
30
- iusto.
31
- </div>
32
- </ReadMore>
33
- );
24
+ export const Default: Story = {
25
+ args: {
26
+ size: "medium",
27
+ defaultOpen: false,
28
+ onOpenChange: fn(),
29
+ children: Content,
30
+ header: "Grunnen til at vi spør om dette og i tillegg ber om vedlegg",
31
+ },
32
+ argTypes: {
33
+ size: {
34
+ options: ["medium", "small"],
35
+ control: { type: "radio" },
36
+ },
37
+ },
34
38
  };
35
- Default.args = {
36
- controlled: false,
37
- size: "medium",
38
- defaultOpen: false,
39
+
40
+ export const Small: Story = {
41
+ args: {
42
+ ...Default.args,
43
+ size: "small",
44
+ },
39
45
  };
40
- Default.argTypes = {
41
- size: {
42
- options: ["medium", "small"],
43
- control: { type: "radio" },
46
+
47
+ export const DefaultOpen: Story = {
48
+ args: {
49
+ ...Default.args,
50
+ defaultOpen: true,
44
51
  },
45
52
  };
46
53
 
47
- export const Small = () => (
48
- <ReadMore
49
- header="Grunnen til at vi spør om dette og i tillegg ber om vedlegg"
50
- size="small"
51
- >
52
- Command station, this is ST 321. Code Clearance Blue. We&apos;re starting
53
- our approach. Deactivate the security shield.
54
- </ReadMore>
55
- );
54
+ export const Open: Story = {
55
+ args: {
56
+ ...Default.args,
57
+ open: true,
58
+ },
59
+ };
56
60
 
57
- export const Open = () => (
58
- <ReadMore
59
- header="Grunnen til at vi spør om dette og i tillegg ber om vedlegg"
60
- defaultOpen
61
- >
62
- Command station, this is ST 321. Code Clearance Blue. We&apos;re starting
63
- our approach. Deactivate the security shield.
64
- </ReadMore>
65
- );
61
+ export const Chromatic: Story = {
62
+ render: () => {
63
+ return (
64
+ <VStack gap="4">
65
+ <div>
66
+ <h2>Default</h2>
67
+ {/* @ts-expect-error Args are partial, leading to required prop mismatch */}
68
+ <ReadMore {...Default.args} />
69
+ </div>
70
+ <div>
71
+ <h2>Small</h2>
72
+ {/* @ts-expect-error Args are partial, leading to required prop mismatch */}
73
+ <ReadMore {...Small.args} />
74
+ </div>
75
+ <div>
76
+ <h2>DefaultOpen</h2>
77
+ {/* @ts-expect-error Args are partial, leading to required prop mismatch */}
78
+ <ReadMore {...DefaultOpen.args} />
79
+ </div>
80
+ <div>
81
+ <h2>Controlled open</h2>
82
+ {/* @ts-expect-error Args are partial, leading to required prop mismatch */}
83
+ <ReadMore {...Open.args} />
84
+ </div>
85
+ </VStack>
86
+ );
87
+ },
88
+ parameters: {
89
+ chromatic: { disable: false },
90
+ },
91
+ };