@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.
Files changed (60) hide show
  1. package/_docs.json +334 -54
  2. package/cjs/form/Textarea.js +1 -4
  3. package/cjs/typography/BodyLong.js +14 -7
  4. package/cjs/typography/BodyShort.js +13 -8
  5. package/cjs/typography/Detail.js +14 -7
  6. package/cjs/typography/ErrorMessage.js +6 -4
  7. package/cjs/typography/Heading.js +10 -6
  8. package/cjs/typography/Ingress.js +4 -2
  9. package/cjs/typography/Label.js +10 -6
  10. package/cjs/typography/types.js +2 -0
  11. package/cjs/typography/util.js +19 -0
  12. package/esm/form/Textarea.js +1 -4
  13. package/esm/form/Textarea.js.map +1 -1
  14. package/esm/typography/BodyLong.d.ts +9 -10
  15. package/esm/typography/BodyLong.js +14 -7
  16. package/esm/typography/BodyLong.js.map +1 -1
  17. package/esm/typography/BodyShort.d.ts +6 -9
  18. package/esm/typography/BodyShort.js +13 -8
  19. package/esm/typography/BodyShort.js.map +1 -1
  20. package/esm/typography/Detail.d.ts +4 -7
  21. package/esm/typography/Detail.js +14 -7
  22. package/esm/typography/Detail.js.map +1 -1
  23. package/esm/typography/ErrorMessage.d.ts +4 -7
  24. package/esm/typography/ErrorMessage.js +6 -4
  25. package/esm/typography/ErrorMessage.js.map +1 -1
  26. package/esm/typography/Heading.d.ts +3 -7
  27. package/esm/typography/Heading.js +10 -6
  28. package/esm/typography/Heading.js.map +1 -1
  29. package/esm/typography/Ingress.d.ts +4 -2
  30. package/esm/typography/Ingress.js +4 -2
  31. package/esm/typography/Ingress.js.map +1 -1
  32. package/esm/typography/Label.d.ts +4 -7
  33. package/esm/typography/Label.js +10 -6
  34. package/esm/typography/Label.js.map +1 -1
  35. package/esm/typography/types.d.ts +26 -0
  36. package/esm/typography/types.js +2 -0
  37. package/esm/typography/types.js.map +1 -0
  38. package/esm/typography/util.d.ts +4 -0
  39. package/esm/typography/util.js +13 -0
  40. package/esm/typography/util.js.map +1 -0
  41. package/package.json +2 -2
  42. package/src/form/Textarea.tsx +1 -1
  43. package/src/typography/BodyLong.tsx +36 -15
  44. package/src/typography/BodyShort.tsx +34 -15
  45. package/src/typography/Detail.tsx +28 -13
  46. package/src/typography/ErrorMessage.tsx +17 -11
  47. package/src/typography/Heading.tsx +32 -12
  48. package/src/typography/Ingress.tsx +4 -2
  49. package/src/typography/Label.tsx +28 -13
  50. package/src/typography/stories/bodylong.stories.tsx +165 -0
  51. package/src/typography/stories/bodyshort.stories.tsx +164 -0
  52. package/src/typography/stories/detail.stories.tsx +88 -0
  53. package/src/typography/stories/error-message.stories.tsx +93 -0
  54. package/src/typography/stories/heading.stories.tsx +143 -0
  55. package/src/typography/stories/ingress.stories.tsx +51 -0
  56. package/src/typography/stories/label.stories.tsx +98 -0
  57. package/src/typography/types.ts +26 -0
  58. package/src/typography/util.ts +14 -0
  59. package/src/typography/heading.stories.tsx +0 -77
  60. 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
- export interface LabelProps extends React.LabelHTMLAttributes<HTMLLabelElement> {
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 level="1" size="xlarge">
28
- * Pengestøtte når du er syk
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
  */
@@ -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 level="1" size="xlarge">
24
- * Pengestøtte når du er syk
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", spacing, as: Component = "label" } = _a, rest = __rest(_a, ["className", "size", "spacing", "as"]);
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;AAC1C,OAAO,EAAE,MAAM,MAAM,CAAC;AAoBtB;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAC,MAAM,KAAK,GAChB,UAAU,CACR,CACE,EAAyE,EACzE,GAAG,EACH,EAAE;QAFF,EAAE,SAAS,EAAE,IAAI,GAAG,QAAQ,EAAE,OAAO,EAAE,EAAE,EAAE,SAAS,GAAG,OAAO,OAAW,EAAN,IAAI,cAAvE,sCAAyE,CAAF;IAEpE,OAAA,CACH,oBAAC,SAAS,oBACJ,IAAI,IACR,GAAG,EAAE,GAAG,EACR,SAAS,EAAE,EAAE,CAAC,SAAS,EAAE,aAAa,EAAE;YACtC,oBAAoB,EAAE,IAAI,KAAK,OAAO;YACtC,qBAAqB,EAAE,CAAC,CAAC,OAAO;SACjC,CAAC,IACF,CACH,CAAA;CAAA,CACF,CAAC;AAEJ,eAAe,KAAK,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,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/typography/types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,4 @@
1
+ import { TypoProps } from "./types";
2
+ export declare const typoClassNames: (props: TypoProps & {
3
+ uppercase?: boolean;
4
+ }) => string;
@@ -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.2.0",
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.2.0",
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",
@@ -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 React.HTMLAttributes<HTMLParagraphElement> {
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
- * Paragraph text
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 level="1" size="xlarge">
32
- * Pengestøtte når du er syk
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
- { className, size = "medium", spacing, as: Component = "p", ...rest },
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(className, "navds-body-long", {
48
- "navds-body-long--small": size === "small",
49
- "navds-typo--spacing": !!spacing,
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 React.HTMLAttributes<HTMLParagraphElement> {
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 level="1" size="xlarge">
32
- * Pengestøtte når du er syk
30
+ * <BodyShort>
31
+ * Du 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
- { className, size = "medium", spacing, as: Component = "p", ...rest },
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(className, "navds-body-short", {
48
- "navds-body-short--small": size === "small",
49
- "navds-typo--spacing": !!spacing,
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 React.HTMLAttributes<HTMLParagraphElement> {
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 level="1" size="xlarge">
35
- * Pengestøtte når du er syk
33
+ * <Detail>
34
+ * Du 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(className, "navds-detail", {
56
- "navds-detail--small": size === "small",
57
- "navds-typo--spacing": !!spacing,
58
- "navds-typo--uppercase": !!uppercase,
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 React.HTMLAttributes<HTMLParagraphElement> {
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 level="1" size="xlarge">
32
- * Pengestøtte når du er syk
30
+ * <ErrorMessage>
31
+ * Du 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("navds-error-message", "navds-label", className, {
45
- "navds-label--small": size === "small",
46
- "navds-typo--spacing": !!spacing,
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 extends React.HTMLAttributes<HTMLHeadingElement> {
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
- * Pengestøtte når du er syk
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
- ({ level = "1", size, spacing = false, className, as, ...rest }, ref) => {
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(className, "navds-heading", `navds-heading--${size}`, {
50
- "navds-typo--spacing": spacing,
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 level="1" size="xlarge">
27
- * Pengestøtte når du er syk
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
  */
@@ -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 React.LabelHTMLAttributes<HTMLLabelElement> {
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 level="1" size="xlarge">
32
- * Pengestøtte når du er syk
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
- { className, size = "medium", spacing, as: Component = "label", ...rest },
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(className, "navds-label", {
46
- "navds-label--small": size === "small",
47
- "navds-typo--spacing": !!spacing,
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
  );