@navikt/ds-react 5.2.1 → 5.3.1
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.
- package/_docs.json +336 -140
- package/cjs/date/DateInput.js +1 -1
- package/cjs/date/monthpicker/MonthButton.js +5 -5
- package/cjs/form/Textarea.js +1 -4
- package/cjs/guide-panel/GuidePanel.js +7 -5
- package/cjs/guide-panel/Illustration.js +12 -16
- package/cjs/typography/BodyLong.js +14 -7
- package/cjs/typography/BodyShort.js +13 -8
- package/cjs/typography/Detail.js +14 -7
- package/cjs/typography/ErrorMessage.js +6 -4
- package/cjs/typography/Heading.js +10 -6
- package/cjs/typography/Ingress.js +4 -2
- package/cjs/typography/Label.js +10 -6
- package/cjs/typography/types.js +2 -0
- package/cjs/typography/util.js +19 -0
- package/esm/date/DateInput.js +1 -1
- package/esm/date/DateInput.js.map +1 -1
- package/esm/date/monthpicker/MonthButton.js +5 -5
- package/esm/date/monthpicker/MonthButton.js.map +1 -1
- package/esm/form/Textarea.js +1 -4
- package/esm/form/Textarea.js.map +1 -1
- package/esm/guide-panel/GuidePanel.d.ts +3 -3
- package/esm/guide-panel/GuidePanel.js +7 -5
- package/esm/guide-panel/GuidePanel.js.map +1 -1
- package/esm/guide-panel/Illustration.js +12 -16
- package/esm/guide-panel/Illustration.js.map +1 -1
- package/esm/guide-panel/index.d.ts +0 -1
- package/esm/guide-panel/index.js.map +1 -1
- package/esm/typography/BodyLong.d.ts +9 -10
- package/esm/typography/BodyLong.js +14 -7
- package/esm/typography/BodyLong.js.map +1 -1
- package/esm/typography/BodyShort.d.ts +6 -9
- package/esm/typography/BodyShort.js +13 -8
- package/esm/typography/BodyShort.js.map +1 -1
- package/esm/typography/Detail.d.ts +4 -7
- package/esm/typography/Detail.js +14 -7
- package/esm/typography/Detail.js.map +1 -1
- package/esm/typography/ErrorMessage.d.ts +4 -7
- package/esm/typography/ErrorMessage.js +6 -4
- package/esm/typography/ErrorMessage.js.map +1 -1
- package/esm/typography/Heading.d.ts +3 -7
- package/esm/typography/Heading.js +10 -6
- package/esm/typography/Heading.js.map +1 -1
- package/esm/typography/Ingress.d.ts +4 -2
- package/esm/typography/Ingress.js +4 -2
- package/esm/typography/Ingress.js.map +1 -1
- package/esm/typography/Label.d.ts +4 -7
- package/esm/typography/Label.js +10 -6
- package/esm/typography/Label.js.map +1 -1
- package/esm/typography/types.d.ts +26 -0
- package/esm/typography/types.js +2 -0
- package/esm/typography/types.js.map +1 -0
- package/esm/typography/util.d.ts +4 -0
- package/esm/typography/util.js +13 -0
- package/esm/typography/util.js.map +1 -0
- package/package.json +2 -2
- package/src/date/DateInput.tsx +1 -1
- package/src/date/datepicker/datepicker.stories.tsx +23 -19
- package/src/date/monthpicker/MonthButton.tsx +5 -7
- package/src/date/monthpicker/monthpicker.stories.tsx +30 -32
- package/src/form/Textarea.tsx +1 -1
- package/src/guide-panel/GuidePanel.tsx +11 -10
- package/src/guide-panel/Illustration.tsx +23 -47
- package/src/guide-panel/guidepanel.stories.tsx +39 -14
- package/src/guide-panel/index.ts +0 -1
- package/src/typography/BodyLong.tsx +36 -15
- package/src/typography/BodyShort.tsx +34 -15
- package/src/typography/Detail.tsx +28 -13
- package/src/typography/ErrorMessage.tsx +17 -11
- package/src/typography/Heading.tsx +32 -12
- package/src/typography/Ingress.tsx +4 -2
- package/src/typography/Label.tsx +28 -13
- package/src/typography/stories/bodylong.stories.tsx +165 -0
- package/src/typography/stories/bodyshort.stories.tsx +164 -0
- package/src/typography/stories/detail.stories.tsx +88 -0
- package/src/typography/stories/error-message.stories.tsx +93 -0
- package/src/typography/stories/heading.stories.tsx +143 -0
- package/src/typography/stories/ingress.stories.tsx +51 -0
- package/src/typography/stories/label.stories.tsx +98 -0
- package/src/typography/types.ts +26 -0
- package/src/typography/util.ts +14 -0
- package/cjs/guide-panel/Guide.js +0 -48
- package/esm/guide-panel/Guide.d.ts +0 -14
- package/esm/guide-panel/Guide.js +0 -21
- package/esm/guide-panel/Guide.js.map +0 -1
- package/src/guide-panel/Guide.tsx +0 -34
- package/src/typography/heading.stories.tsx +0 -77
- package/src/typography/typography.stories.tsx +0 -166
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
import { expect } from "@storybook/jest";
|
|
2
|
+
import type { Meta, StoryObj } from "@storybook/react";
|
|
3
|
+
import { within } from "@storybook/testing-library";
|
|
4
|
+
import React from "react";
|
|
5
|
+
import { BodyLong } from "..";
|
|
6
|
+
import { VStack } from "../..";
|
|
7
|
+
|
|
8
|
+
const meta = {
|
|
9
|
+
title: "ds-react/Typography/BodyLong",
|
|
10
|
+
component: BodyLong,
|
|
11
|
+
decorators: [(story) => <div style={{ maxWidth: "700px" }}>{story()}</div>],
|
|
12
|
+
} satisfies Meta<typeof BodyLong>;
|
|
13
|
+
|
|
14
|
+
export default meta;
|
|
15
|
+
|
|
16
|
+
type Story = StoryObj<typeof meta>;
|
|
17
|
+
|
|
18
|
+
const lorem =
|
|
19
|
+
"Hvis du ikke bor sammen med begge foreldrene dine, kan du ha rett til barnebidrag fra en eller begge foreldre mens du fullfører videregående skole eller tilsvarende.";
|
|
20
|
+
|
|
21
|
+
export const Default: Story = {
|
|
22
|
+
args: {
|
|
23
|
+
spacing: false,
|
|
24
|
+
children: lorem,
|
|
25
|
+
|
|
26
|
+
truncate: false,
|
|
27
|
+
visuallyHidden: false,
|
|
28
|
+
},
|
|
29
|
+
argTypes: {
|
|
30
|
+
size: {
|
|
31
|
+
control: "radio",
|
|
32
|
+
options: ["large", "medium", "small"],
|
|
33
|
+
},
|
|
34
|
+
weight: {
|
|
35
|
+
control: "radio",
|
|
36
|
+
options: ["regular", "semibold"],
|
|
37
|
+
},
|
|
38
|
+
align: {
|
|
39
|
+
control: "radio",
|
|
40
|
+
options: ["start", "center", "end"],
|
|
41
|
+
},
|
|
42
|
+
textColor: {
|
|
43
|
+
control: "radio",
|
|
44
|
+
options: ["default", "subtle"],
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
export const SizeLarge: Story = {
|
|
50
|
+
render: () => (
|
|
51
|
+
<VStack gap="4">
|
|
52
|
+
<BodyLong size="large">{lorem}</BodyLong>
|
|
53
|
+
<BodyLong size="large" weight="semibold">
|
|
54
|
+
{lorem}
|
|
55
|
+
</BodyLong>
|
|
56
|
+
<BodyLong size="large" truncate>
|
|
57
|
+
{lorem}
|
|
58
|
+
</BodyLong>
|
|
59
|
+
</VStack>
|
|
60
|
+
),
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
export const SizeMedium: Story = {
|
|
64
|
+
render: () => (
|
|
65
|
+
<VStack gap="2">
|
|
66
|
+
<BodyLong size="medium">{lorem}</BodyLong>
|
|
67
|
+
<BodyLong size="medium" weight="semibold">
|
|
68
|
+
{lorem}
|
|
69
|
+
</BodyLong>
|
|
70
|
+
<BodyLong size="medium" truncate>
|
|
71
|
+
{lorem}
|
|
72
|
+
</BodyLong>
|
|
73
|
+
</VStack>
|
|
74
|
+
),
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
export const SizeSmall: Story = {
|
|
78
|
+
render: () => (
|
|
79
|
+
<VStack gap="2">
|
|
80
|
+
<BodyLong size="small">{lorem}</BodyLong>
|
|
81
|
+
<BodyLong size="small" weight="semibold">
|
|
82
|
+
{lorem}
|
|
83
|
+
</BodyLong>
|
|
84
|
+
<BodyLong size="small" truncate>
|
|
85
|
+
{lorem}
|
|
86
|
+
</BodyLong>
|
|
87
|
+
</VStack>
|
|
88
|
+
),
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
export const SpacingLarge: Story = {
|
|
92
|
+
render: () => (
|
|
93
|
+
<div>
|
|
94
|
+
<BodyLong size="large" spacing>
|
|
95
|
+
{lorem}
|
|
96
|
+
</BodyLong>
|
|
97
|
+
<BodyLong size="large" spacing>
|
|
98
|
+
{lorem}
|
|
99
|
+
</BodyLong>
|
|
100
|
+
</div>
|
|
101
|
+
),
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
export const SpacingMedium: Story = {
|
|
105
|
+
render: () => (
|
|
106
|
+
<div>
|
|
107
|
+
<BodyLong size="medium" spacing>
|
|
108
|
+
{lorem}
|
|
109
|
+
</BodyLong>
|
|
110
|
+
<BodyLong size="medium" spacing>
|
|
111
|
+
{lorem}
|
|
112
|
+
</BodyLong>
|
|
113
|
+
</div>
|
|
114
|
+
),
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
export const SpacingSmall: Story = {
|
|
118
|
+
render: () => (
|
|
119
|
+
<div>
|
|
120
|
+
<BodyLong size="small" spacing>
|
|
121
|
+
{lorem}
|
|
122
|
+
</BodyLong>
|
|
123
|
+
<BodyLong size="small" spacing>
|
|
124
|
+
{lorem}
|
|
125
|
+
</BodyLong>
|
|
126
|
+
</div>
|
|
127
|
+
),
|
|
128
|
+
};
|
|
129
|
+
|
|
130
|
+
export const Colors: Story = {
|
|
131
|
+
render: () => (
|
|
132
|
+
<VStack gap="2">
|
|
133
|
+
<BodyLong textColor="default">{lorem}</BodyLong>
|
|
134
|
+
<BodyLong textColor="subtle">{lorem}</BodyLong>
|
|
135
|
+
</VStack>
|
|
136
|
+
),
|
|
137
|
+
};
|
|
138
|
+
|
|
139
|
+
export const Align: Story = {
|
|
140
|
+
render: () => (
|
|
141
|
+
<VStack gap="2">
|
|
142
|
+
<BodyLong align="start">{lorem}</BodyLong>
|
|
143
|
+
<BodyLong align="center">{lorem}</BodyLong>
|
|
144
|
+
<BodyLong align="end">{lorem}</BodyLong>
|
|
145
|
+
</VStack>
|
|
146
|
+
),
|
|
147
|
+
};
|
|
148
|
+
|
|
149
|
+
export const OverrideTag: Story = {
|
|
150
|
+
render: () => (
|
|
151
|
+
<div>
|
|
152
|
+
<BodyLong spacing>default bodylong</BodyLong>
|
|
153
|
+
<BodyLong as="legend">legend bodylong</BodyLong>
|
|
154
|
+
</div>
|
|
155
|
+
),
|
|
156
|
+
play: async ({ canvasElement }) => {
|
|
157
|
+
const canvas = within(canvasElement);
|
|
158
|
+
|
|
159
|
+
const defaultBodyLong = canvas.getByText("default bodylong");
|
|
160
|
+
const legendBodyLong = canvas.getByText("legend bodylong");
|
|
161
|
+
|
|
162
|
+
expect(defaultBodyLong.tagName).toEqual("P");
|
|
163
|
+
expect(legendBodyLong.tagName).toEqual("LEGEND");
|
|
164
|
+
},
|
|
165
|
+
};
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
import { expect } from "@storybook/jest";
|
|
2
|
+
import type { Meta, StoryObj } from "@storybook/react";
|
|
3
|
+
import { within } from "@storybook/testing-library";
|
|
4
|
+
import React from "react";
|
|
5
|
+
import { BodyShort } from "..";
|
|
6
|
+
import { VStack } from "../..";
|
|
7
|
+
|
|
8
|
+
const meta = {
|
|
9
|
+
title: "ds-react/Typography/BodyShort",
|
|
10
|
+
component: BodyShort,
|
|
11
|
+
decorators: [(story) => <div style={{ maxWidth: "200px" }}>{story()}</div>],
|
|
12
|
+
} satisfies Meta<typeof BodyShort>;
|
|
13
|
+
|
|
14
|
+
export default meta;
|
|
15
|
+
|
|
16
|
+
type Story = StoryObj<typeof meta>;
|
|
17
|
+
|
|
18
|
+
const lorem = "Du må gjøre en filtrering for å se brukere i listen.";
|
|
19
|
+
|
|
20
|
+
export const Default: Story = {
|
|
21
|
+
args: {
|
|
22
|
+
spacing: false,
|
|
23
|
+
children: lorem,
|
|
24
|
+
|
|
25
|
+
truncate: false,
|
|
26
|
+
visuallyHidden: false,
|
|
27
|
+
},
|
|
28
|
+
argTypes: {
|
|
29
|
+
size: {
|
|
30
|
+
control: "radio",
|
|
31
|
+
options: ["large", "medium", "small"],
|
|
32
|
+
},
|
|
33
|
+
weight: {
|
|
34
|
+
control: "radio",
|
|
35
|
+
options: ["regular", "semibold"],
|
|
36
|
+
},
|
|
37
|
+
align: {
|
|
38
|
+
control: "radio",
|
|
39
|
+
options: ["start", "center", "end"],
|
|
40
|
+
},
|
|
41
|
+
textColor: {
|
|
42
|
+
control: "radio",
|
|
43
|
+
options: ["default", "subtle"],
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
export const SizeLarge: Story = {
|
|
49
|
+
render: () => (
|
|
50
|
+
<VStack gap="2">
|
|
51
|
+
<BodyShort size="large">{lorem}</BodyShort>
|
|
52
|
+
<BodyShort size="large" weight="semibold">
|
|
53
|
+
{lorem}
|
|
54
|
+
</BodyShort>
|
|
55
|
+
<BodyShort size="large" truncate>
|
|
56
|
+
{lorem}
|
|
57
|
+
</BodyShort>
|
|
58
|
+
</VStack>
|
|
59
|
+
),
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
export const SizeMedium: Story = {
|
|
63
|
+
render: () => (
|
|
64
|
+
<VStack gap="2">
|
|
65
|
+
<BodyShort size="medium">{lorem}</BodyShort>
|
|
66
|
+
<BodyShort size="medium" weight="semibold">
|
|
67
|
+
{lorem}
|
|
68
|
+
</BodyShort>
|
|
69
|
+
<BodyShort size="medium" truncate>
|
|
70
|
+
{lorem}
|
|
71
|
+
</BodyShort>
|
|
72
|
+
</VStack>
|
|
73
|
+
),
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
export const SizeSmall: Story = {
|
|
77
|
+
render: () => (
|
|
78
|
+
<VStack gap="2">
|
|
79
|
+
<BodyShort size="small">{lorem}</BodyShort>
|
|
80
|
+
<BodyShort size="small" weight="semibold">
|
|
81
|
+
{lorem}
|
|
82
|
+
</BodyShort>
|
|
83
|
+
<BodyShort size="small" truncate>
|
|
84
|
+
{lorem}
|
|
85
|
+
</BodyShort>
|
|
86
|
+
</VStack>
|
|
87
|
+
),
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
export const SpacingLarge: Story = {
|
|
91
|
+
render: () => (
|
|
92
|
+
<div>
|
|
93
|
+
<BodyShort size="large" spacing>
|
|
94
|
+
{lorem}
|
|
95
|
+
</BodyShort>
|
|
96
|
+
<BodyShort size="large" spacing>
|
|
97
|
+
{lorem}
|
|
98
|
+
</BodyShort>
|
|
99
|
+
</div>
|
|
100
|
+
),
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
export const SpacingMedium: Story = {
|
|
104
|
+
render: () => (
|
|
105
|
+
<div>
|
|
106
|
+
<BodyShort size="medium" spacing>
|
|
107
|
+
{lorem}
|
|
108
|
+
</BodyShort>
|
|
109
|
+
<BodyShort size="medium" spacing>
|
|
110
|
+
{lorem}
|
|
111
|
+
</BodyShort>
|
|
112
|
+
</div>
|
|
113
|
+
),
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
export const SpacingSmall: Story = {
|
|
117
|
+
render: () => (
|
|
118
|
+
<div>
|
|
119
|
+
<BodyShort size="small" spacing>
|
|
120
|
+
{lorem}
|
|
121
|
+
</BodyShort>
|
|
122
|
+
<BodyShort size="small" spacing>
|
|
123
|
+
{lorem}
|
|
124
|
+
</BodyShort>
|
|
125
|
+
</div>
|
|
126
|
+
),
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
export const Colors: Story = {
|
|
130
|
+
render: () => (
|
|
131
|
+
<VStack gap="2">
|
|
132
|
+
<BodyShort textColor="default">{lorem}</BodyShort>
|
|
133
|
+
<BodyShort textColor="subtle">{lorem}</BodyShort>
|
|
134
|
+
</VStack>
|
|
135
|
+
),
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
export const Align: Story = {
|
|
139
|
+
render: () => (
|
|
140
|
+
<VStack gap="2">
|
|
141
|
+
<BodyShort align="start">{lorem}</BodyShort>
|
|
142
|
+
<BodyShort align="center">{lorem}</BodyShort>
|
|
143
|
+
<BodyShort align="end">{lorem}</BodyShort>
|
|
144
|
+
</VStack>
|
|
145
|
+
),
|
|
146
|
+
};
|
|
147
|
+
|
|
148
|
+
export const OverrideTag: Story = {
|
|
149
|
+
render: () => (
|
|
150
|
+
<div>
|
|
151
|
+
<BodyShort spacing>default bodyshort</BodyShort>
|
|
152
|
+
<BodyShort as="legend">legend bodyshort</BodyShort>
|
|
153
|
+
</div>
|
|
154
|
+
),
|
|
155
|
+
play: async ({ canvasElement }) => {
|
|
156
|
+
const canvas = within(canvasElement);
|
|
157
|
+
|
|
158
|
+
const defaultBodyShort = canvas.getByText("default bodyshort");
|
|
159
|
+
const legendBodyShort = canvas.getByText("legend bodyshort");
|
|
160
|
+
|
|
161
|
+
expect(defaultBodyShort.tagName).toEqual("P");
|
|
162
|
+
expect(legendBodyShort.tagName).toEqual("LEGEND");
|
|
163
|
+
},
|
|
164
|
+
};
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { expect } from "@storybook/jest";
|
|
2
|
+
import type { Meta, StoryObj } from "@storybook/react";
|
|
3
|
+
import { within } from "@storybook/testing-library";
|
|
4
|
+
import React from "react";
|
|
5
|
+
import { Detail } from "..";
|
|
6
|
+
import { VStack } from "../..";
|
|
7
|
+
|
|
8
|
+
const meta = {
|
|
9
|
+
title: "ds-react/Typography/Detail",
|
|
10
|
+
component: Detail,
|
|
11
|
+
decorators: [(story) => <div style={{ maxWidth: "200px" }}>{story()}</div>],
|
|
12
|
+
} satisfies Meta<typeof Detail>;
|
|
13
|
+
|
|
14
|
+
export default meta;
|
|
15
|
+
|
|
16
|
+
type Story = StoryObj<typeof meta>;
|
|
17
|
+
|
|
18
|
+
const lorem = "Du må gjøre en filtrering for å se brukere i listen.";
|
|
19
|
+
|
|
20
|
+
export const Default: Story = {
|
|
21
|
+
args: {
|
|
22
|
+
spacing: false,
|
|
23
|
+
children: lorem,
|
|
24
|
+
|
|
25
|
+
truncate: false,
|
|
26
|
+
visuallyHidden: false,
|
|
27
|
+
},
|
|
28
|
+
argTypes: {
|
|
29
|
+
weight: {
|
|
30
|
+
control: "radio",
|
|
31
|
+
options: ["regular", "semibold"],
|
|
32
|
+
},
|
|
33
|
+
align: {
|
|
34
|
+
control: "radio",
|
|
35
|
+
options: ["start", "center", "end"],
|
|
36
|
+
},
|
|
37
|
+
textColor: {
|
|
38
|
+
control: "radio",
|
|
39
|
+
options: ["default", "subtle"],
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
export const Spacing: Story = {
|
|
45
|
+
render: () => (
|
|
46
|
+
<div>
|
|
47
|
+
<Detail spacing>{lorem}</Detail>
|
|
48
|
+
<Detail spacing>{lorem}</Detail>
|
|
49
|
+
</div>
|
|
50
|
+
),
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
export const Colors: Story = {
|
|
54
|
+
render: () => (
|
|
55
|
+
<VStack gap="2">
|
|
56
|
+
<Detail textColor="default">{lorem}</Detail>
|
|
57
|
+
<Detail textColor="subtle">{lorem}</Detail>
|
|
58
|
+
</VStack>
|
|
59
|
+
),
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
export const Align: Story = {
|
|
63
|
+
render: () => (
|
|
64
|
+
<VStack gap="2">
|
|
65
|
+
<Detail align="start">{lorem}</Detail>
|
|
66
|
+
<Detail align="center">{lorem}</Detail>
|
|
67
|
+
<Detail align="end">{lorem}</Detail>
|
|
68
|
+
</VStack>
|
|
69
|
+
),
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
export const OverrideTag: Story = {
|
|
73
|
+
render: () => (
|
|
74
|
+
<div>
|
|
75
|
+
<Detail spacing>default detail</Detail>
|
|
76
|
+
<Detail as="legend">legend detail</Detail>
|
|
77
|
+
</div>
|
|
78
|
+
),
|
|
79
|
+
play: async ({ canvasElement }) => {
|
|
80
|
+
const canvas = within(canvasElement);
|
|
81
|
+
|
|
82
|
+
const defaultDetail = canvas.getByText("default detail");
|
|
83
|
+
const legendDetail = canvas.getByText("legend detail");
|
|
84
|
+
|
|
85
|
+
expect(defaultDetail.tagName).toEqual("P");
|
|
86
|
+
expect(legendDetail.tagName).toEqual("LEGEND");
|
|
87
|
+
},
|
|
88
|
+
};
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { expect } from "@storybook/jest";
|
|
2
|
+
import type { Meta, StoryObj } from "@storybook/react";
|
|
3
|
+
import { within } from "@storybook/testing-library";
|
|
4
|
+
import React from "react";
|
|
5
|
+
import { ErrorMessage } from "..";
|
|
6
|
+
import { VStack } from "../..";
|
|
7
|
+
|
|
8
|
+
const meta = {
|
|
9
|
+
title: "ds-react/Typography/ErrorMessage",
|
|
10
|
+
component: ErrorMessage,
|
|
11
|
+
} satisfies Meta<typeof ErrorMessage>;
|
|
12
|
+
|
|
13
|
+
export default meta;
|
|
14
|
+
|
|
15
|
+
type Story = StoryObj<typeof meta>;
|
|
16
|
+
|
|
17
|
+
const lorem =
|
|
18
|
+
"Du må fylle ut: Oppgi årsaken til at du har ventet mer enn 6 måneder med å søke om refusjon";
|
|
19
|
+
|
|
20
|
+
export const Default: Story = {
|
|
21
|
+
args: {
|
|
22
|
+
spacing: false,
|
|
23
|
+
children: lorem,
|
|
24
|
+
},
|
|
25
|
+
argTypes: {
|
|
26
|
+
size: {
|
|
27
|
+
control: "radio",
|
|
28
|
+
options: ["medium", "small"],
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
export const SizeMedium: Story = {
|
|
34
|
+
render: () => (
|
|
35
|
+
<VStack gap="2">
|
|
36
|
+
<ErrorMessage size="medium">{lorem}</ErrorMessage>
|
|
37
|
+
<ErrorMessage size="medium">{lorem}</ErrorMessage>
|
|
38
|
+
</VStack>
|
|
39
|
+
),
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
export const SizeSmall: Story = {
|
|
43
|
+
render: () => (
|
|
44
|
+
<VStack gap="2">
|
|
45
|
+
<ErrorMessage size="small">{lorem}</ErrorMessage>
|
|
46
|
+
<ErrorMessage size="small">{lorem}</ErrorMessage>
|
|
47
|
+
</VStack>
|
|
48
|
+
),
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
export const SpacingMedium: Story = {
|
|
52
|
+
render: () => (
|
|
53
|
+
<div>
|
|
54
|
+
<ErrorMessage size="medium" spacing>
|
|
55
|
+
{lorem}
|
|
56
|
+
</ErrorMessage>
|
|
57
|
+
<ErrorMessage size="medium" spacing>
|
|
58
|
+
{lorem}
|
|
59
|
+
</ErrorMessage>
|
|
60
|
+
</div>
|
|
61
|
+
),
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
export const SpacingSmall: Story = {
|
|
65
|
+
render: () => (
|
|
66
|
+
<div>
|
|
67
|
+
<ErrorMessage size="small" spacing>
|
|
68
|
+
{lorem}
|
|
69
|
+
</ErrorMessage>
|
|
70
|
+
<ErrorMessage size="small" spacing>
|
|
71
|
+
{lorem}
|
|
72
|
+
</ErrorMessage>
|
|
73
|
+
</div>
|
|
74
|
+
),
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
export const OverrideTag: Story = {
|
|
78
|
+
render: () => (
|
|
79
|
+
<div>
|
|
80
|
+
<ErrorMessage spacing>default errormessage</ErrorMessage>
|
|
81
|
+
<ErrorMessage as="legend">legend errormessage</ErrorMessage>
|
|
82
|
+
</div>
|
|
83
|
+
),
|
|
84
|
+
play: async ({ canvasElement }) => {
|
|
85
|
+
const canvas = within(canvasElement);
|
|
86
|
+
|
|
87
|
+
const defaultErrorMessage = canvas.getByText("default errormessage");
|
|
88
|
+
const legendErrorMessage = canvas.getByText("legend errormessage");
|
|
89
|
+
|
|
90
|
+
expect(defaultErrorMessage.tagName).toEqual("P");
|
|
91
|
+
expect(legendErrorMessage.tagName).toEqual("LEGEND");
|
|
92
|
+
},
|
|
93
|
+
};
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from "@storybook/react";
|
|
2
|
+
|
|
3
|
+
import { expect } from "@storybook/jest";
|
|
4
|
+
import { within } from "@storybook/testing-library";
|
|
5
|
+
import { default as React } from "react";
|
|
6
|
+
import { Heading } from "..";
|
|
7
|
+
import { VStack } from "../..";
|
|
8
|
+
|
|
9
|
+
const meta = {
|
|
10
|
+
title: "ds-react/Typography/Heading",
|
|
11
|
+
component: Heading,
|
|
12
|
+
decorators: [(story) => <div style={{ maxWidth: "300px" }}>{story()}</div>],
|
|
13
|
+
} satisfies Meta<typeof Heading>;
|
|
14
|
+
|
|
15
|
+
export default meta;
|
|
16
|
+
|
|
17
|
+
type Story = StoryObj<typeof meta>;
|
|
18
|
+
|
|
19
|
+
const lorem = "Hva kan vi hjelpe deg med?";
|
|
20
|
+
|
|
21
|
+
export const Default: Story = {
|
|
22
|
+
args: {
|
|
23
|
+
spacing: false,
|
|
24
|
+
children: lorem,
|
|
25
|
+
visuallyHidden: false,
|
|
26
|
+
},
|
|
27
|
+
argTypes: {
|
|
28
|
+
size: {
|
|
29
|
+
control: "radio",
|
|
30
|
+
options: ["xlarge", "large", "medium", "small", "xsmall"],
|
|
31
|
+
},
|
|
32
|
+
level: {
|
|
33
|
+
control: "radio",
|
|
34
|
+
options: ["1", "2", "3", "4", "5", "6"],
|
|
35
|
+
},
|
|
36
|
+
align: {
|
|
37
|
+
control: "radio",
|
|
38
|
+
options: ["start", "center", "end"],
|
|
39
|
+
},
|
|
40
|
+
textColor: {
|
|
41
|
+
control: "radio",
|
|
42
|
+
options: ["default", "subtle"],
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
export const Sizes: Story = {
|
|
48
|
+
render: () => (
|
|
49
|
+
<VStack gap="4">
|
|
50
|
+
<Heading level="1" size="xlarge">
|
|
51
|
+
{lorem}
|
|
52
|
+
</Heading>
|
|
53
|
+
<Heading level="2" size="large">
|
|
54
|
+
{lorem}
|
|
55
|
+
</Heading>
|
|
56
|
+
<Heading level="3" size="medium">
|
|
57
|
+
{lorem}
|
|
58
|
+
</Heading>
|
|
59
|
+
<Heading level="4" size="small">
|
|
60
|
+
{lorem}
|
|
61
|
+
</Heading>
|
|
62
|
+
<Heading level="5" size="xsmall">
|
|
63
|
+
{lorem}
|
|
64
|
+
</Heading>
|
|
65
|
+
</VStack>
|
|
66
|
+
),
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
export const Spacing: Story = {
|
|
70
|
+
render: () => (
|
|
71
|
+
<div>
|
|
72
|
+
<Heading level="1" size="xlarge" spacing>
|
|
73
|
+
{lorem}
|
|
74
|
+
</Heading>
|
|
75
|
+
<Heading level="2" size="large" spacing>
|
|
76
|
+
{lorem}
|
|
77
|
+
</Heading>
|
|
78
|
+
<Heading level="3" size="medium" spacing>
|
|
79
|
+
{lorem}
|
|
80
|
+
</Heading>
|
|
81
|
+
<Heading level="4" size="small" spacing>
|
|
82
|
+
{lorem}
|
|
83
|
+
</Heading>
|
|
84
|
+
<Heading level="5" size="xsmall" spacing>
|
|
85
|
+
{lorem}
|
|
86
|
+
</Heading>
|
|
87
|
+
<Heading level="5" size="xsmall">
|
|
88
|
+
{lorem}
|
|
89
|
+
</Heading>
|
|
90
|
+
</div>
|
|
91
|
+
),
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
export const Colors: Story = {
|
|
95
|
+
render: () => (
|
|
96
|
+
<VStack gap="2">
|
|
97
|
+
<Heading level="1" size="large" textColor="default">
|
|
98
|
+
{lorem}
|
|
99
|
+
</Heading>
|
|
100
|
+
<Heading level="2" size="large" textColor="subtle">
|
|
101
|
+
{lorem}
|
|
102
|
+
</Heading>
|
|
103
|
+
</VStack>
|
|
104
|
+
),
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
export const Align: Story = {
|
|
108
|
+
render: () => (
|
|
109
|
+
<VStack gap="2">
|
|
110
|
+
<Heading level="1" size="large" align="start">
|
|
111
|
+
{lorem}
|
|
112
|
+
</Heading>
|
|
113
|
+
<Heading level="2" size="large" align="center">
|
|
114
|
+
{lorem}
|
|
115
|
+
</Heading>
|
|
116
|
+
<Heading level="3" size="large" align="end">
|
|
117
|
+
{lorem}
|
|
118
|
+
</Heading>
|
|
119
|
+
</VStack>
|
|
120
|
+
),
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
export const OverrideTag: Story = {
|
|
124
|
+
render: () => (
|
|
125
|
+
<div>
|
|
126
|
+
<Heading spacing level="1" size="large">
|
|
127
|
+
default heading
|
|
128
|
+
</Heading>
|
|
129
|
+
<Heading as="legend" size="large">
|
|
130
|
+
legend heading
|
|
131
|
+
</Heading>
|
|
132
|
+
</div>
|
|
133
|
+
),
|
|
134
|
+
play: async ({ canvasElement }) => {
|
|
135
|
+
const canvas = within(canvasElement);
|
|
136
|
+
|
|
137
|
+
const defaultHeading = canvas.getByText("default heading");
|
|
138
|
+
const legendHeading = canvas.getByText("legend heading");
|
|
139
|
+
|
|
140
|
+
expect(defaultHeading.tagName).toEqual("H1");
|
|
141
|
+
expect(legendHeading.tagName).toEqual("LEGEND");
|
|
142
|
+
},
|
|
143
|
+
};
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { expect } from "@storybook/jest";
|
|
2
|
+
import type { Meta, StoryObj } from "@storybook/react";
|
|
3
|
+
import { within } from "@storybook/testing-library";
|
|
4
|
+
import React from "react";
|
|
5
|
+
import { Ingress } from "..";
|
|
6
|
+
|
|
7
|
+
const meta = {
|
|
8
|
+
title: "ds-react/Typography/deprecated/Ingress",
|
|
9
|
+
component: Ingress,
|
|
10
|
+
} satisfies Meta<typeof Ingress>;
|
|
11
|
+
|
|
12
|
+
export default meta;
|
|
13
|
+
|
|
14
|
+
type Story = StoryObj<typeof meta>;
|
|
15
|
+
|
|
16
|
+
const lorem =
|
|
17
|
+
"Hvis du ikke bor sammen med begge foreldrene dine, kan du ha rett til barnebidrag fra en eller begge foreldre mens du fullfører videregående skole eller tilsvarende.";
|
|
18
|
+
|
|
19
|
+
export const Default: Story = {
|
|
20
|
+
args: {
|
|
21
|
+
spacing: false,
|
|
22
|
+
children: lorem,
|
|
23
|
+
},
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export const Spacing: Story = {
|
|
27
|
+
render: () => (
|
|
28
|
+
<div>
|
|
29
|
+
<Ingress spacing>{lorem}</Ingress>
|
|
30
|
+
<Ingress spacing>{lorem}</Ingress>
|
|
31
|
+
</div>
|
|
32
|
+
),
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
export const OverrideTag: Story = {
|
|
36
|
+
render: () => (
|
|
37
|
+
<div>
|
|
38
|
+
<Ingress spacing>default ingress</Ingress>
|
|
39
|
+
<Ingress as="legend">legend ingress</Ingress>
|
|
40
|
+
</div>
|
|
41
|
+
),
|
|
42
|
+
play: async ({ canvasElement }) => {
|
|
43
|
+
const canvas = within(canvasElement);
|
|
44
|
+
|
|
45
|
+
const defaultIngress = canvas.getByText("default ingress");
|
|
46
|
+
const legendIngress = canvas.getByText("legend ingress");
|
|
47
|
+
|
|
48
|
+
expect(defaultIngress.tagName).toEqual("P");
|
|
49
|
+
expect(legendIngress.tagName).toEqual("LEGEND");
|
|
50
|
+
},
|
|
51
|
+
};
|