@entur/typography 3.0.7 → 3.2.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 (69) hide show
  1. package/README.md +9 -38
  2. package/dist/beta/cjs/components/Heading.cjs +39 -29
  3. package/dist/beta/cjs/components/Heading.cjs.map +1 -1
  4. package/dist/beta/cjs/components/Label.cjs +22 -0
  5. package/dist/beta/cjs/components/Label.cjs.map +1 -0
  6. package/dist/beta/cjs/components/Link.cjs +18 -33
  7. package/dist/beta/cjs/components/Link.cjs.map +1 -1
  8. package/dist/beta/cjs/components/ListItem.cjs +34 -25
  9. package/dist/beta/cjs/components/ListItem.cjs.map +1 -1
  10. package/dist/beta/cjs/components/NumberedList.cjs +36 -24
  11. package/dist/beta/cjs/components/NumberedList.cjs.map +1 -1
  12. package/dist/beta/cjs/components/Text.cjs +40 -28
  13. package/dist/beta/cjs/components/Text.cjs.map +1 -1
  14. package/dist/beta/cjs/components/TextContainer.cjs +26 -0
  15. package/dist/beta/cjs/components/TextContainer.cjs.map +1 -0
  16. package/dist/beta/cjs/components/UnorderedList.cjs +31 -21
  17. package/dist/beta/cjs/components/UnorderedList.cjs.map +1 -1
  18. package/dist/beta/cjs/index.cjs +8 -3
  19. package/dist/beta/cjs/index.cjs.map +1 -1
  20. package/dist/beta/cjs/utils/utils.cjs +73 -41
  21. package/dist/beta/cjs/utils/utils.cjs.map +1 -1
  22. package/dist/beta/cjs/utils/warnAboutGlobalStyles.cjs +113 -0
  23. package/dist/beta/cjs/utils/warnAboutGlobalStyles.cjs.map +1 -0
  24. package/dist/beta/esm/components/Heading.mjs +40 -30
  25. package/dist/beta/esm/components/Heading.mjs.map +1 -1
  26. package/dist/beta/esm/components/Label.mjs +22 -0
  27. package/dist/beta/esm/components/Label.mjs.map +1 -0
  28. package/dist/beta/esm/components/Link.mjs +20 -35
  29. package/dist/beta/esm/components/Link.mjs.map +1 -1
  30. package/dist/beta/esm/components/ListItem.mjs +35 -26
  31. package/dist/beta/esm/components/ListItem.mjs.map +1 -1
  32. package/dist/beta/esm/components/NumberedList.mjs +37 -25
  33. package/dist/beta/esm/components/NumberedList.mjs.map +1 -1
  34. package/dist/beta/esm/components/Text.mjs +41 -29
  35. package/dist/beta/esm/components/Text.mjs.map +1 -1
  36. package/dist/beta/esm/components/TextContainer.mjs +26 -0
  37. package/dist/beta/esm/components/TextContainer.mjs.map +1 -0
  38. package/dist/beta/esm/components/UnorderedList.mjs +32 -22
  39. package/dist/beta/esm/components/UnorderedList.mjs.map +1 -1
  40. package/dist/beta/esm/index.mjs +8 -3
  41. package/dist/beta/esm/index.mjs.map +1 -1
  42. package/dist/beta/esm/utils/utils.mjs +73 -41
  43. package/dist/beta/esm/utils/utils.mjs.map +1 -1
  44. package/dist/beta/esm/utils/warnAboutGlobalStyles.mjs +113 -0
  45. package/dist/beta/esm/utils/warnAboutGlobalStyles.mjs.map +1 -0
  46. package/dist/beta/styles/index.css +878 -609
  47. package/dist/beta/types/components/Heading.d.ts +27 -11
  48. package/dist/beta/types/components/Label.d.ts +22 -0
  49. package/dist/beta/types/components/Link.d.ts +11 -9
  50. package/dist/beta/types/components/ListItem.d.ts +13 -7
  51. package/dist/beta/types/components/NumberedList.d.ts +17 -7
  52. package/dist/beta/types/components/Text.d.ts +33 -13
  53. package/dist/beta/types/components/TextContainer.d.ts +25 -0
  54. package/dist/beta/types/components/UnorderedList.d.ts +13 -7
  55. package/dist/beta/types/index.d.ts +11 -2
  56. package/dist/beta/types/tests/styles.test.d.ts +1 -0
  57. package/dist/beta/types/tests/warnAboutGlobalStyles.test.d.ts +1 -0
  58. package/dist/beta/types/types.d.ts +16 -5
  59. package/dist/beta/types/utils/utils.d.ts +15 -4
  60. package/dist/beta/types/utils/warnAboutGlobalStyles.d.ts +4 -0
  61. package/dist/styles.css +13 -5
  62. package/dist/styles.no-base-tokens.css +822 -0
  63. package/package.json +8 -12
  64. package/dist/beta/cjs/components/Blockquote.cjs +0 -29
  65. package/dist/beta/cjs/components/Blockquote.cjs.map +0 -1
  66. package/dist/beta/esm/components/Blockquote.mjs +0 -29
  67. package/dist/beta/esm/components/Blockquote.mjs.map +0 -1
  68. package/dist/beta/types/components/Blockquote.d.ts +0 -12
  69. package/scripts/migrate-typography.mjs +0 -1462
