@navikt/ds-react 5.2.0 → 5.3.0
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 +334 -54
- package/cjs/form/Textarea.js +1 -4
- 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/form/Textarea.js +1 -4
- package/esm/form/Textarea.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/form/Textarea.tsx +1 -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/src/typography/heading.stories.tsx +0 -77
- package/src/typography/typography.stories.tsx +0 -166
|
@@ -0,0 +1,98 @@
|
|
|
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 { Label } from "..";
|
|
6
|
+
import { VStack } from "../..";
|
|
7
|
+
|
|
8
|
+
const meta = {
|
|
9
|
+
title: "ds-react/Typography/Label",
|
|
10
|
+
component: Label,
|
|
11
|
+
decorators: [(story) => <div style={{ maxWidth: "400px" }}>{story()}</div>],
|
|
12
|
+
} satisfies Meta<typeof Label>;
|
|
13
|
+
|
|
14
|
+
export default meta;
|
|
15
|
+
|
|
16
|
+
type Story = StoryObj<typeof meta>;
|
|
17
|
+
|
|
18
|
+
const lorem =
|
|
19
|
+
"Oppgi årsaken til at du har ventet mer enn 6 måneder med å søke om refusjon";
|
|
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: ["large", "medium", "small"],
|
|
31
|
+
},
|
|
32
|
+
textColor: {
|
|
33
|
+
control: "radio",
|
|
34
|
+
options: ["default", "subtle"],
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
export const SizeMedium: Story = {
|
|
40
|
+
render: () => <Label size="medium">{lorem}</Label>,
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
export const SizeSmall: Story = {
|
|
44
|
+
render: () => <Label size="small">{lorem}</Label>,
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
export const SpacingMedium: Story = {
|
|
48
|
+
render: () => (
|
|
49
|
+
<div>
|
|
50
|
+
<Label size="medium" spacing as="p">
|
|
51
|
+
{lorem}
|
|
52
|
+
</Label>
|
|
53
|
+
<Label size="medium" spacing as="p">
|
|
54
|
+
{lorem}
|
|
55
|
+
</Label>
|
|
56
|
+
</div>
|
|
57
|
+
),
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
export const SpacingSmall: Story = {
|
|
61
|
+
render: () => (
|
|
62
|
+
<div>
|
|
63
|
+
<Label size="small" spacing as="p">
|
|
64
|
+
{lorem}
|
|
65
|
+
</Label>
|
|
66
|
+
<Label size="small" spacing as="p">
|
|
67
|
+
{lorem}
|
|
68
|
+
</Label>
|
|
69
|
+
</div>
|
|
70
|
+
),
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
export const Colors: Story = {
|
|
74
|
+
render: () => (
|
|
75
|
+
<VStack gap="2">
|
|
76
|
+
<Label textColor="default">{lorem}</Label>
|
|
77
|
+
<Label textColor="subtle">{lorem}</Label>
|
|
78
|
+
</VStack>
|
|
79
|
+
),
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
export const OverrideTag: Story = {
|
|
83
|
+
render: () => (
|
|
84
|
+
<div>
|
|
85
|
+
<Label spacing>default label</Label>
|
|
86
|
+
<Label as="legend">legend label</Label>
|
|
87
|
+
</div>
|
|
88
|
+
),
|
|
89
|
+
play: async ({ canvasElement }) => {
|
|
90
|
+
const canvas = within(canvasElement);
|
|
91
|
+
|
|
92
|
+
const defaultLabel = canvas.getByText("default label");
|
|
93
|
+
const legendLabel = canvas.getByText("legend label");
|
|
94
|
+
|
|
95
|
+
expect(defaultLabel.tagName).toEqual("LABEL");
|
|
96
|
+
expect(legendLabel.tagName).toEqual("LEGEND");
|
|
97
|
+
},
|
|
98
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export type TypoProps = {
|
|
2
|
+
/**
|
|
3
|
+
* Truncate text overflow with ellipsis.
|
|
4
|
+
*/
|
|
5
|
+
truncate?: boolean;
|
|
6
|
+
/**
|
|
7
|
+
* Adjusts font-weight.
|
|
8
|
+
*/
|
|
9
|
+
weight?: "regular" | "semibold";
|
|
10
|
+
/**
|
|
11
|
+
* Adjust text-align.
|
|
12
|
+
*/
|
|
13
|
+
align?: "start" | "center" | "end";
|
|
14
|
+
/**
|
|
15
|
+
* Visually hide text. Text will still be accessible for screenreaders
|
|
16
|
+
*/
|
|
17
|
+
visuallyHidden?: boolean;
|
|
18
|
+
/**
|
|
19
|
+
* Adds spacing below text
|
|
20
|
+
*/
|
|
21
|
+
spacing?: boolean;
|
|
22
|
+
/**
|
|
23
|
+
* Adjusts color
|
|
24
|
+
*/
|
|
25
|
+
textColor?: "default" | "subtle";
|
|
26
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import cl from "clsx";
|
|
2
|
+
import { TypoProps } from "./types";
|
|
3
|
+
|
|
4
|
+
export const typoClassNames = (props: TypoProps & { uppercase?: boolean }) => {
|
|
5
|
+
return cl({
|
|
6
|
+
"navds-typo--spacing": props.spacing,
|
|
7
|
+
"navds-typo--truncate": props.truncate,
|
|
8
|
+
"navds-typo--semibold": props.weight === "semibold",
|
|
9
|
+
[`navds-typo--align-${props.align}`]: props.align,
|
|
10
|
+
[`navds-typo--color-${props.textColor}`]: props.textColor,
|
|
11
|
+
"navds-typo--visually-hidden": props.visuallyHidden,
|
|
12
|
+
"navds-typo--uppercase": props.uppercase,
|
|
13
|
+
});
|
|
14
|
+
};
|
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
import { Meta } from "@storybook/react";
|
|
2
|
-
import React from "react";
|
|
3
|
-
import { Heading } from "..";
|
|
4
|
-
|
|
5
|
-
export default {
|
|
6
|
-
title: "ds-react/Typography/Heading",
|
|
7
|
-
component: Heading,
|
|
8
|
-
argTypes: {
|
|
9
|
-
size: {
|
|
10
|
-
defaultValue: "large",
|
|
11
|
-
control: {
|
|
12
|
-
type: "radio",
|
|
13
|
-
options: ["xlarge", "large", "medium", "small", "xsmall"],
|
|
14
|
-
},
|
|
15
|
-
},
|
|
16
|
-
level: {
|
|
17
|
-
defaultValue: "1",
|
|
18
|
-
control: {
|
|
19
|
-
type: "radio",
|
|
20
|
-
options: ["1", "2", "3", "4", "5", "6"],
|
|
21
|
-
},
|
|
22
|
-
},
|
|
23
|
-
},
|
|
24
|
-
} as Meta;
|
|
25
|
-
|
|
26
|
-
const lorem = "Veniam consequat cillum";
|
|
27
|
-
|
|
28
|
-
export const Default = {
|
|
29
|
-
render: (props) => <Heading {...props}>{lorem}</Heading>,
|
|
30
|
-
|
|
31
|
-
args: {
|
|
32
|
-
spacing: false,
|
|
33
|
-
},
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
export const Sizes = () => (
|
|
37
|
-
<div className="colgap">
|
|
38
|
-
<Heading level="1" size="xlarge">
|
|
39
|
-
{lorem}
|
|
40
|
-
</Heading>
|
|
41
|
-
<Heading level="2" size="large">
|
|
42
|
-
{lorem}
|
|
43
|
-
</Heading>
|
|
44
|
-
<Heading level="3" size="medium">
|
|
45
|
-
{lorem}
|
|
46
|
-
</Heading>
|
|
47
|
-
<Heading level="4" size="small">
|
|
48
|
-
{lorem}
|
|
49
|
-
</Heading>
|
|
50
|
-
<Heading level="5" size="xsmall">
|
|
51
|
-
{lorem}
|
|
52
|
-
</Heading>
|
|
53
|
-
</div>
|
|
54
|
-
);
|
|
55
|
-
|
|
56
|
-
export const Spacing = () => (
|
|
57
|
-
<div>
|
|
58
|
-
<Heading level="1" size="xlarge" spacing>
|
|
59
|
-
{lorem}
|
|
60
|
-
</Heading>
|
|
61
|
-
<Heading level="2" size="large" spacing>
|
|
62
|
-
{lorem}
|
|
63
|
-
</Heading>
|
|
64
|
-
<Heading level="3" size="medium" spacing>
|
|
65
|
-
{lorem}
|
|
66
|
-
</Heading>
|
|
67
|
-
<Heading level="4" size="small" spacing>
|
|
68
|
-
{lorem}
|
|
69
|
-
</Heading>
|
|
70
|
-
<Heading level="5" size="xsmall" spacing>
|
|
71
|
-
{lorem}
|
|
72
|
-
</Heading>
|
|
73
|
-
<Heading level="5" size="xsmall">
|
|
74
|
-
{lorem}
|
|
75
|
-
</Heading>
|
|
76
|
-
</div>
|
|
77
|
-
);
|
|
@@ -1,166 +0,0 @@
|
|
|
1
|
-
import { Meta } from "@storybook/react";
|
|
2
|
-
import React from "react";
|
|
3
|
-
import {
|
|
4
|
-
BodyLong as DsBodyLong,
|
|
5
|
-
BodyShort as DsBodyShort,
|
|
6
|
-
Detail as DsDetail,
|
|
7
|
-
ErrorMessage as DsErrorMessage,
|
|
8
|
-
Ingress as DsIngress,
|
|
9
|
-
Label as DsLabel,
|
|
10
|
-
} from "..";
|
|
11
|
-
|
|
12
|
-
export default {
|
|
13
|
-
title: "ds-react/Typography",
|
|
14
|
-
component: DsBodyLong,
|
|
15
|
-
subcomponents: {
|
|
16
|
-
DsBodyShort,
|
|
17
|
-
DsDetail,
|
|
18
|
-
DsErrorMessage,
|
|
19
|
-
DsIngress,
|
|
20
|
-
DsLabel,
|
|
21
|
-
},
|
|
22
|
-
} as Meta;
|
|
23
|
-
|
|
24
|
-
export const Ingress = () => (
|
|
25
|
-
<>
|
|
26
|
-
<DsIngress spacing>
|
|
27
|
-
Deserunt veniam eu fugiat ad est occaecat aliqua nisi aliquip.
|
|
28
|
-
</DsIngress>
|
|
29
|
-
<DsIngress>
|
|
30
|
-
Deserunt veniam eu fugiat ad est occaecat aliqua nisi aliquip.
|
|
31
|
-
</DsIngress>
|
|
32
|
-
</>
|
|
33
|
-
);
|
|
34
|
-
|
|
35
|
-
export const BodyLong = () => (
|
|
36
|
-
<>
|
|
37
|
-
<DsBodyLong spacing>
|
|
38
|
-
Deserunt veniam eu fugiat ad est occaecat aliqua nisi aliquip. Aute amet
|
|
39
|
-
occaecat ex aliqua irure elit labore pariatur. Proident pariatur proident
|
|
40
|
-
pariatur magna consequat velit id commodo quis sunt tempor ullamco aliquip
|
|
41
|
-
pariatur.
|
|
42
|
-
</DsBodyLong>
|
|
43
|
-
<DsBodyLong>
|
|
44
|
-
Deserunt veniam eu fugiat ad est occaecat aliqua nisi aliquip. Aute amet
|
|
45
|
-
occaecat ex aliqua irure elit labore pariatur. Proident pariatur proident
|
|
46
|
-
pariatur magna consequat velit id commodo quis sunt tempor ullamco aliquip
|
|
47
|
-
pariatur.
|
|
48
|
-
</DsBodyLong>
|
|
49
|
-
</>
|
|
50
|
-
);
|
|
51
|
-
|
|
52
|
-
export const BodyLongSmall = () => (
|
|
53
|
-
<>
|
|
54
|
-
<DsBodyLong size="small" spacing>
|
|
55
|
-
Deserunt veniam eu fugiat ad est occaecat aliqua nisi aliquip. Aute amet
|
|
56
|
-
occaecat ex aliqua irure elit labore pariatur. Proident pariatur proident
|
|
57
|
-
pariatur magna consequat velit id commodo quis sunt tempor ullamco aliquip
|
|
58
|
-
pariatur.
|
|
59
|
-
</DsBodyLong>
|
|
60
|
-
<DsBodyLong size="small">
|
|
61
|
-
Deserunt veniam eu fugiat ad est occaecat aliqua nisi aliquip. Aute amet
|
|
62
|
-
occaecat ex aliqua irure elit labore pariatur. Proident pariatur proident
|
|
63
|
-
pariatur magna consequat velit id commodo quis sunt tempor ullamco aliquip
|
|
64
|
-
pariatur.
|
|
65
|
-
</DsBodyLong>
|
|
66
|
-
</>
|
|
67
|
-
);
|
|
68
|
-
|
|
69
|
-
export const BodyShort = () => (
|
|
70
|
-
<>
|
|
71
|
-
<DsBodyShort spacing>
|
|
72
|
-
Deserunt veniam eu fugiat ad est occaecat aliqua nisi aliquip.
|
|
73
|
-
</DsBodyShort>
|
|
74
|
-
<DsBodyShort>
|
|
75
|
-
Deserunt veniam eu fugiat ad est occaecat aliqua nisi aliquip.
|
|
76
|
-
</DsBodyShort>
|
|
77
|
-
</>
|
|
78
|
-
);
|
|
79
|
-
|
|
80
|
-
export const BodyShortSmall = () => (
|
|
81
|
-
<>
|
|
82
|
-
<DsBodyShort size="small" spacing>
|
|
83
|
-
Deserunt veniam eu fugiat ad est occaecat aliqua nisi aliquip.
|
|
84
|
-
</DsBodyShort>
|
|
85
|
-
<DsBodyShort size="small">
|
|
86
|
-
Deserunt veniam eu fugiat ad est occaecat aliqua nisi aliquip.
|
|
87
|
-
</DsBodyShort>
|
|
88
|
-
</>
|
|
89
|
-
);
|
|
90
|
-
|
|
91
|
-
export const Label = () => (
|
|
92
|
-
<>
|
|
93
|
-
<DsLabel spacing>
|
|
94
|
-
Deserunt veniam eu fugiat ad est occaecat aliqua nisi aliquip.
|
|
95
|
-
</DsLabel>
|
|
96
|
-
<DsLabel>
|
|
97
|
-
Deserunt veniam eu fugiat ad est occaecat aliqua nisi aliquip.
|
|
98
|
-
</DsLabel>
|
|
99
|
-
</>
|
|
100
|
-
);
|
|
101
|
-
|
|
102
|
-
export const LabelSmall = () => (
|
|
103
|
-
<>
|
|
104
|
-
<DsLabel size="small" spacing>
|
|
105
|
-
Deserunt veniam eu fugiat ad est occaecat aliqua nisi aliquip.
|
|
106
|
-
</DsLabel>
|
|
107
|
-
<DsLabel size="small">
|
|
108
|
-
Deserunt veniam eu fugiat ad est occaecat aliqua nisi aliquip.
|
|
109
|
-
</DsLabel>
|
|
110
|
-
</>
|
|
111
|
-
);
|
|
112
|
-
|
|
113
|
-
export const Detail = () => (
|
|
114
|
-
<>
|
|
115
|
-
<DsDetail spacing>
|
|
116
|
-
Deserunt veniam eu fugiat ad est occaecat aliqua nisi aliquip.
|
|
117
|
-
</DsDetail>
|
|
118
|
-
<DsDetail>
|
|
119
|
-
Deserunt veniam eu fugiat ad est occaecat aliqua nisi aliquip.
|
|
120
|
-
</DsDetail>
|
|
121
|
-
</>
|
|
122
|
-
);
|
|
123
|
-
|
|
124
|
-
export const DetailUppercase = () => (
|
|
125
|
-
<>
|
|
126
|
-
<DsDetail spacing uppercase>
|
|
127
|
-
Deserunt veniam eu fugiat ad est occaecat aliqua nisi aliquip.
|
|
128
|
-
</DsDetail>
|
|
129
|
-
<DsDetail uppercase>
|
|
130
|
-
Deserunt veniam eu fugiat ad est occaecat aliqua nisi aliquip.
|
|
131
|
-
</DsDetail>
|
|
132
|
-
</>
|
|
133
|
-
);
|
|
134
|
-
|
|
135
|
-
export const DetailSmall = () => (
|
|
136
|
-
<>
|
|
137
|
-
<DsDetail size="small" spacing>
|
|
138
|
-
Deserunt veniam eu fugiat ad est occaecat aliqua nisi aliquip.
|
|
139
|
-
</DsDetail>
|
|
140
|
-
<DsDetail size="small">
|
|
141
|
-
Deserunt veniam eu fugiat ad est occaecat aliqua nisi aliquip.
|
|
142
|
-
</DsDetail>
|
|
143
|
-
</>
|
|
144
|
-
);
|
|
145
|
-
|
|
146
|
-
export const ErrorMessage = () => (
|
|
147
|
-
<>
|
|
148
|
-
<DsErrorMessage spacing>
|
|
149
|
-
Deserunt veniam eu fugiat ad est occaecat aliqua nisi aliquip.
|
|
150
|
-
</DsErrorMessage>
|
|
151
|
-
<DsErrorMessage>
|
|
152
|
-
Deserunt veniam eu fugiat ad est occaecat aliqua nisi aliquip.
|
|
153
|
-
</DsErrorMessage>
|
|
154
|
-
</>
|
|
155
|
-
);
|
|
156
|
-
|
|
157
|
-
export const ErrorMessageSmall = () => (
|
|
158
|
-
<>
|
|
159
|
-
<DsErrorMessage size="small" spacing>
|
|
160
|
-
Deserunt veniam eu fugiat ad est occaecat aliqua nisi aliquip.
|
|
161
|
-
</DsErrorMessage>
|
|
162
|
-
<DsErrorMessage size="small">
|
|
163
|
-
Deserunt veniam eu fugiat ad est occaecat aliqua nisi aliquip.
|
|
164
|
-
</DsErrorMessage>
|
|
165
|
-
</>
|
|
166
|
-
);
|