@entur/typography 1.9.14 → 1.10.0-beta.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/README.md CHANGED
@@ -7,18 +7,115 @@ Entur's official font is Nationale and is created by Playtype Foundry, located i
7
7
  This package contains styles and React components for all of our typography.
8
8
 
9
9
  > 💡 Looking for the [documentation](https://linje.entur.no/komponenter/ressurser/typography)?
10
+ > Looking for the beta [documentation](https://linje.entur.no/komponenter/ressurser/typography-beta)?
10
11
 
11
12
  ## Installation
12
13
 
13
- ```sh
14
+ ```bash
14
15
  npm install @entur/typography
15
- # or if you are using Yarn:
16
+ # or
16
17
  yarn add @entur/typography
17
18
  ```
18
19
 
19
- ## Usage
20
+ ## 🚀 Quick Start
20
21
 
21
- Please refer to the [documentation](https://linje.entur.no/komponenter/ressurser/typography) for usage information.
22
+ ### Using Beta Typography (Recommended)
23
+
24
+ ```typescript
25
+ import { Heading, Text, LinkBeta } from '@entur/typography';
26
+
27
+ function MyComponent() {
28
+ return (
29
+ <div>
30
+ <Heading as="h1" variant="title-1">
31
+ My Title
32
+ </Heading>
33
+ <Text variant="paragraph">My content</Text>
34
+ <LinkBeta href="/more">Learn more</LinkBeta>
35
+ </div>
36
+ );
37
+ }
38
+ ```
39
+
40
+ ### Using Legacy Typography
41
+
42
+ ```typescript
43
+ import { Heading1, Paragraph, Link } from '@entur/typography';
44
+
45
+ function MyComponent() {
46
+ return (
47
+ <div>
48
+ <Heading1>My Title</Heading1>
49
+ <Paragraph>My content</Paragraph>
50
+ <Link href="/more">Learn more</Link>
51
+ </div>
52
+ );
53
+ }
54
+ ```
55
+
56
+ ## 🔄 Migration
57
+
58
+ **Migrating from legacy typography?** We've created a comprehensive migration package to help you transition smoothly. Follow our migration guide in our website.
59
+
60
+ - 🔧 **Migration Helpers** - Drop-in replacements for legacy components
61
+ - 🤖 **Migration Script** - Automated migration tool
62
+
63
+ ### Quick Migration
64
+
65
+ ```bash
66
+ # Option 1: Using npx (recommended)
67
+ npx @entur/typography@latest migrate
68
+
69
+ # Option 2: With specific options
70
+ npx @entur/typography@latest migrate --dry-run
71
+
72
+
73
+ # Option 3: From installed package
74
+ npm install @entur/typography@latest
75
+ npx @entur/typography@latest migrate
76
+
77
+ # Option 4: Add to your package.json scripts
78
+ # "scripts": { "migrate-typography": "npx @entur/typography@latest migrate" }
79
+ # Then run: npm run migrate-typography -- --dry-run
80
+ ```
81
+
82
+ **Note**: The migration script requires `glob` to be available. If you encounter an error, install it:
83
+
84
+ ```bash
85
+ npm install glob
86
+ # or
87
+ yarn add glob
88
+ ```
89
+
90
+ ### Migration Mode
91
+
92
+ - **🚀 Complete Migration**: Updates imports + component usage
93
+
94
+ ### Update Styles
95
+
96
+ ```scss
97
+ // Replace this
98
+ @import '@entur/typography/dist/styles.css';
99
+
100
+ // With this
101
+ @import '@entur/typography/src/beta/styles.scss';
102
+ ```
103
+
104
+ ## 🎨 Features
105
+
106
+ ### Beta Typography
107
+
108
+ - **Semantic variants** - Title, subtitle, section, paragraph, etc.
109
+ - **Size variants** - Extra large, large, medium, small, extra small
110
+ - **Weight variants** - Light, regular, medium, semibold, bold
111
+ - **Spacing options** - Configurable margins and padding
112
+ - **Accessibility** - Built-in ARIA support and semantic HTML
113
+
114
+ ### Legacy Typography
115
+
116
+ - **Individual components** - Heading1-6, Paragraph, Link, etc.
117
+ - **Simple API** - Easy to use with minimal configuration
118
+ - **Backward compatibility** - Existing code continues to work
22
119
 
23
120
  ## Licenses
24
121
 
@@ -0,0 +1,12 @@
1
+ import { default as React } from 'react';
2
+ export type BlockquotePropsBeta = {
3
+ /** Ekstra klassenavn */
4
+ className?: string;
5
+ } & React.DetailedHTMLProps<React.BlockquoteHTMLAttributes<HTMLQuoteElement>, HTMLQuoteElement>;
6
+ export declare const BlockquoteBeta: ({ className, ...rest }: BlockquotePropsBeta) => React.JSX.Element;
7
+ type BlockquoteFooterPropsBeta = {
8
+ /** Ekstra klassenavn */
9
+ className?: string;
10
+ } & React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>;
11
+ export declare const BlockquoteFooterBeta: ({ className, ...rest }: BlockquoteFooterPropsBeta) => React.JSX.Element;
12
+ export {};
@@ -0,0 +1,20 @@
1
+ import { default as React } from 'react';
2
+ import { TypographyHeadingVariant, TypographySize, TypographySpacing } from './types';
3
+ import { PolymorphicComponentProps } from '../../../utils';
4
+ type HeadingBaseProps = {
5
+ /** Visuell variant som bestemmer styling (anbefalt over size) */
6
+ variant?: TypographyHeadingVariant;
7
+ /** Visuell tekststørrelse som overstyrer variant-styling */
8
+ size?: TypographySize;
9
+ /** Innholdet som skal vises */
10
+ children: React.ReactNode;
11
+ /** Ekstra klassenavn for tilpasset styling */
12
+ className?: string;
13
+ /** Inline CSS-stiler */
14
+ style?: React.CSSProperties;
15
+ /** Spacing around the component */
16
+ spacing?: TypographySpacing;
17
+ };
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>) => React.JSX.Element;
20
+ export {};
@@ -0,0 +1,16 @@
1
+ import { default as React } from 'react';
2
+ import { PolymorphicComponentProps } from '../../../utils';
3
+ import { TypographySpacing } from './types';
4
+ type LinkBaseProps = {
5
+ external?: boolean;
6
+ /** Ekstra klassenavn */
7
+ className?: string;
8
+ /** Innholdet */
9
+ children: React.ReactNode;
10
+ /** Spacing around the component (same as Text and Heading components) */
11
+ spacing?: TypographySpacing;
12
+ ariaLabelExternalIcon?: string;
13
+ };
14
+ export type LinkPropsBeta<C extends React.ElementType> = PolymorphicComponentProps<C, LinkBaseProps>;
15
+ export declare const LinkBeta: <C extends React.ElementType = "a">({ external, ariaLabelExternalIcon, className, spacing, children, as, ...rest }: LinkPropsBeta<C>) => JSX.Element;
16
+ export {};
@@ -0,0 +1,16 @@
1
+ import { default as React } from 'react';
2
+ import { PolymorphicComponentProps } from '../../../utils';
3
+ import { TypographySpacing } from './types';
4
+ type ListItemBaseProps = {
5
+ /** Ekstra klassenavn */
6
+ className?: string;
7
+ /** Innholdet */
8
+ children: React.ReactNode;
9
+ /** Tittel */
10
+ title?: React.ReactNode;
11
+ /** Spacing around the component (same as Text and Heading components) */
12
+ spacing?: TypographySpacing;
13
+ };
14
+ export type ListItemBetaProps<C extends React.ElementType> = PolymorphicComponentProps<C, ListItemBaseProps>;
15
+ export declare const ListItemBeta: <C extends React.ElementType = "li">({ children, className, title, spacing, as, ...rest }: ListItemBetaProps<C>) => JSX.Element;
16
+ export {};
@@ -0,0 +1,16 @@
1
+ import { default as React } from 'react';
2
+ import { PolymorphicComponentProps } from '../../../utils';
3
+ import { TypographySpacing } from './types';
4
+ type NumberedListBaseProps = {
5
+ /** Ekstra klassenavn */
6
+ className?: string;
7
+ /** Innholdet */
8
+ children: React.ReactNode;
9
+ /** List type (1, A, a, I, i) */
10
+ type?: '1' | 'A' | 'a' | 'I' | 'i';
11
+ /** Spacing around the component (same as Text and Heading components) */
12
+ spacing?: TypographySpacing;
13
+ };
14
+ export type NumberedListBetaProps<C extends React.ElementType> = PolymorphicComponentProps<C, NumberedListBaseProps>;
15
+ export declare const NumberedListBeta: <C extends React.ElementType = "ol">({ className, type, spacing, as, children, ...rest }: NumberedListBetaProps<C>) => JSX.Element;
16
+ export {};
@@ -0,0 +1,20 @@
1
+ import { default as React } from 'react';
2
+ import { TypographySize, TypographyTextVariant, TypographyWeight, TypographySpacing } from './types';
3
+ import { PolymorphicComponentProps } from '../../../utils';
4
+ type TextBaseProps = {
5
+ /** 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;
11
+ /** Innhold */
12
+ children: React.ReactNode;
13
+ /** Spacing around the component */
14
+ spacing?: TypographySpacing;
15
+ /** Ekstra klassenavn */
16
+ className?: string;
17
+ };
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>) => React.JSX.Element;
20
+ export {};
@@ -0,0 +1,14 @@
1
+ import { default as React } from 'react';
2
+ import { PolymorphicComponentProps } from '../../../utils';
3
+ import { TypographySpacing } from './types';
4
+ type UnorderedListBaseProps = {
5
+ /** Ekstra klassenavn */
6
+ className?: string;
7
+ /** Innholdet */
8
+ children: React.ReactNode;
9
+ /** Spacing around the component (same as Text and Heading components) */
10
+ spacing?: TypographySpacing;
11
+ };
12
+ export type UnorderedListBetaProps<C extends React.ElementType> = PolymorphicComponentProps<C, UnorderedListBaseProps>;
13
+ export declare const UnorderedListBeta: <C extends React.ElementType = "ul">({ className, spacing, as, children, ...rest }: UnorderedListBetaProps<C>) => JSX.Element;
14
+ export {};
@@ -0,0 +1,9 @@
1
+ export { Heading } from './Heading';
2
+ export { Text } from './Text';
3
+ export { LinkBeta } from './LinkBeta';
4
+ export { BlockquoteBeta, BlockquoteFooterBeta } from './BlockquoteBeta';
5
+ export { UnorderedListBeta } from './UnorderedListBeta';
6
+ export { NumberedListBeta } from './NumberedListBeta';
7
+ export { ListItemBeta } from './ListItemBeta';
8
+ export { getHeadingVariantFromSemanticType, getSpacingClasses } from './utils';
9
+ export type { TypographyHeadingVariant, TypographyTextVariant, TypographySize, TypographyWeight, TypographySpacing, } from './types';
@@ -0,0 +1,5 @@
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';
@@ -0,0 +1,10 @@
1
+ import { TypographySpacing, TypographyTextVariant } from './types';
2
+ export declare function getHeadingVariantFromSemanticType(semanticType: string | React.ElementType): "title-1" | "title-2" | "subtitle-1" | "subtitle-2" | "paragraph";
3
+ export declare function getSemanticTypeFromTextVariant(variant?: TypographyTextVariant): React.ElementType;
4
+ /**
5
+ * Generates spacing class names for typography components
6
+ * @param spacing - The spacing value from TypographySpacing
7
+ * @param componentPrefix - The CSS class prefix (e.g., 'eds-heading', 'eds-text')
8
+ * @returns Object with class names for the spacing prop
9
+ */
10
+ export declare function getSpacingClasses(spacing: TypographySpacing | undefined, componentPrefix: string): Record<string, boolean> | undefined;
package/dist/index.d.ts CHANGED
@@ -19,3 +19,10 @@ export * from './StrongText';
19
19
  export * from './SubLabel';
20
20
  export * from './SubParagraph';
21
21
  export * from './UnorderedList';
22
+ export * from './beta/Text';
23
+ export * from './beta/Heading';
24
+ export * from './beta/BlockquoteBeta';
25
+ export * from './beta/LinkBeta';
26
+ export * from './beta/UnorderedListBeta';
27
+ export * from './beta/NumberedListBeta';
28
+ export * from './beta/ListItemBeta';