@@ -1,20 +1,36 @@
1
1
  import { default as React } from 'react';
2
- import { TypographyHeadingVariant, TypographySize, TypographySpacing } from '../types';
2
+ import { TypographySpacingProps } from '../types';
3
3
  import { PolymorphicComponentProps } from '@entur/utils';
4
- type HeadingBaseProps = {
4
+ /**
5
+ * @beta Experimental component - may have breaking changes in future releases
6
+ */
7
+ export type HeadingOwnProps = TypographySpacingProps & {
5
8
  /** Visuell variant som bestemmer styling (anbefalt over size) */
6
- variant?: TypographyHeadingVariant;
9
+ variant?: 'title-1' | 'title-2' | 'subtitle-1' | 'subtitle-2' | 'section-1' | 'section-2';
7
10
  /** Visuell tekststørrelse som overstyrer variant-styling */
8
- size?: TypographySize;
11
+ size?: 'xs' | 's' | 'm' | 'lg' | 'xl' | '2xl';
12
+ /** Dempet tekst for sekundære overskrifter. Velger riktig farge i kontrast- og mørk modus. */
13
+ tone?: 'subdued';
9
14
  /** Innholdet som skal vises */
10
- children: React.ReactNode;
15
+ children?: React.ReactNode;
16
+ /** Fjerner luften over versalhøyden og under grunnlinjen, så teksten flukter med elementer ved siden av. Har ingen effekt i nettlesere uten støtte for `text-box`. */
17
+ trim?: boolean;
18
+ /** Kutter teksten etter så mange linjer og avslutter med «…». Hele teksten må kunne leses et annet sted, for eksempel på en egen side. */
19
+ maxLines?: number;
11
20
  /** Ekstra klassenavn for tilpasset styling */
12
21
  className?: string;
13
- /** Inline CSS-stiler */
14
- style?: React.CSSProperties;
15
- /** Spacing around the component */
16
- spacing?: TypographySpacing;
17
22
  };
18
- export type HeadingProps<C extends React.ElementType> = PolymorphicComponentProps<C, HeadingBaseProps>;
19
- export declare const Heading: <C extends React.ElementType = "h1">({ children, as, size, variant, spacing, className, ...rest }: HeadingProps<C>) => import("react/jsx-runtime").JSX.Element;
23
+ export type TypographyHeadingVariant = NonNullable<HeadingOwnProps['variant']>;
24
+ export type TypographyHeadingSize = NonNullable<HeadingOwnProps['size']>;
25
+ export type HeadingProps<C extends React.ElementType = typeof defaultElement> = PolymorphicComponentProps<C, HeadingOwnProps>;
26
+ export type HeadingComponent = (<C extends React.ElementType = typeof defaultElement>(props: HeadingProps<C> & {
27
+ ref?: React.Ref<Element>;
28
+ }) => React.ReactElement | null) & {
29
+ displayName?: string;
30
+ };
31
+ declare const defaultElement = "h2";
32
+ /**
33
+ * @beta Experimental component - may have breaking changes in future releases
34
+ */
35
+ export declare const Heading: HeadingComponent;
20
36
  export {};
@@ -0,0 +1,22 @@
1
+ import { default as React } from 'react';
2
+ import { TypographySpacingProps } from '../types';
3
+ /**
4
+ * @beta Experimental component - may have breaking changes in future releases
5
+ */
6
+ export type LabelOwnProps = TypographySpacingProps & {
7
+ /** Ekstra klassenavn */
8
+ className?: string;
9
+ /** Innholdet */
10
+ children?: React.ReactNode;
11
+ };
12
+ export type LabelProps = LabelOwnProps & Omit<React.LabelHTMLAttributes<HTMLLabelElement>, keyof LabelOwnProps>;
13
+ /**
14
+ * Ledetekst for et skjemafelt, koblet til feltet med `htmlFor` eller ved å ligge rundt det
15
+ * @beta Experimental component - may have breaking changes in future releases
16
+ */
17
+ export declare const Label: React.ForwardRefExoticComponent<TypographySpacingProps & {
18
+ /** Ekstra klassenavn */
19
+ className?: string;
20
+ /** Innholdet */
21
+ children?: React.ReactNode;
22
+ } & Omit<React.LabelHTMLAttributes<HTMLLabelElement>, "spacing" | "children" | "className"> & React.RefAttributes<HTMLLabelElement>>;
@@ -1,22 +1,24 @@
1
1
  import { default as React } from 'react';
2
2
  import { PolymorphicComponentProps } from '@entur/utils';
3
- import { TypographySpacing } from '../types';
3
+ import { TypographySpacingProps } from '../types';
4
4
  /**
5
5
  * @beta Experimental component - may have breaking changes in future releases
6
6
  */
7
- type LinkBaseProps = {
8
- external?: boolean;
7
+ export type LinkOwnProps = TypographySpacingProps & {
9
8
  /** Ekstra klassenavn */
10
9
  className?: string;
11
10
  /** Innholdet */
12
- children: React.ReactNode;
13
- /** Spacing around the component (same as Text and Heading components) */
14
- spacing?: TypographySpacing;
15
- ariaLabelExternalIcon?: string;
11
+ children?: React.ReactNode;
16
12
  };
17
- export type LinkProps<C extends React.ElementType> = PolymorphicComponentProps<C, LinkBaseProps>;
13
+ export type LinkProps<C extends React.ElementType = typeof defaultElement> = PolymorphicComponentProps<C, LinkOwnProps>;
14
+ export type LinkComponent = (<C extends React.ElementType = typeof defaultElement>(props: LinkProps<C> & {
15
+ ref?: React.Ref<Element>;
16
+ }) => React.ReactElement | null) & {
17
+ displayName?: string;
18
+ };
19
+ declare const defaultElement = "a";
18
20
  /**
19
21
  * @beta Experimental component - may have breaking changes in future releases
20
22
  */
21
- export declare const Link: <C extends React.ElementType = "a">({ external, ariaLabelExternalIcon, className, spacing, children, as, ...rest }: LinkProps<C>) => JSX.Element;
23
+ export declare const Link: LinkComponent;
22
24
  export {};
@@ -1,22 +1,28 @@
1
1
  import { default as React } from 'react';
2
2
  import { PolymorphicComponentProps } from '@entur/utils';
3
- import { TypographySpacing } from '../types';
3
+ import { TypographySpacingProps } from '../types';
4
4
  /**
5
5
  * @beta Experimental component - may have breaking changes in future releases
6
6
  */
7
- type ListItemBaseProps = {
7
+ export type ListItemOwnProps = TypographySpacingProps & {
8
8
  /** Ekstra klassenavn */
9
9
  className?: string;
10
+ /** Dempet punkt, for eksempel et steg som er fullført. Velger riktig farge i kontrast- og mørk modus. */
11
+ tone?: 'subdued';
10
12
  /** Innholdet */
11
- children: React.ReactNode;
13
+ children?: React.ReactNode;
12
14
  /** Tittel */
13
15
  title?: React.ReactNode;
14
- /** Spacing around the component (same as Text and Heading components) */
15
- spacing?: TypographySpacing;
16
16
  };
17
- export type ListItemProps<C extends React.ElementType> = PolymorphicComponentProps<C, ListItemBaseProps>;
17
+ export type ListItemProps<C extends React.ElementType = typeof defaultElement> = PolymorphicComponentProps<C, ListItemOwnProps>;
18
+ export type ListItemComponent = (<C extends React.ElementType = typeof defaultElement>(props: ListItemProps<C> & {
19
+ ref?: React.Ref<Element>;
20
+ }) => React.ReactElement | null) & {
21
+ displayName?: string;
22
+ };
23
+ declare const defaultElement = "li";
18
24
  /**
19
25
  * @beta Experimental component - may have breaking changes in future releases
20
26
  */
21
- export declare const ListItem: <C extends React.ElementType = "li">({ children, className, title, spacing, as, ...rest }: ListItemProps<C>) => JSX.Element;
27
+ export declare const ListItem: ListItemComponent;
22
28
  export {};
@@ -1,22 +1,32 @@
1
1
  import { default as React } from 'react';
2
2
  import { PolymorphicComponentProps } from '@entur/utils';
3
- import { TypographySpacing } from '../types';
3
+ import { TypographySpacingProps } from '../types';
4
4
  /**
5
5
  * @beta Experimental component - may have breaking changes in future releases
6
6
  */
7
- type NumberedListBaseProps = {
7
+ export type NumberedListOwnProps = TypographySpacingProps & {
8
8
  /** Ekstra klassenavn */
9
9
  className?: string;
10
+ /** Dempet liste for sekundær informasjon, som hjelpetekst. Velger riktig farge i kontrast- og mørk modus. */
11
+ tone?: 'subdued';
10
12
  /** Innholdet */
11
- children: React.ReactNode;
13
+ children?: React.ReactNode;
12
14
  /** List type (1, A, a, I, i) */
13
15
  type?: '1' | 'A' | 'a' | 'I' | 'i';
14
- /** Spacing around the component (same as Text and Heading components) */
15
- spacing?: TypographySpacing;
16
+ /** `steps` viser numrene i merker, for steg-for-steg-instruksjoner
17
+ * @default 'default'
18
+ */
19
+ variant?: 'default' | 'steps';
16
20
  };
17
- export type NumberedListProps<C extends React.ElementType> = PolymorphicComponentProps<C, NumberedListBaseProps>;
21
+ export type NumberedListProps<C extends React.ElementType = typeof defaultElement> = PolymorphicComponentProps<C, NumberedListOwnProps>;
22
+ export type NumberedListComponent = (<C extends React.ElementType = typeof defaultElement>(props: NumberedListProps<C> & {
23
+ ref?: React.Ref<Element>;
24
+ }) => React.ReactElement | null) & {
25
+ displayName?: string;
26
+ };
27
+ declare const defaultElement = "ol";
18
28
  /**
19
29
  * @beta Experimental component - may have breaking changes in future releases
20
30
  */
21
- export declare const NumberedList: <C extends React.ElementType = "ol">({ className, type, spacing, as, children, ...rest }: NumberedListProps<C>) => JSX.Element;
31
+ export declare const NumberedList: NumberedListComponent;
22
32
  export {};
@@ -1,20 +1,40 @@
1
1
  import { default as React } from 'react';
2
2
  import { PolymorphicComponentProps } from '@entur/utils';
3
- import { TypographySize, TypographySpacing, TypographyTextVariant, TypographyWeight } from '../types';
4
- type TextBaseProps = {
3
+ import { TypographySpacingProps } from '../types';
4
+ /**
5
+ * @beta Experimental component - may have breaking changes in future releases
6
+ */
7
+ export type TextOwnProps = TypographySpacingProps & {
5
8
  /** Visuell tekststørrelse (typografi-token) */
6
- size?: TypographySize;
7
- /** Fontvekt */
8
- weight?: TypographyWeight;
9
- /** Variant (kan brukes til spesielle typer tekst som for eksempel caption) */
10
- variant?: TypographyTextVariant;
9
+ size?: 'xs' | 's' | 'm' | 'lg' | 'xl';
10
+ /** Fontvekt: `medium` (500) eller `bold` (600) */
11
+ weight?: 'medium' | 'bold';
12
+ /** Dempet tekst for sekundær informasjon, som metadata og hjelpetekst. Velger riktig farge i kontrast- og mørk modus. */
13
+ tone?: 'subdued';
14
+ /** Variant (kan brukes til spesielle typer tekst som for eksempel caption).
15
+ * Uten variant blir teksten `paragraph` når den står for seg selv (`p`, `div`, `li` …), og arver
16
+ * størrelse, farge og vekt når den står inne i annen tekst (`span`, `strong`, en komponent …). */
17
+ variant?: 'leading' | 'quote' | 'paragraph' | 'subparagraph' | 'caption' | 'label' | 'sublabel' | 'overline' | 'emphasized' | 'code' | 'preformatted';
11
18
  /** Innhold */
12
- children: React.ReactNode;
13
- /** Spacing around the component */
14
- spacing?: TypographySpacing;
19
+ children?: React.ReactNode;
20
+ /** Fjerner luften over versalhøyden og under grunnlinjen, så teksten flukter med elementer ved siden av. Har ingen effekt i nettlesere uten støtte for `text-box`. */
21
+ trim?: boolean;
22
+ /** Kutter teksten etter så mange linjer og avslutter med «…». Hele teksten må kunne leses et annet sted, for eksempel på en egen side. */
23
+ maxLines?: number;
15
24
  /** Ekstra klassenavn */
16
25
  className?: string;
17
26
  };
18
- export type TextProps<C extends React.ElementType> = PolymorphicComponentProps<C, TextBaseProps>;
19
- export declare const Text: <C extends React.ElementType = "p">({ children, as, size, variant, weight, spacing, className, ...rest }: TextProps<C>) => import("react/jsx-runtime").JSX.Element;
20
- export {};
27
+ export type TypographyTextVariant = NonNullable<TextOwnProps['variant']>;
28
+ export type TypographyTextSize = NonNullable<TextOwnProps['size']>;
29
+ export type TypographyWeight = NonNullable<TextOwnProps['weight']>;
30
+ export type TypographyTone = NonNullable<TextOwnProps['tone']>;
31
+ export type TextProps<C extends React.ElementType = 'p'> = PolymorphicComponentProps<C, TextOwnProps>;
32
+ export type TextComponent = (<C extends React.ElementType = 'p'>(props: TextProps<C> & {
33
+ ref?: React.Ref<Element>;
34
+ }) => React.ReactElement | null) & {
35
+ displayName?: string;
36
+ };
37
+ /**
38
+ * @beta Experimental component - may have breaking changes in future releases
39
+ */
40
+ export declare const Text: TextComponent;
@@ -0,0 +1,25 @@
1
+ import { default as React } from 'react';
2
+ import { PolymorphicComponentProps } from '@entur/utils';
3
+ import { TypographySpacingProps } from '../types';
4
+ /**
5
+ * @beta Experimental component - may have breaking changes in future releases
6
+ */
7
+ export type TextContainerOwnProps = TypographySpacingProps & {
8
+ /** Ekstra klassenavn */
9
+ className?: string;
10
+ /** Overskrifter, avsnitt, lister og annen løpende tekst */
11
+ children?: React.ReactNode;
12
+ };
13
+ export type TextContainerProps<C extends React.ElementType = typeof defaultElement> = PolymorphicComponentProps<C, TextContainerOwnProps>;
14
+ export type TextContainerComponent = (<C extends React.ElementType = typeof defaultElement>(props: TextContainerProps<C> & {
15
+ ref?: React.Ref<Element>;
16
+ }) => React.ReactElement | null) & {
17
+ displayName?: string;
18
+ };
19
+ declare const defaultElement = "div";
20
+ /**
21
+ * Gir løpende tekst riktig avstand mellom overskrifter, avsnitt og lister
22
+ * @beta Experimental component - may have breaking changes in future releases
23
+ */
24
+ export declare const TextContainer: TextContainerComponent;
25
+ export {};
@@ -1,20 +1,26 @@
1
1
  import { default as React } from 'react';
2
2
  import { PolymorphicComponentProps } from '@entur/utils';
3
- import { TypographySpacing } from '../types';
3
+ import { TypographySpacingProps } from '../types';
4
4
  /**
5
5
  * @beta Experimental component - may have breaking changes in future releases
6
6
  */
7
- type UnorderedListBaseProps = {
7
+ export type UnorderedListOwnProps = TypographySpacingProps & {
8
8
  /** Ekstra klassenavn */
9
9
  className?: string;
10
+ /** Dempet liste for sekundær informasjon, som hjelpetekst. Velger riktig farge i kontrast- og mørk modus. */
11
+ tone?: 'subdued';
10
12
  /** Innholdet */
11
- children: React.ReactNode;
12
- /** Spacing around the component (same as Text and Heading components) */
13
- spacing?: TypographySpacing;
13
+ children?: React.ReactNode;
14
14
  };
15
- export type UnorderedListProps<C extends React.ElementType> = PolymorphicComponentProps<C, UnorderedListBaseProps>;
15
+ export type UnorderedListProps<C extends React.ElementType = typeof defaultElement> = PolymorphicComponentProps<C, UnorderedListOwnProps>;
16
+ export type UnorderedListComponent = (<C extends React.ElementType = typeof defaultElement>(props: UnorderedListProps<C> & {
17
+ ref?: React.Ref<Element>;
18
+ }) => React.ReactElement | null) & {
19
+ displayName?: string;
20
+ };
21
+ declare const defaultElement = "ul";
16
22
  /**
17
23
  * @beta Experimental component - may have breaking changes in future releases
18
24
  */
19
- export declare const UnorderedList: <C extends React.ElementType = "ul">({ className, spacing, as, children, ...rest }: UnorderedListProps<C>) => JSX.Element;
25
+ export declare const UnorderedList: UnorderedListComponent;
20
26
  export {};
@@ -1,8 +1,17 @@
1
1
  export { Heading } from './components/Heading';
2
2
  export { Text } from './components/Text';
3
3
  export { Link } from './components/Link';
4
- export { Blockquote, BlockquoteFooter } from './components/Blockquote';
4
+ export { Label } from './components/Label';
5
5
  export { UnorderedList } from './components/UnorderedList';
6
6
  export { NumberedList } from './components/NumberedList';
7
7
  export { ListItem } from './components/ListItem';
8
- export type { TypographyHeadingVariant, TypographyTextVariant, TypographySize, TypographyWeight, TypographySpacing, } from './types';
8
+ export { TextContainer } from './components/TextContainer';
9
+ export type { HeadingComponent, HeadingOwnProps, HeadingProps, TypographyHeadingSize, TypographyHeadingVariant, } from './components/Heading';
10
+ export type { TextComponent, TextOwnProps, TextProps, TypographyTextSize, TypographyTextVariant, TypographyTone, TypographyWeight, } from './components/Text';
11
+ export type { LinkComponent, LinkOwnProps, LinkProps } from './components/Link';
12
+ export type { LabelOwnProps, LabelProps } from './components/Label';
13
+ export type { UnorderedListComponent, UnorderedListOwnProps, UnorderedListProps, } from './components/UnorderedList';
14
+ export type { NumberedListComponent, NumberedListOwnProps, NumberedListProps, } from './components/NumberedList';
15
+ export type { ListItemComponent, ListItemOwnProps, ListItemProps, } from './components/ListItem';
16
+ export type { TextContainerComponent, TextContainerOwnProps, TextContainerProps, } from './components/TextContainer';
17
+ export type { TypographySize, TypographySpacing, TypographySpacingProps, } from './types';
@@ -0,0 +1 @@
1
+ export {};
@@ -1,5 +1,16 @@
1
- export type TypographyHeadingVariant = 'title-1' | 'title-2' | 'subtitle-1' | 'subtitle-2' | 'section-1' | 'section-2' | 'label' | 'sublabel';
2
- export type TypographyTextVariant = 'leading' | 'quote' | 'paragraph' | 'subparagraph' | 'caption' | 'link' | 'label' | 'sublabel' | 'overline' | 'emphasized' | 'code-text' | 'preformatted-text';
3
- export type TypographySize = 'xs' | 's' | 'm' | 'lg' | 'xl' | '2xl';
4
- export type TypographyWeight = 'regular' | 'medium' | 'semibold' | 'bold' | '400' | '500' | '600' | '700';
5
- export type TypographySpacing = 'none' | 'xs2' | 'xs2-top' | 'xs2-bottom' | 'xs' | 'xs-top' | 'xs-bottom' | 'sm' | 'sm-top' | 'sm-bottom' | 'md' | 'md-top' | 'md-bottom' | 'lg' | 'lg-top' | 'lg-bottom' | 'xl' | 'xl-top' | 'xl-bottom';
1
+ import { TypographyHeadingSize } from './components/Heading';
2
+ import { TypographyTextSize } from './components/Text';
3
+ /** Every font size in the typography, on headings and text */
4
+ export type TypographySize = TypographyHeadingSize | TypographyTextSize;
5
+ export type TypographySpacingProps = {
6
+ /**
7
+ * Avstand over og under, fra samme skala som `gap` på Flex og Grid.
8
+ * Én verdi gir lik avstand over og under, `{ top, bottom }` setter dem hver for seg.
9
+ * Uten `spacing` har teksten ingen avstand, med mindre den ligger i en `TextContainer`.
10
+ */
11
+ spacing?: 'none' | '2xs' | 'xs' | 's' | 'm' | 'lg' | 'xl' | '2xl' | '3xl' | '4xl' | '5xl' | '6xl' | '7xl' | '8xl' | '9xl' | '10xl' | '11xl' | '12xl' | '13xl' | {
12
+ top?: 'none' | '2xs' | 'xs' | 's' | 'm' | 'lg' | 'xl' | '2xl' | '3xl' | '4xl' | '5xl' | '6xl' | '7xl' | '8xl' | '9xl' | '10xl' | '11xl' | '12xl' | '13xl';
13
+ bottom?: 'none' | '2xs' | 'xs' | 's' | 'm' | 'lg' | 'xl' | '2xl' | '3xl' | '4xl' | '5xl' | '6xl' | '7xl' | '8xl' | '9xl' | '10xl' | '11xl' | '12xl' | '13xl';
14
+ };
15
+ };
16
+ export type TypographySpacing = NonNullable<TypographySpacingProps['spacing']>;
@@ -1,13 +1,24 @@
1
- import { TypographyHeadingVariant, TypographySpacing, TypographyTextVariant } from '../types';
1
+ import { TypographyHeadingVariant } from '../components/Heading';
2
+ import { TypographyTextVariant } from '../components/Text';
3
+ import { TypographySpacing } from '../types';
4
+ export declare const SPACING_STEPS: Set<string>;
2
5
  /**
3
- * Get spacing classes for a component
6
+ * Turn the spacing prop into the custom properties that set the margins
4
7
  */
5
- export declare function getSpacingClasses(spacing: TypographySpacing | undefined, baseClass: string): string;
8
+ export declare function getSpacingStyle(spacing: TypographySpacing | undefined, style?: React.CSSProperties): React.CSSProperties | undefined;
9
+ /**
10
+ * Pass maxLines on to the CSS, which cuts the text after that many lines
11
+ */
12
+ export declare function getMaxLinesStyle(maxLines: number | undefined, style?: React.CSSProperties): React.CSSProperties | undefined;
6
13
  /**
7
14
  * Get heading variant based on semantic HTML element
8
15
  */
9
16
  export declare function getHeadingVariantFromSemanticType(element: string | React.ElementType): TypographyHeadingVariant;
17
+ /**
18
+ * The variant Text uses when none is given: paragraph on its own line, inherit inside other text
19
+ */
20
+ export declare function getDefaultTextVariant(element: React.ElementType): 'paragraph' | 'inherit';
10
21
  /**
11
22
  * Get semantic HTML element from text variant
12
23
  */
13
- export declare function getSemanticTypeFromTextVariant(variant: TypographyTextVariant | undefined): string;
24
+ export declare function getSemanticTypeFromTextVariant(variant: TypographyTextVariant | undefined): keyof JSX.IntrinsicElements;
@@ -0,0 +1,4 @@
1
+ /** Finds global CSS in the app that overrides the beta typography. Empty when the beta styles aren't loaded. */
2
+ export declare function findGlobalStyleConflicts(): string[];
3
+ /** Warns the developer once if global CSS in the app overrides the beta typography */
4
+ export declare function warnAboutGlobalStyles(): void;
package/dist/styles.css CHANGED
@@ -141,7 +141,9 @@
141
141
  [data-color-mode=light],
142
142
  :root{
143
143
  --components-typography-basetext-contrast-text-accent:#ffffff;
144
+ --components-typography-basetext-contrast-text-subdued:#d9dae8;
144
145
  --components-typography-basetext-standard-text-accent:#181c56;
146
+ --components-typography-basetext-standard-text-subdued:#626493;
145
147
  --components-typography-blockquote-contrast-stroke:#8284ab;
146
148
  --components-typography-blockquote-contrast-text-accent:#ffffff;
147
149
  --components-typography-blockquote-contrast-text-subdued:#d9dae8;
@@ -150,23 +152,27 @@
150
152
  --components-typography-blockquote-standard-text-subdued:#626493;
151
153
  --components-typography-codetext-contrast-border:rgba(255, 255, 255, 0);
152
154
  --components-typography-codetext-contrast-border-interactive:#aeb7e2;
153
- --components-typography-codetext-contrast-fill:#f6f6f9;
155
+ --components-typography-codetext-contrast-fill:#292b6a;
154
156
  --components-typography-codetext-contrast-text:#181c56;
155
157
  --components-typography-codetext-standard-border:rgba(84, 86, 140, 0.4);
156
158
  --components-typography-codetext-standard-border-interactive:#181c56;
157
- --components-typography-codetext-standard-fill:#f6f6f9;
159
+ --components-typography-codetext-standard-fill:#eaeaf1;
158
160
  --components-typography-codetext-standard-text:#181c56;
159
161
  --components-typography-label-contrast-text-accent:#d9dae8;
160
162
  --components-typography-label-standard-text-accent:#626493;
161
163
  --components-typography-list-contrast-border:#aeb7e2;
164
+ --components-typography-list-contrast-fill:#292b6a;
162
165
  --components-typography-list-contrast-text-accent:#ffffff;
163
166
  --components-typography-list-standard-border:#aeb7e2;
167
+ --components-typography-list-standard-fill:#eaeaf1;
164
168
  --components-typography-list-standard-text-accent:#181c56;
165
169
  }
166
170
 
167
171
  [data-color-mode=dark]{
168
172
  --components-typography-basetext-contrast-text-accent:#e5e5e9;
173
+ --components-typography-basetext-contrast-text-subdued:#b3b4bd;
169
174
  --components-typography-basetext-standard-text-accent:#e5e5e9;
175
+ --components-typography-basetext-standard-text-subdued:#b3b4bd;
170
176
  --components-typography-blockquote-contrast-stroke:#81828f;
171
177
  --components-typography-blockquote-contrast-text-accent:#e5e5e9;
172
178
  --components-typography-blockquote-contrast-text-subdued:#b3b4bd;
@@ -175,17 +181,19 @@
175
181
  --components-typography-blockquote-standard-text-subdued:#b3b4bd;
176
182
  --components-typography-codetext-contrast-border:rgba(255, 255, 255, 0);
177
183
  --components-typography-codetext-contrast-border-interactive:#e5e5e9;
178
- --components-typography-codetext-contrast-fill:#393a49;
184
+ --components-typography-codetext-contrast-fill:#212233;
179
185
  --components-typography-codetext-contrast-text:#e5e5e9;
180
186
  --components-typography-codetext-standard-border:rgba(255, 255, 255, 0);
181
187
  --components-typography-codetext-standard-border-interactive:#e5e5e9;
182
- --components-typography-codetext-standard-fill:#393a49;
188
+ --components-typography-codetext-standard-fill:#212233;
183
189
  --components-typography-codetext-standard-text:#e5e5e9;
184
190
  --components-typography-label-contrast-text-accent:#e5e5e9;
185
191
  --components-typography-label-standard-text-accent:#e5e5e9;
186
192
  --components-typography-list-contrast-border:#aeb7e2;
193
+ --components-typography-list-contrast-fill:#212233;
187
194
  --components-typography-list-contrast-text-accent:#e5e5e9;
188
195
  --components-typography-list-standard-border:#aeb7e2;
196
+ --components-typography-list-standard-fill:#212233;
189
197
  --components-typography-list-standard-text-accent:#e5e5e9;
190
198
  }
191
199
 
@@ -734,7 +742,7 @@ p .eds-link--ext-icon{
734
742
 
735
743
  .eds-preformatted-text,
736
744
  .eds-code-text{
737
- background-color:#f6f6f9;
745
+ background-color:#eaeaf1;
738
746
  background-color:var(--components-typography-codetext-standard-fill);
739
747
  border:0.0625rem solid rgba(84, 86, 140, 0.4);
740
748
  border:0.0625rem solid var(--components-typography-codetext-standard-border);