@navikt/ds-react 5.2.1 → 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
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { OverridableComponent } from "../util/OverridableComponent";
|
|
3
|
-
|
|
3
|
+
import { TypoProps } from "./types";
|
|
4
|
+
export interface LabelProps extends Omit<TypoProps, "weight" | "align" | "truncate">, React.LabelHTMLAttributes<HTMLLabelElement> {
|
|
4
5
|
/**
|
|
5
6
|
* medium: 18px, small: 16px
|
|
6
7
|
* @default "medium"
|
|
@@ -10,10 +11,6 @@ export interface LabelProps extends React.LabelHTMLAttributes<HTMLLabelElement>
|
|
|
10
11
|
* Paragraph text
|
|
11
12
|
*/
|
|
12
13
|
children: React.ReactNode;
|
|
13
|
-
/**
|
|
14
|
-
* Adds margin-bottom
|
|
15
|
-
*/
|
|
16
|
-
spacing?: boolean;
|
|
17
14
|
}
|
|
18
15
|
/**
|
|
19
16
|
* Part of a set of components for displaying text with consistent typography.
|
|
@@ -24,8 +21,8 @@ export interface LabelProps extends React.LabelHTMLAttributes<HTMLLabelElement>
|
|
|
24
21
|
*
|
|
25
22
|
* @example
|
|
26
23
|
* ```jsx
|
|
27
|
-
* <Label
|
|
28
|
-
*
|
|
24
|
+
* <Label>
|
|
25
|
+
* Oppgi årsaken til at du har ventet mer enn 6 måneder med å søke om refusjon
|
|
29
26
|
* </Label>
|
|
30
27
|
* ```
|
|
31
28
|
*/
|
package/esm/typography/Label.js
CHANGED
|
@@ -9,8 +9,9 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
9
9
|
}
|
|
10
10
|
return t;
|
|
11
11
|
};
|
|
12
|
-
import React, { forwardRef } from "react";
|
|
13
12
|
import cl from "clsx";
|
|
13
|
+
import React, { forwardRef } from "react";
|
|
14
|
+
import { typoClassNames } from "./util";
|
|
14
15
|
/**
|
|
15
16
|
* Part of a set of components for displaying text with consistent typography.
|
|
16
17
|
*
|
|
@@ -20,16 +21,19 @@ import cl from "clsx";
|
|
|
20
21
|
*
|
|
21
22
|
* @example
|
|
22
23
|
* ```jsx
|
|
23
|
-
* <Label
|
|
24
|
-
*
|
|
24
|
+
* <Label>
|
|
25
|
+
* Oppgi årsaken til at du har ventet mer enn 6 måneder med å søke om refusjon
|
|
25
26
|
* </Label>
|
|
26
27
|
* ```
|
|
27
28
|
*/
|
|
28
29
|
export const Label = forwardRef((_a, ref) => {
|
|
29
|
-
var { className, size = "medium",
|
|
30
|
-
return (React.createElement(Component, Object.assign({}, rest, { ref: ref, className: cl(className, "navds-label", {
|
|
30
|
+
var { className, size = "medium", as: Component = "label", spacing, visuallyHidden, textColor } = _a, rest = __rest(_a, ["className", "size", "as", "spacing", "visuallyHidden", "textColor"]);
|
|
31
|
+
return (React.createElement(Component, Object.assign({}, rest, { ref: ref, className: cl(className, "navds-label", typoClassNames({
|
|
32
|
+
spacing,
|
|
33
|
+
visuallyHidden,
|
|
34
|
+
textColor,
|
|
35
|
+
}), {
|
|
31
36
|
"navds-label--small": size === "small",
|
|
32
|
-
"navds-typo--spacing": !!spacing,
|
|
33
37
|
}) })));
|
|
34
38
|
});
|
|
35
39
|
export default Label;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Label.js","sourceRoot":"","sources":["../../src/typography/Label.tsx"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,KAAK,EAAE,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"Label.js","sourceRoot":"","sources":["../../src/typography/Label.tsx"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,EAAE,MAAM,MAAM,CAAC;AACtB,OAAO,KAAK,EAAE,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAG1C,OAAO,EAAE,cAAc,EAAE,MAAM,QAAQ,CAAC;AAgBxC;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAC,MAAM,KAAK,GAChB,UAAU,CACR,CACE,EAQC,EACD,GAAG,EACH,EAAE;QAVF,EACE,SAAS,EACT,IAAI,GAAG,QAAQ,EACf,EAAE,EAAE,SAAS,GAAG,OAAO,EACvB,OAAO,EACP,cAAc,EACd,SAAS,OAEV,EADI,IAAI,cAPT,qEAQC,CADQ;IAGN,OAAA,CACH,oBAAC,SAAS,oBACJ,IAAI,IACR,GAAG,EAAE,GAAG,EACR,SAAS,EAAE,EAAE,CACX,SAAS,EACT,aAAa,EACb,cAAc,CAAC;YACb,OAAO;YACP,cAAc;YACd,SAAS;SACV,CAAC,EACF;YACE,oBAAoB,EAAE,IAAI,KAAK,OAAO;SACvC,CACF,IACD,CACH,CAAA;CAAA,CACF,CAAC;AAEJ,eAAe,KAAK,CAAC"}
|
|
@@ -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 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/typography/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import cl from "clsx";
|
|
2
|
+
export const typoClassNames = (props) => {
|
|
3
|
+
return cl({
|
|
4
|
+
"navds-typo--spacing": props.spacing,
|
|
5
|
+
"navds-typo--truncate": props.truncate,
|
|
6
|
+
"navds-typo--semibold": props.weight === "semibold",
|
|
7
|
+
[`navds-typo--align-${props.align}`]: props.align,
|
|
8
|
+
[`navds-typo--color-${props.textColor}`]: props.textColor,
|
|
9
|
+
"navds-typo--visually-hidden": props.visuallyHidden,
|
|
10
|
+
"navds-typo--uppercase": props.uppercase,
|
|
11
|
+
});
|
|
12
|
+
};
|
|
13
|
+
//# sourceMappingURL=util.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"util.js","sourceRoot":"","sources":["../../src/typography/util.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,MAAM,CAAC;AAGtB,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,KAA0C,EAAE,EAAE;IAC3E,OAAO,EAAE,CAAC;QACR,qBAAqB,EAAE,KAAK,CAAC,OAAO;QACpC,sBAAsB,EAAE,KAAK,CAAC,QAAQ;QACtC,sBAAsB,EAAE,KAAK,CAAC,MAAM,KAAK,UAAU;QACnD,CAAC,qBAAqB,KAAK,CAAC,KAAK,EAAE,CAAC,EAAE,KAAK,CAAC,KAAK;QACjD,CAAC,qBAAqB,KAAK,CAAC,SAAS,EAAE,CAAC,EAAE,KAAK,CAAC,SAAS;QACzD,6BAA6B,EAAE,KAAK,CAAC,cAAc;QACnD,uBAAuB,EAAE,KAAK,CAAC,SAAS;KACzC,CAAC,CAAC;AACL,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@navikt/ds-react",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.3.0",
|
|
4
4
|
"description": "Aksel react-components for NAV designsystem",
|
|
5
5
|
"author": "Aksel | NAV designsystem team",
|
|
6
6
|
"license": "MIT",
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
40
|
"@floating-ui/react": "0.24.1",
|
|
41
|
-
"@navikt/aksel-icons": "^5.
|
|
41
|
+
"@navikt/aksel-icons": "^5.3.0",
|
|
42
42
|
"@radix-ui/react-tabs": "1.0.0",
|
|
43
43
|
"@radix-ui/react-toggle-group": "1.0.0",
|
|
44
44
|
"clsx": "^1.2.1",
|
package/src/form/Textarea.tsx
CHANGED
|
@@ -171,7 +171,7 @@ export const Textarea = forwardRef<HTMLTextAreaElement, TextareaProps>(
|
|
|
171
171
|
{hasMaxLength && (
|
|
172
172
|
<>
|
|
173
173
|
<span id={maxLengthId} className="navds-sr-only">
|
|
174
|
-
Tekstområde med plass til {maxLength} tegn
|
|
174
|
+
{`Tekstområde med plass til ${maxLength} tegn.`}
|
|
175
175
|
</span>
|
|
176
176
|
<Counter
|
|
177
177
|
maxLength={maxLength}
|
|
@@ -1,22 +1,21 @@
|
|
|
1
1
|
import React, { forwardRef } from "react";
|
|
2
2
|
import cl from "clsx";
|
|
3
3
|
import { OverridableComponent } from "../util/OverridableComponent";
|
|
4
|
+
import { TypoProps } from "./types";
|
|
5
|
+
import { typoClassNames } from "./util";
|
|
4
6
|
|
|
5
7
|
export interface BodyLongProps
|
|
6
|
-
extends
|
|
8
|
+
extends TypoProps,
|
|
9
|
+
React.HTMLAttributes<HTMLParagraphElement> {
|
|
7
10
|
/**
|
|
8
|
-
* medium: 18px, small: 16px
|
|
11
|
+
* large: 20px, medium: 18px, small: 16px
|
|
9
12
|
* @default "medium"
|
|
10
13
|
*/
|
|
11
|
-
size?: "medium" | "small";
|
|
14
|
+
size?: "large" | "medium" | "small";
|
|
12
15
|
/**
|
|
13
|
-
*
|
|
16
|
+
* Text
|
|
14
17
|
*/
|
|
15
18
|
children: React.ReactNode;
|
|
16
|
-
/**
|
|
17
|
-
* Adds margin-bottom
|
|
18
|
-
*/
|
|
19
|
-
spacing?: boolean;
|
|
20
19
|
}
|
|
21
20
|
|
|
22
21
|
/**
|
|
@@ -28,8 +27,10 @@ export interface BodyLongProps
|
|
|
28
27
|
*
|
|
29
28
|
* @example
|
|
30
29
|
* ```jsx
|
|
31
|
-
* <BodyLong
|
|
32
|
-
*
|
|
30
|
+
* <BodyLong>
|
|
31
|
+
* Hvis du ikke bor sammen med begge foreldrene dine,
|
|
32
|
+
* kan du ha rett til barnebidrag fra en eller begge foreldre mens du
|
|
33
|
+
* fullfører videregående skole eller tilsvarende.
|
|
33
34
|
* </BodyLong>
|
|
34
35
|
* ```
|
|
35
36
|
*/
|
|
@@ -38,16 +39,36 @@ export const BodyLong: OverridableComponent<
|
|
|
38
39
|
HTMLParagraphElement
|
|
39
40
|
> = forwardRef(
|
|
40
41
|
(
|
|
41
|
-
{
|
|
42
|
+
{
|
|
43
|
+
className,
|
|
44
|
+
size = "medium",
|
|
45
|
+
as: Component = "p",
|
|
46
|
+
spacing,
|
|
47
|
+
truncate,
|
|
48
|
+
weight = "regular",
|
|
49
|
+
align,
|
|
50
|
+
visuallyHidden,
|
|
51
|
+
textColor,
|
|
52
|
+
...rest
|
|
53
|
+
},
|
|
42
54
|
ref
|
|
43
55
|
) => (
|
|
44
56
|
<Component
|
|
45
57
|
{...rest}
|
|
46
58
|
ref={ref}
|
|
47
|
-
className={cl(
|
|
48
|
-
|
|
49
|
-
"navds-
|
|
50
|
-
|
|
59
|
+
className={cl(
|
|
60
|
+
className,
|
|
61
|
+
"navds-body-long",
|
|
62
|
+
`navds-body-long--${size}`,
|
|
63
|
+
typoClassNames({
|
|
64
|
+
spacing,
|
|
65
|
+
truncate,
|
|
66
|
+
weight,
|
|
67
|
+
align,
|
|
68
|
+
visuallyHidden,
|
|
69
|
+
textColor,
|
|
70
|
+
})
|
|
71
|
+
)}
|
|
51
72
|
/>
|
|
52
73
|
)
|
|
53
74
|
);
|
|
@@ -1,22 +1,21 @@
|
|
|
1
|
-
import React, { forwardRef } from "react";
|
|
2
1
|
import cl from "clsx";
|
|
2
|
+
import React, { forwardRef } from "react";
|
|
3
3
|
import { OverridableComponent } from "../util/OverridableComponent";
|
|
4
|
+
import { TypoProps } from "./types";
|
|
5
|
+
import { typoClassNames } from "./util";
|
|
4
6
|
|
|
5
7
|
export interface BodyShortProps
|
|
6
|
-
extends
|
|
8
|
+
extends TypoProps,
|
|
9
|
+
React.HTMLAttributes<HTMLParagraphElement> {
|
|
7
10
|
/**
|
|
8
|
-
* medium: 18px, small: 16px
|
|
11
|
+
* large: 20px, medium: 18px, small: 16px
|
|
9
12
|
* @default "medium"
|
|
10
13
|
*/
|
|
11
|
-
size?: "medium" | "small";
|
|
14
|
+
size?: "large" | "medium" | "small";
|
|
12
15
|
/**
|
|
13
16
|
* Paragraph text
|
|
14
17
|
*/
|
|
15
18
|
children: React.ReactNode;
|
|
16
|
-
/**
|
|
17
|
-
* Adds margin-bottom
|
|
18
|
-
*/
|
|
19
|
-
spacing?: boolean;
|
|
20
19
|
}
|
|
21
20
|
|
|
22
21
|
/**
|
|
@@ -28,8 +27,8 @@ export interface BodyShortProps
|
|
|
28
27
|
*
|
|
29
28
|
* @example
|
|
30
29
|
* ```jsx
|
|
31
|
-
* <BodyShort
|
|
32
|
-
*
|
|
30
|
+
* <BodyShort>
|
|
31
|
+
* Du må gjøre en filtrering for å se brukere i listen.
|
|
33
32
|
* </BodyShort>
|
|
34
33
|
* ```
|
|
35
34
|
*/
|
|
@@ -38,16 +37,36 @@ export const BodyShort: OverridableComponent<
|
|
|
38
37
|
HTMLParagraphElement
|
|
39
38
|
> = forwardRef(
|
|
40
39
|
(
|
|
41
|
-
{
|
|
40
|
+
{
|
|
41
|
+
className,
|
|
42
|
+
size = "medium",
|
|
43
|
+
as: Component = "p",
|
|
44
|
+
spacing,
|
|
45
|
+
truncate,
|
|
46
|
+
weight = "regular",
|
|
47
|
+
align,
|
|
48
|
+
visuallyHidden,
|
|
49
|
+
textColor,
|
|
50
|
+
...rest
|
|
51
|
+
},
|
|
42
52
|
ref
|
|
43
53
|
) => (
|
|
44
54
|
<Component
|
|
45
55
|
{...rest}
|
|
46
56
|
ref={ref}
|
|
47
|
-
className={cl(
|
|
48
|
-
|
|
49
|
-
"navds-
|
|
50
|
-
|
|
57
|
+
className={cl(
|
|
58
|
+
className,
|
|
59
|
+
"navds-body-short",
|
|
60
|
+
`navds-body-short--${size}`,
|
|
61
|
+
typoClassNames({
|
|
62
|
+
spacing,
|
|
63
|
+
truncate,
|
|
64
|
+
weight,
|
|
65
|
+
align,
|
|
66
|
+
visuallyHidden,
|
|
67
|
+
textColor,
|
|
68
|
+
})
|
|
69
|
+
)}
|
|
51
70
|
/>
|
|
52
71
|
)
|
|
53
72
|
);
|
|
@@ -1,9 +1,12 @@
|
|
|
1
|
-
import React, { forwardRef } from "react";
|
|
2
1
|
import cl from "clsx";
|
|
2
|
+
import React, { forwardRef } from "react";
|
|
3
3
|
import { OverridableComponent } from "../util/OverridableComponent";
|
|
4
|
+
import { TypoProps } from "./types";
|
|
5
|
+
import { typoClassNames } from "./util";
|
|
4
6
|
|
|
5
7
|
export interface DetailProps
|
|
6
|
-
extends
|
|
8
|
+
extends TypoProps,
|
|
9
|
+
React.HTMLAttributes<HTMLParagraphElement> {
|
|
7
10
|
/**
|
|
8
11
|
* @deprecated Medium === small
|
|
9
12
|
*/
|
|
@@ -12,10 +15,6 @@ export interface DetailProps
|
|
|
12
15
|
* Paragraph text
|
|
13
16
|
*/
|
|
14
17
|
children: React.ReactNode;
|
|
15
|
-
/**
|
|
16
|
-
* Adds margin-bottom
|
|
17
|
-
*/
|
|
18
|
-
spacing?: boolean;
|
|
19
18
|
/**
|
|
20
19
|
* All caps
|
|
21
20
|
*/
|
|
@@ -31,8 +30,8 @@ export interface DetailProps
|
|
|
31
30
|
*
|
|
32
31
|
* @example
|
|
33
32
|
* ```jsx
|
|
34
|
-
* <Detail
|
|
35
|
-
*
|
|
33
|
+
* <Detail>
|
|
34
|
+
* Du må gjøre en filtrering for å se brukere i listen.
|
|
36
35
|
* </Detail>
|
|
37
36
|
* ```
|
|
38
37
|
*/
|
|
@@ -45,6 +44,11 @@ export const Detail: OverridableComponent<DetailProps, HTMLParagraphElement> =
|
|
|
45
44
|
spacing,
|
|
46
45
|
uppercase,
|
|
47
46
|
as: Component = "p",
|
|
47
|
+
truncate,
|
|
48
|
+
weight = "regular",
|
|
49
|
+
align,
|
|
50
|
+
visuallyHidden,
|
|
51
|
+
textColor,
|
|
48
52
|
...rest
|
|
49
53
|
},
|
|
50
54
|
ref
|
|
@@ -52,11 +56,22 @@ export const Detail: OverridableComponent<DetailProps, HTMLParagraphElement> =
|
|
|
52
56
|
<Component
|
|
53
57
|
{...rest}
|
|
54
58
|
ref={ref}
|
|
55
|
-
className={cl(
|
|
56
|
-
|
|
57
|
-
"navds-
|
|
58
|
-
|
|
59
|
-
|
|
59
|
+
className={cl(
|
|
60
|
+
className,
|
|
61
|
+
"navds-detail",
|
|
62
|
+
typoClassNames({
|
|
63
|
+
spacing,
|
|
64
|
+
truncate,
|
|
65
|
+
weight,
|
|
66
|
+
align,
|
|
67
|
+
visuallyHidden,
|
|
68
|
+
textColor,
|
|
69
|
+
uppercase,
|
|
70
|
+
}),
|
|
71
|
+
{
|
|
72
|
+
"navds-detail--small": size === "small",
|
|
73
|
+
}
|
|
74
|
+
)}
|
|
60
75
|
/>
|
|
61
76
|
)
|
|
62
77
|
);
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import React, { forwardRef } from "react";
|
|
2
2
|
import cl from "clsx";
|
|
3
3
|
import { OverridableComponent } from "../util/OverridableComponent";
|
|
4
|
+
import { TypoProps } from "./types";
|
|
5
|
+
import { typoClassNames } from "./util";
|
|
4
6
|
|
|
5
7
|
export interface ErrorMessageProps
|
|
6
|
-
extends
|
|
8
|
+
extends Pick<TypoProps, "spacing">,
|
|
9
|
+
React.HTMLAttributes<HTMLParagraphElement> {
|
|
7
10
|
/**
|
|
8
11
|
* medium: 18px, small: 16px
|
|
9
12
|
* @default "medium"
|
|
@@ -13,10 +16,6 @@ export interface ErrorMessageProps
|
|
|
13
16
|
* Error text
|
|
14
17
|
*/
|
|
15
18
|
children: React.ReactNode;
|
|
16
|
-
/**
|
|
17
|
-
* Adds margin-bottom
|
|
18
|
-
*/
|
|
19
|
-
spacing?: boolean;
|
|
20
19
|
}
|
|
21
20
|
|
|
22
21
|
/**
|
|
@@ -28,8 +27,8 @@ export interface ErrorMessageProps
|
|
|
28
27
|
*
|
|
29
28
|
* @example
|
|
30
29
|
* ```jsx
|
|
31
|
-
* <ErrorMessage
|
|
32
|
-
*
|
|
30
|
+
* <ErrorMessage>
|
|
31
|
+
* Du må fylle ut: Oppgi årsaken til at du har ventet mer enn 6 måneder med å søke om refusjon
|
|
33
32
|
* </ErrorMessage>
|
|
34
33
|
* ```
|
|
35
34
|
*/
|
|
@@ -41,10 +40,17 @@ export const ErrorMessage: OverridableComponent<
|
|
|
41
40
|
<Component
|
|
42
41
|
{...rest}
|
|
43
42
|
ref={ref}
|
|
44
|
-
className={cl(
|
|
45
|
-
"navds-
|
|
46
|
-
"navds-
|
|
47
|
-
|
|
43
|
+
className={cl(
|
|
44
|
+
"navds-error-message",
|
|
45
|
+
"navds-label",
|
|
46
|
+
className,
|
|
47
|
+
typoClassNames({
|
|
48
|
+
spacing,
|
|
49
|
+
}),
|
|
50
|
+
{
|
|
51
|
+
"navds-label--small": size === "small",
|
|
52
|
+
}
|
|
53
|
+
)}
|
|
48
54
|
/>
|
|
49
55
|
)
|
|
50
56
|
);
|
|
@@ -1,8 +1,12 @@
|
|
|
1
|
-
import React, { forwardRef } from "react";
|
|
2
1
|
import cl from "clsx";
|
|
2
|
+
import React, { forwardRef } from "react";
|
|
3
3
|
import { OverridableComponent } from "../util/OverridableComponent";
|
|
4
|
+
import { TypoProps } from "./types";
|
|
5
|
+
import { typoClassNames } from "./util";
|
|
4
6
|
|
|
5
|
-
export interface HeadingProps
|
|
7
|
+
export interface HeadingProps
|
|
8
|
+
extends Pick<TypoProps, "spacing" | "visuallyHidden" | "align" | "textColor">,
|
|
9
|
+
React.HTMLAttributes<HTMLHeadingElement> {
|
|
6
10
|
/**
|
|
7
11
|
* Heading level
|
|
8
12
|
* @default "1"
|
|
@@ -16,11 +20,6 @@ export interface HeadingProps extends React.HTMLAttributes<HTMLHeadingElement> {
|
|
|
16
20
|
* Heading text
|
|
17
21
|
*/
|
|
18
22
|
children: React.ReactNode;
|
|
19
|
-
/**
|
|
20
|
-
* Adds margin-bottom
|
|
21
|
-
* @default false
|
|
22
|
-
*/
|
|
23
|
-
spacing?: boolean;
|
|
24
23
|
}
|
|
25
24
|
|
|
26
25
|
/**
|
|
@@ -33,22 +32,43 @@ export interface HeadingProps extends React.HTMLAttributes<HTMLHeadingElement> {
|
|
|
33
32
|
* @example
|
|
34
33
|
* ```jsx
|
|
35
34
|
* <Heading level="1" size="xlarge">
|
|
36
|
-
*
|
|
35
|
+
* Hva kan vi hjelpe deg med?
|
|
37
36
|
* </Heading>
|
|
38
37
|
* ```
|
|
39
38
|
*/
|
|
40
39
|
export const Heading: OverridableComponent<HeadingProps, HTMLHeadingElement> =
|
|
41
40
|
forwardRef(
|
|
42
|
-
(
|
|
41
|
+
(
|
|
42
|
+
{
|
|
43
|
+
level = "1",
|
|
44
|
+
size,
|
|
45
|
+
className,
|
|
46
|
+
as,
|
|
47
|
+
spacing,
|
|
48
|
+
align,
|
|
49
|
+
visuallyHidden,
|
|
50
|
+
textColor,
|
|
51
|
+
...rest
|
|
52
|
+
},
|
|
53
|
+
ref
|
|
54
|
+
) => {
|
|
43
55
|
let HeadingTag = as ?? (`h${level}` as React.ElementType);
|
|
44
56
|
|
|
45
57
|
return (
|
|
46
58
|
<HeadingTag
|
|
47
59
|
{...rest}
|
|
48
60
|
ref={ref}
|
|
49
|
-
className={cl(
|
|
50
|
-
|
|
51
|
-
|
|
61
|
+
className={cl(
|
|
62
|
+
className,
|
|
63
|
+
"navds-heading",
|
|
64
|
+
`navds-heading--${size}`,
|
|
65
|
+
typoClassNames({
|
|
66
|
+
spacing,
|
|
67
|
+
align,
|
|
68
|
+
visuallyHidden,
|
|
69
|
+
textColor,
|
|
70
|
+
})
|
|
71
|
+
)}
|
|
52
72
|
/>
|
|
53
73
|
);
|
|
54
74
|
}
|
|
@@ -15,6 +15,8 @@ export interface IngressProps
|
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
/**
|
|
18
|
+
* @deprecated Use `<BodyLong size="large" />`
|
|
19
|
+
*
|
|
18
20
|
* Part of a set of components for displaying text with consistent typography.
|
|
19
21
|
*
|
|
20
22
|
* @see [📝 Documentation](https://aksel.nav.no/komponenter/core/typography)
|
|
@@ -23,8 +25,8 @@ export interface IngressProps
|
|
|
23
25
|
*
|
|
24
26
|
* @example
|
|
25
27
|
* ```jsx
|
|
26
|
-
* <Ingress
|
|
27
|
-
*
|
|
28
|
+
* <Ingress>
|
|
29
|
+
* 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.
|
|
28
30
|
* </Ingress>
|
|
29
31
|
* ```
|
|
30
32
|
*/
|
package/src/typography/Label.tsx
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
|
-
import React, { forwardRef } from "react";
|
|
2
1
|
import cl from "clsx";
|
|
2
|
+
import React, { forwardRef } from "react";
|
|
3
3
|
import { OverridableComponent } from "../util/OverridableComponent";
|
|
4
|
+
import { TypoProps } from "./types";
|
|
5
|
+
import { typoClassNames } from "./util";
|
|
4
6
|
|
|
5
7
|
export interface LabelProps
|
|
6
|
-
extends
|
|
8
|
+
extends Omit<TypoProps, "weight" | "align" | "truncate">,
|
|
9
|
+
React.LabelHTMLAttributes<HTMLLabelElement> {
|
|
7
10
|
/**
|
|
8
11
|
* medium: 18px, small: 16px
|
|
9
12
|
* @default "medium"
|
|
@@ -13,10 +16,6 @@ export interface LabelProps
|
|
|
13
16
|
* Paragraph text
|
|
14
17
|
*/
|
|
15
18
|
children: React.ReactNode;
|
|
16
|
-
/**
|
|
17
|
-
* Adds margin-bottom
|
|
18
|
-
*/
|
|
19
|
-
spacing?: boolean;
|
|
20
19
|
}
|
|
21
20
|
|
|
22
21
|
/**
|
|
@@ -28,24 +27,40 @@ export interface LabelProps
|
|
|
28
27
|
*
|
|
29
28
|
* @example
|
|
30
29
|
* ```jsx
|
|
31
|
-
* <Label
|
|
32
|
-
*
|
|
30
|
+
* <Label>
|
|
31
|
+
* Oppgi årsaken til at du har ventet mer enn 6 måneder med å søke om refusjon
|
|
33
32
|
* </Label>
|
|
34
33
|
* ```
|
|
35
34
|
*/
|
|
36
35
|
export const Label: OverridableComponent<LabelProps, HTMLLabelElement> =
|
|
37
36
|
forwardRef(
|
|
38
37
|
(
|
|
39
|
-
{
|
|
38
|
+
{
|
|
39
|
+
className,
|
|
40
|
+
size = "medium",
|
|
41
|
+
as: Component = "label",
|
|
42
|
+
spacing,
|
|
43
|
+
visuallyHidden,
|
|
44
|
+
textColor,
|
|
45
|
+
...rest
|
|
46
|
+
},
|
|
40
47
|
ref
|
|
41
48
|
) => (
|
|
42
49
|
<Component
|
|
43
50
|
{...rest}
|
|
44
51
|
ref={ref}
|
|
45
|
-
className={cl(
|
|
46
|
-
|
|
47
|
-
"navds-
|
|
48
|
-
|
|
52
|
+
className={cl(
|
|
53
|
+
className,
|
|
54
|
+
"navds-label",
|
|
55
|
+
typoClassNames({
|
|
56
|
+
spacing,
|
|
57
|
+
visuallyHidden,
|
|
58
|
+
textColor,
|
|
59
|
+
}),
|
|
60
|
+
{
|
|
61
|
+
"navds-label--small": size === "small",
|
|
62
|
+
}
|
|
63
|
+
)}
|
|
49
64
|
/>
|
|
50
65
|
)
|
|
51
66
|
);
|