@entur/typography 1.10.0-beta.8 → 2.0.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 +37 -17
- package/dist/BaseHeading.d.ts +1 -1
- package/dist/Blockquote.d.ts +3 -4
- package/dist/CodeText.d.ts +1 -1
- package/dist/EmphasizedText.d.ts +1 -1
- package/dist/Heading1.d.ts +1 -1
- package/dist/Heading2.d.ts +1 -1
- package/dist/Heading3.d.ts +1 -1
- package/dist/Heading4.d.ts +1 -1
- package/dist/Heading5.d.ts +1 -1
- package/dist/Heading6.d.ts +1 -1
- package/dist/Label.d.ts +1 -1
- package/dist/LeadParagraph.d.ts +1 -1
- package/dist/Link.d.ts +1 -1
- package/dist/ListItem.d.ts +1 -1
- package/dist/NumberedList.d.ts +1 -1
- package/dist/Paragraph.d.ts +1 -1
- package/dist/PreformattedText.d.ts +1 -1
- package/dist/SmallText.d.ts +1 -1
- package/dist/StrongText.d.ts +1 -1
- package/dist/SubLabel.d.ts +1 -1
- package/dist/SubParagraph.d.ts +1 -1
- package/dist/UnorderedList.d.ts +1 -1
- package/dist/beta/cjs/components/Blockquote.cjs +29 -0
- package/dist/beta/cjs/components/Blockquote.cjs.map +1 -0
- package/dist/beta/cjs/components/Heading.cjs +37 -0
- package/dist/beta/cjs/components/Heading.cjs.map +1 -0
- package/dist/beta/cjs/components/Link.cjs +41 -0
- package/dist/beta/cjs/components/Link.cjs.map +1 -0
- package/dist/beta/cjs/components/ListItem.cjs +33 -0
- package/dist/beta/cjs/components/ListItem.cjs.map +1 -0
- package/dist/beta/cjs/components/NumberedList.cjs +32 -0
- package/dist/beta/cjs/components/NumberedList.cjs.map +1 -0
- package/dist/beta/cjs/components/Text.cjs +36 -0
- package/dist/beta/cjs/components/Text.cjs.map +1 -0
- package/dist/beta/cjs/components/UnorderedList.cjs +29 -0
- package/dist/beta/cjs/components/UnorderedList.cjs.map +1 -0
- package/dist/beta/cjs/index.cjs +18 -0
- package/dist/beta/cjs/index.cjs.map +1 -0
- package/dist/beta/cjs/utils/utils.cjs +77 -0
- package/dist/beta/cjs/utils/utils.cjs.map +1 -0
- package/dist/beta/esm/components/Blockquote.mjs +29 -0
- package/dist/beta/esm/components/Blockquote.mjs.map +1 -0
- package/dist/beta/esm/components/Heading.mjs +37 -0
- package/dist/beta/esm/components/Heading.mjs.map +1 -0
- package/dist/beta/esm/components/Link.mjs +41 -0
- package/dist/beta/esm/components/Link.mjs.map +1 -0
- package/dist/beta/esm/components/ListItem.mjs +33 -0
- package/dist/beta/esm/components/ListItem.mjs.map +1 -0
- package/dist/beta/esm/components/NumberedList.mjs +32 -0
- package/dist/beta/esm/components/NumberedList.mjs.map +1 -0
- package/dist/beta/esm/components/Text.mjs +36 -0
- package/dist/beta/esm/components/Text.mjs.map +1 -0
- package/dist/beta/esm/components/UnorderedList.mjs +29 -0
- package/dist/beta/esm/components/UnorderedList.mjs.map +1 -0
- package/dist/beta/esm/index.mjs +18 -0
- package/dist/beta/esm/index.mjs.map +1 -0
- package/dist/beta/esm/utils/utils.mjs +77 -0
- package/dist/beta/esm/utils/utils.mjs.map +1 -0
- package/dist/beta/styles/components/heading.css +458 -0
- package/dist/beta/styles/components/text.css +959 -0
- package/dist/beta/types/components/Blockquote.d.ts +12 -0
- package/dist/beta/{Heading.d.ts → types/components/Heading.d.ts} +2 -3
- package/dist/beta/types/components/Link.d.ts +22 -0
- package/dist/beta/types/components/ListItem.d.ts +22 -0
- package/dist/beta/types/components/NumberedList.d.ts +22 -0
- package/dist/beta/{Text.d.ts → types/components/Text.d.ts} +2 -3
- package/dist/beta/types/components/UnorderedList.d.ts +20 -0
- package/dist/beta/types/index.d.ts +8 -0
- package/dist/beta/types/utils/utils.d.ts +13 -0
- package/dist/index.d.ts +0 -5
- package/dist/styles.css +162 -820
- package/dist/typography.cjs.js +416 -0
- package/dist/typography.cjs.js.map +1 -0
- package/dist/typography.esm.js +392 -454
- package/dist/typography.esm.js.map +1 -1
- package/fonts/Entur-Nationale-Demibold.eot +0 -0
- package/fonts/Entur-Nationale-Demibold.woff +0 -0
- package/fonts/Entur-Nationale-Demibold.woff2 +0 -0
- package/fonts/Entur-Nationale-DemiboldItalic.eot +0 -0
- package/fonts/Entur-Nationale-DemiboldItalic.woff +0 -0
- package/fonts/Entur-Nationale-DemiboldItalic.woff2 +0 -0
- package/fonts/Entur-Nationale-Italic.eot +0 -0
- package/fonts/Entur-Nationale-Italic.woff +0 -0
- package/fonts/Entur-Nationale-Italic.woff2 +0 -0
- package/fonts/Entur-Nationale-Light.eot +0 -0
- package/fonts/Entur-Nationale-Light.woff +0 -0
- package/fonts/Entur-Nationale-Light.woff2 +0 -0
- package/fonts/Entur-Nationale-LightItalic.eot +0 -0
- package/fonts/Entur-Nationale-LightItalic.woff +0 -0
- package/fonts/Entur-Nationale-LightItalic.woff2 +0 -0
- package/fonts/Entur-Nationale-Medium.eot +0 -0
- package/fonts/Entur-Nationale-Medium.woff +0 -0
- package/fonts/Entur-Nationale-Medium.woff2 +0 -0
- package/fonts/Entur-Nationale-MediumItalic.eot +0 -0
- package/fonts/Entur-Nationale-MediumItalic.woff +0 -0
- package/fonts/Entur-Nationale-MediumItalic.woff2 +0 -0
- package/fonts/Entur-Nationale-Regular.eot +0 -0
- package/fonts/Entur-Nationale-Regular.woff +0 -0
- package/fonts/Entur-Nationale-Regular.woff2 +0 -0
- package/package.json +59 -19
- package/scripts/migrate-typography.js +415 -178
- package/dist/beta/BlockquoteBeta.d.ts +0 -12
- package/dist/beta/LinkBeta.d.ts +0 -16
- package/dist/beta/index.d.ts +0 -6
- package/dist/beta/utils.d.ts +0 -9
- package/dist/index.js +0 -8
- package/dist/typography.cjs.development.js +0 -508
- package/dist/typography.cjs.development.js.map +0 -1
- package/dist/typography.cjs.production.min.js +0 -2
- package/dist/typography.cjs.production.min.js.map +0 -1
- /package/dist/beta/{types.d.ts → types/types.d.ts} +0 -0
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
function getSpacingClasses(spacing, baseClass) {
|
|
4
|
+
if (!spacing) return "";
|
|
5
|
+
const spacingMap = {
|
|
6
|
+
none: `${baseClass}--spacing-none`,
|
|
7
|
+
xs2: `${baseClass}--spacing-xs2`,
|
|
8
|
+
"xs2-top": `${baseClass}--spacing-xs2-top`,
|
|
9
|
+
"xs2-bottom": `${baseClass}--spacing-xs2-bottom`,
|
|
10
|
+
xs: `${baseClass}--spacing-xs`,
|
|
11
|
+
"xs-top": `${baseClass}--spacing-xs-top`,
|
|
12
|
+
"xs-bottom": `${baseClass}--spacing-xs-bottom`,
|
|
13
|
+
sm: `${baseClass}--spacing-sm`,
|
|
14
|
+
"sm-top": `${baseClass}--spacing-sm-top`,
|
|
15
|
+
"sm-bottom": `${baseClass}--spacing-sm-bottom`,
|
|
16
|
+
md: `${baseClass}--spacing-md`,
|
|
17
|
+
"md-top": `${baseClass}--spacing-md-top`,
|
|
18
|
+
"md-bottom": `${baseClass}--spacing-md-bottom`,
|
|
19
|
+
lg: `${baseClass}--spacing-lg`,
|
|
20
|
+
"lg-top": `${baseClass}--spacing-lg-top`,
|
|
21
|
+
"lg-bottom": `${baseClass}--spacing-lg-bottom`,
|
|
22
|
+
xl: `${baseClass}--spacing-xl`,
|
|
23
|
+
"xl-top": `${baseClass}--spacing-xl-top`,
|
|
24
|
+
"xl-bottom": `${baseClass}--spacing-xl-bottom`
|
|
25
|
+
};
|
|
26
|
+
return spacingMap[spacing] || "";
|
|
27
|
+
}
|
|
28
|
+
function getHeadingVariantFromSemanticType(element) {
|
|
29
|
+
const elementStr = typeof element === "string" ? element : element.toString();
|
|
30
|
+
switch (elementStr.toLowerCase()) {
|
|
31
|
+
case "h1":
|
|
32
|
+
return "title-1";
|
|
33
|
+
case "h2":
|
|
34
|
+
return "title-2";
|
|
35
|
+
case "h3":
|
|
36
|
+
return "subtitle-1";
|
|
37
|
+
case "h4":
|
|
38
|
+
return "subtitle-2";
|
|
39
|
+
case "h5":
|
|
40
|
+
return "section-1";
|
|
41
|
+
case "h6":
|
|
42
|
+
return "section-2";
|
|
43
|
+
default:
|
|
44
|
+
return "title-1";
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
function getSemanticTypeFromTextVariant(variant) {
|
|
48
|
+
if (!variant) return "p";
|
|
49
|
+
switch (variant) {
|
|
50
|
+
case "label":
|
|
51
|
+
return "label";
|
|
52
|
+
case "sublabel":
|
|
53
|
+
return "span";
|
|
54
|
+
case "caption":
|
|
55
|
+
return "span";
|
|
56
|
+
case "overline":
|
|
57
|
+
return "span";
|
|
58
|
+
case "link":
|
|
59
|
+
return "a";
|
|
60
|
+
case "code-text":
|
|
61
|
+
return "code";
|
|
62
|
+
case "preformatted-text":
|
|
63
|
+
return "pre";
|
|
64
|
+
case "quote":
|
|
65
|
+
return "blockquote";
|
|
66
|
+
case "leading":
|
|
67
|
+
case "paragraph":
|
|
68
|
+
case "subparagraph":
|
|
69
|
+
case "emphasized":
|
|
70
|
+
default:
|
|
71
|
+
return "p";
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
exports.getHeadingVariantFromSemanticType = getHeadingVariantFromSemanticType;
|
|
75
|
+
exports.getSemanticTypeFromTextVariant = getSemanticTypeFromTextVariant;
|
|
76
|
+
exports.getSpacingClasses = getSpacingClasses;
|
|
77
|
+
//# sourceMappingURL=utils.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.cjs","sources":["../../../../src/beta/utils/utils.ts"],"sourcesContent":["import {\n TypographySpacing,\n TypographyHeadingVariant,\n TypographyTextVariant,\n} from '../types';\n\n/**\n * Get spacing classes for a component\n */\nexport function getSpacingClasses(\n spacing: TypographySpacing | undefined,\n baseClass: string,\n): string {\n if (!spacing) return '';\n\n const spacingMap: Record<string, string> = {\n none: `${baseClass}--spacing-none`,\n xs2: `${baseClass}--spacing-xs2`,\n 'xs2-top': `${baseClass}--spacing-xs2-top`,\n 'xs2-bottom': `${baseClass}--spacing-xs2-bottom`,\n xs: `${baseClass}--spacing-xs`,\n 'xs-top': `${baseClass}--spacing-xs-top`,\n 'xs-bottom': `${baseClass}--spacing-xs-bottom`,\n sm: `${baseClass}--spacing-sm`,\n 'sm-top': `${baseClass}--spacing-sm-top`,\n 'sm-bottom': `${baseClass}--spacing-sm-bottom`,\n md: `${baseClass}--spacing-md`,\n 'md-top': `${baseClass}--spacing-md-top`,\n 'md-bottom': `${baseClass}--spacing-md-bottom`,\n lg: `${baseClass}--spacing-lg`,\n 'lg-top': `${baseClass}--spacing-lg-top`,\n 'lg-bottom': `${baseClass}--spacing-lg-bottom`,\n xl: `${baseClass}--spacing-xl`,\n 'xl-top': `${baseClass}--spacing-xl-top`,\n 'xl-bottom': `${baseClass}--spacing-xl-bottom`,\n };\n\n return spacingMap[spacing] || '';\n}\n\n/**\n * Get heading variant based on semantic HTML element\n */\nexport function getHeadingVariantFromSemanticType(\n element: string | React.ElementType,\n): TypographyHeadingVariant {\n const elementStr = typeof element === 'string' ? element : element.toString();\n\n switch (elementStr.toLowerCase()) {\n case 'h1':\n return 'title-1';\n case 'h2':\n return 'title-2';\n case 'h3':\n return 'subtitle-1';\n case 'h4':\n return 'subtitle-2';\n case 'h5':\n return 'section-1';\n case 'h6':\n return 'section-2';\n default:\n return 'title-1';\n }\n}\n\n/**\n * Get semantic HTML element from text variant\n */\nexport function getSemanticTypeFromTextVariant(\n variant: TypographyTextVariant | undefined,\n): string {\n if (!variant) return 'p';\n\n switch (variant) {\n case 'label':\n return 'label';\n case 'sublabel':\n return 'span';\n case 'caption':\n return 'span';\n case 'overline':\n return 'span';\n case 'link':\n return 'a';\n case 'code-text':\n return 'code';\n case 'preformatted-text':\n return 'pre';\n case 'quote':\n return 'blockquote';\n case 'leading':\n case 'paragraph':\n case 'subparagraph':\n case 'emphasized':\n default:\n return 'p';\n }\n}\n"],"names":[],"mappings":";;AASO,SAAS,kBACd,SACA,WACQ;AACR,MAAI,CAAC,QAAS,QAAO;AAErB,QAAM,aAAqC;AAAA,IACzC,MAAM,GAAG,SAAS;AAAA,IAClB,KAAK,GAAG,SAAS;AAAA,IACjB,WAAW,GAAG,SAAS;AAAA,IACvB,cAAc,GAAG,SAAS;AAAA,IAC1B,IAAI,GAAG,SAAS;AAAA,IAChB,UAAU,GAAG,SAAS;AAAA,IACtB,aAAa,GAAG,SAAS;AAAA,IACzB,IAAI,GAAG,SAAS;AAAA,IAChB,UAAU,GAAG,SAAS;AAAA,IACtB,aAAa,GAAG,SAAS;AAAA,IACzB,IAAI,GAAG,SAAS;AAAA,IAChB,UAAU,GAAG,SAAS;AAAA,IACtB,aAAa,GAAG,SAAS;AAAA,IACzB,IAAI,GAAG,SAAS;AAAA,IAChB,UAAU,GAAG,SAAS;AAAA,IACtB,aAAa,GAAG,SAAS;AAAA,IACzB,IAAI,GAAG,SAAS;AAAA,IAChB,UAAU,GAAG,SAAS;AAAA,IACtB,aAAa,GAAG,SAAS;AAAA,EAAA;AAG3B,SAAO,WAAW,OAAO,KAAK;AAChC;AAKO,SAAS,kCACd,SAC0B;AAC1B,QAAM,aAAa,OAAO,YAAY,WAAW,UAAU,QAAQ,SAAA;AAEnE,UAAQ,WAAW,eAAY;AAAA,IAC7B,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AACH,aAAO;AAAA,IACT;AACE,aAAO;AAAA,EAAA;AAEb;AAKO,SAAS,+BACd,SACQ;AACR,MAAI,CAAC,QAAS,QAAO;AAErB,UAAQ,SAAA;AAAA,IACN,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AAAA,IACL;AACE,aAAO;AAAA,EAAA;AAEb;;;;"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import classNames from "classnames";
|
|
3
|
+
import '../../styles/components/text.css';/* empty css */
|
|
4
|
+
const Blockquote = ({ className, ...rest }) => {
|
|
5
|
+
return /* @__PURE__ */ jsx(
|
|
6
|
+
"blockquote",
|
|
7
|
+
{
|
|
8
|
+
className: classNames("eds-text--blockquote", className),
|
|
9
|
+
...rest
|
|
10
|
+
}
|
|
11
|
+
);
|
|
12
|
+
};
|
|
13
|
+
const BlockquoteFooter = ({
|
|
14
|
+
className,
|
|
15
|
+
...rest
|
|
16
|
+
}) => {
|
|
17
|
+
return /* @__PURE__ */ jsx(
|
|
18
|
+
"footer",
|
|
19
|
+
{
|
|
20
|
+
className: classNames("eds-text--blockquote__footer", className),
|
|
21
|
+
...rest
|
|
22
|
+
}
|
|
23
|
+
);
|
|
24
|
+
};
|
|
25
|
+
export {
|
|
26
|
+
Blockquote,
|
|
27
|
+
BlockquoteFooter
|
|
28
|
+
};
|
|
29
|
+
//# sourceMappingURL=Blockquote.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Blockquote.mjs","sources":["../../../../src/beta/components/Blockquote.tsx"],"sourcesContent":["import React from 'react';\nimport classNames from 'classnames';\n\nimport './text.scss';\n\nexport type BlockquoteProps = {\n /** Ekstra klassenavn */\n className?: string;\n} & React.DetailedHTMLProps<\n React.BlockquoteHTMLAttributes<HTMLQuoteElement>,\n HTMLQuoteElement\n>;\n\nexport const Blockquote = ({ className, ...rest }: BlockquoteProps) => {\n return (\n <blockquote\n className={classNames('eds-text--blockquote', className)}\n {...rest}\n />\n );\n};\n\ntype BlockquoteFooterProps = {\n /** Ekstra klassenavn */\n className?: string;\n} & React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>;\n\nexport const BlockquoteFooter = ({\n className,\n ...rest\n}: BlockquoteFooterProps) => {\n return (\n <footer\n className={classNames('eds-text--blockquote__footer', className)}\n {...rest}\n />\n );\n};\n"],"names":[],"mappings":";;;AAaO,MAAM,aAAa,CAAC,EAAE,WAAW,GAAG,WAA4B;AACrE,SACE;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,WAAW,WAAW,wBAAwB,SAAS;AAAA,MACtD,GAAG;AAAA,IAAA;AAAA,EAAA;AAGV;AAOO,MAAM,mBAAmB,CAAC;AAAA,EAC/B;AAAA,EACA,GAAG;AACL,MAA6B;AAC3B,SACE;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,WAAW,WAAW,gCAAgC,SAAS;AAAA,MAC9D,GAAG;AAAA,IAAA;AAAA,EAAA;AAGV;"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import classNames from "classnames";
|
|
3
|
+
import { getHeadingVariantFromSemanticType, getSpacingClasses } from "../utils/utils.mjs";
|
|
4
|
+
import '../../styles/components/heading.css';/* empty css */
|
|
5
|
+
const Heading = ({
|
|
6
|
+
children,
|
|
7
|
+
as,
|
|
8
|
+
size,
|
|
9
|
+
variant,
|
|
10
|
+
spacing,
|
|
11
|
+
className,
|
|
12
|
+
...rest
|
|
13
|
+
}) => {
|
|
14
|
+
const HeadingElement = as || "h1";
|
|
15
|
+
const usedVariant = variant ?? getHeadingVariantFromSemanticType(HeadingElement);
|
|
16
|
+
const shouldUseSize = size !== void 0;
|
|
17
|
+
return /* @__PURE__ */ jsx(
|
|
18
|
+
HeadingElement,
|
|
19
|
+
{
|
|
20
|
+
className: classNames(
|
|
21
|
+
"eds-heading",
|
|
22
|
+
// Only apply variant if size is not specified
|
|
23
|
+
{ [`eds-heading--${usedVariant}`]: !shouldUseSize },
|
|
24
|
+
// Size takes precedence when specified
|
|
25
|
+
{ [`eds-heading--${size}`]: shouldUseSize && size },
|
|
26
|
+
getSpacingClasses(spacing, "eds-heading"),
|
|
27
|
+
className
|
|
28
|
+
),
|
|
29
|
+
...rest,
|
|
30
|
+
children
|
|
31
|
+
}
|
|
32
|
+
);
|
|
33
|
+
};
|
|
34
|
+
export {
|
|
35
|
+
Heading
|
|
36
|
+
};
|
|
37
|
+
//# sourceMappingURL=Heading.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Heading.mjs","sources":["../../../../src/beta/components/Heading.tsx"],"sourcesContent":["import React from 'react';\n\nimport classNames from 'classnames';\nimport {\n TypographyHeadingVariant,\n TypographySize,\n TypographySpacing,\n} from '../types';\nimport {\n getHeadingVariantFromSemanticType,\n getSpacingClasses,\n} from '../utils/utils';\nimport { PolymorphicComponentProps } from '@entur/utils';\n\nimport './heading.scss';\n\ntype HeadingBaseProps = {\n /** Visuell variant som bestemmer styling (anbefalt over size) */\n variant?: TypographyHeadingVariant;\n /** Visuell tekststørrelse som overstyrer variant-styling */\n size?: TypographySize;\n /** Innholdet som skal vises */\n children: React.ReactNode;\n /** Ekstra klassenavn for tilpasset styling */\n className?: string;\n /** Inline CSS-stiler */\n style?: React.CSSProperties;\n /** Spacing around the component */\n spacing?: TypographySpacing;\n};\n\nexport type HeadingProps<C extends React.ElementType> =\n PolymorphicComponentProps<C, HeadingBaseProps>;\n\nexport const Heading = <C extends React.ElementType = 'h1'>({\n children,\n as,\n size,\n variant,\n spacing,\n className,\n ...rest\n}: HeadingProps<C>) => {\n const HeadingElement = as || 'h1';\n\n // Function to determine the variant based on the semantic type\n const usedVariant =\n variant ?? getHeadingVariantFromSemanticType(HeadingElement);\n\n // When size is explicitly provided, it should override variant styling\n const shouldUseSize = size !== undefined;\n\n return (\n <HeadingElement\n className={classNames(\n 'eds-heading',\n // Only apply variant if size is not specified\n { [`eds-heading--${usedVariant}`]: !shouldUseSize },\n // Size takes precedence when specified\n { [`eds-heading--${size}`]: shouldUseSize && size },\n getSpacingClasses(spacing, 'eds-heading'),\n className,\n )}\n {...rest}\n >\n {children}\n </HeadingElement>\n );\n};\n"],"names":[],"mappings":";;;;AAkCO,MAAM,UAAU,CAAqC;AAAA,EAC1D;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG;AACL,MAAuB;AACrB,QAAM,iBAAiB,MAAM;AAG7B,QAAM,cACJ,WAAW,kCAAkC,cAAc;AAG7D,QAAM,gBAAgB,SAAS;AAE/B,SACE;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,WAAW;AAAA,QACT;AAAA;AAAA,QAEA,EAAE,CAAC,gBAAgB,WAAW,EAAE,GAAG,CAAC,cAAA;AAAA;AAAA,QAEpC,EAAE,CAAC,gBAAgB,IAAI,EAAE,GAAG,iBAAiB,KAAA;AAAA,QAC7C,kBAAkB,SAAS,aAAa;AAAA,QACxC;AAAA,MAAA;AAAA,MAED,GAAG;AAAA,MAEH;AAAA,IAAA;AAAA,EAAA;AAGP;"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { jsxs, jsx } from "react/jsx-runtime";
|
|
2
|
+
import classNames from "classnames";
|
|
3
|
+
import { ExternalIcon } from "@entur/icons";
|
|
4
|
+
import { getSpacingClasses } from "../utils/utils.mjs";
|
|
5
|
+
import '../../styles/components/text.css';/* empty css */
|
|
6
|
+
const Link = ({
|
|
7
|
+
external = false,
|
|
8
|
+
ariaLabelExternalIcon = "(ekstern lenke)",
|
|
9
|
+
className,
|
|
10
|
+
spacing,
|
|
11
|
+
children,
|
|
12
|
+
as,
|
|
13
|
+
...rest
|
|
14
|
+
}) => {
|
|
15
|
+
const LinkElement = as || "a";
|
|
16
|
+
return /* @__PURE__ */ jsxs(
|
|
17
|
+
LinkElement,
|
|
18
|
+
{
|
|
19
|
+
className: classNames(
|
|
20
|
+
"eds-text--link",
|
|
21
|
+
getSpacingClasses(spacing, "eds-text--link"),
|
|
22
|
+
className
|
|
23
|
+
),
|
|
24
|
+
...rest,
|
|
25
|
+
children: [
|
|
26
|
+
children,
|
|
27
|
+
external ? /* @__PURE__ */ jsx(
|
|
28
|
+
ExternalIcon,
|
|
29
|
+
{
|
|
30
|
+
className: "eds-text--link--ext-icon",
|
|
31
|
+
"aria-label": ariaLabelExternalIcon
|
|
32
|
+
}
|
|
33
|
+
) : null
|
|
34
|
+
]
|
|
35
|
+
}
|
|
36
|
+
);
|
|
37
|
+
};
|
|
38
|
+
export {
|
|
39
|
+
Link
|
|
40
|
+
};
|
|
41
|
+
//# sourceMappingURL=Link.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Link.mjs","sources":["../../../../src/beta/components/Link.tsx"],"sourcesContent":["import React from 'react';\nimport classNames from 'classnames';\nimport { PolymorphicComponentProps } from '@entur/utils';\nimport { ExternalIcon } from '@entur/icons';\nimport { TypographySpacing } from '../types';\nimport { getSpacingClasses } from '../utils/utils';\n\nimport './text.scss';\n\n/**\n * @beta Experimental component - may have breaking changes in future releases\n */\ntype LinkBaseProps = {\n external?: boolean;\n\n /** Ekstra klassenavn */\n className?: string;\n /** Innholdet */\n children: React.ReactNode;\n /** Spacing around the component (same as Text and Heading components) */\n spacing?: TypographySpacing;\n ariaLabelExternalIcon?: string;\n};\n\nexport type LinkProps<C extends React.ElementType> = PolymorphicComponentProps<\n C,\n LinkBaseProps\n>;\n\n/**\n * @beta Experimental component - may have breaking changes in future releases\n */\nexport const Link = <C extends React.ElementType = 'a'>({\n external = false,\n ariaLabelExternalIcon = '(ekstern lenke)',\n className,\n spacing,\n children,\n as,\n ...rest\n}: LinkProps<C>): JSX.Element => {\n const LinkElement: React.ElementType = as || 'a';\n return (\n <LinkElement\n className={classNames(\n 'eds-text--link',\n getSpacingClasses(spacing, 'eds-text--link'),\n className,\n )}\n {...rest}\n >\n {children}\n {external ? (\n <ExternalIcon\n className=\"eds-text--link--ext-icon\"\n aria-label={ariaLabelExternalIcon}\n />\n ) : null}\n </LinkElement>\n );\n};\n"],"names":[],"mappings":";;;;;AAgCO,MAAM,OAAO,CAAoC;AAAA,EACtD,WAAW;AAAA,EACX,wBAAwB;AAAA,EACxB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG;AACL,MAAiC;AAC/B,QAAM,cAAiC,MAAM;AAC7C,SACE;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,WAAW;AAAA,QACT;AAAA,QACA,kBAAkB,SAAS,gBAAgB;AAAA,QAC3C;AAAA,MAAA;AAAA,MAED,GAAG;AAAA,MAEH,UAAA;AAAA,QAAA;AAAA,QACA,WACC;AAAA,UAAC;AAAA,UAAA;AAAA,YACC,WAAU;AAAA,YACV,cAAY;AAAA,UAAA;AAAA,QAAA,IAEZ;AAAA,MAAA;AAAA,IAAA;AAAA,EAAA;AAGV;"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { jsxs, jsx } from "react/jsx-runtime";
|
|
2
|
+
import classNames from "classnames";
|
|
3
|
+
import { getSpacingClasses } from "../utils/utils.mjs";
|
|
4
|
+
import '../../styles/components/text.css';/* empty css */
|
|
5
|
+
const ListItem = ({
|
|
6
|
+
children,
|
|
7
|
+
className,
|
|
8
|
+
title,
|
|
9
|
+
spacing,
|
|
10
|
+
as,
|
|
11
|
+
...rest
|
|
12
|
+
}) => {
|
|
13
|
+
const ItemElement = as || "li";
|
|
14
|
+
return /* @__PURE__ */ jsxs(
|
|
15
|
+
ItemElement,
|
|
16
|
+
{
|
|
17
|
+
className: classNames(
|
|
18
|
+
"eds-text--list-item",
|
|
19
|
+
getSpacingClasses(spacing, "eds-text--list-item"),
|
|
20
|
+
className
|
|
21
|
+
),
|
|
22
|
+
...rest,
|
|
23
|
+
children: [
|
|
24
|
+
title && /* @__PURE__ */ jsx("span", { className: "eds-text--list-item__title eds-text--weight-bold", children: title }),
|
|
25
|
+
children
|
|
26
|
+
]
|
|
27
|
+
}
|
|
28
|
+
);
|
|
29
|
+
};
|
|
30
|
+
export {
|
|
31
|
+
ListItem
|
|
32
|
+
};
|
|
33
|
+
//# sourceMappingURL=ListItem.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ListItem.mjs","sources":["../../../../src/beta/components/ListItem.tsx"],"sourcesContent":["import React from 'react';\nimport classNames from 'classnames';\nimport { PolymorphicComponentProps } from '@entur/utils';\nimport { TypographySpacing } from '../types';\nimport { getSpacingClasses } from '../utils/utils';\n\nimport './text.scss';\n\n/**\n * @beta Experimental component - may have breaking changes in future releases\n */\ntype ListItemBaseProps = {\n /** Ekstra klassenavn */\n className?: string;\n /** Innholdet */\n children: React.ReactNode;\n /** Tittel */\n title?: React.ReactNode;\n /** Spacing around the component (same as Text and Heading components) */\n spacing?: TypographySpacing;\n};\n\nexport type ListItemProps<C extends React.ElementType> =\n PolymorphicComponentProps<C, ListItemBaseProps>;\n\n/**\n * @beta Experimental component - may have breaking changes in future releases\n */\nexport const ListItem = <C extends React.ElementType = 'li'>({\n children,\n className,\n title,\n spacing,\n as,\n ...rest\n}: ListItemProps<C>): JSX.Element => {\n const ItemElement: React.ElementType = as || 'li';\n\n return (\n <ItemElement\n className={classNames(\n 'eds-text--list-item',\n getSpacingClasses(spacing, 'eds-text--list-item'),\n className,\n )}\n {...rest}\n >\n {title && (\n <span className=\"eds-text--list-item__title eds-text--weight-bold\">\n {title}\n </span>\n )}\n {children}\n </ItemElement>\n );\n};\n"],"names":[],"mappings":";;;;AA4BO,MAAM,WAAW,CAAqC;AAAA,EAC3D;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG;AACL,MAAqC;AACnC,QAAM,cAAiC,MAAM;AAE7C,SACE;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,WAAW;AAAA,QACT;AAAA,QACA,kBAAkB,SAAS,qBAAqB;AAAA,QAChD;AAAA,MAAA;AAAA,MAED,GAAG;AAAA,MAEH,UAAA;AAAA,QAAA,SACC,oBAAC,QAAA,EAAK,WAAU,oDACb,UAAA,OACH;AAAA,QAED;AAAA,MAAA;AAAA,IAAA;AAAA,EAAA;AAGP;"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import classNames from "classnames";
|
|
3
|
+
import { getSpacingClasses } from "../utils/utils.mjs";
|
|
4
|
+
import '../../styles/components/text.css';/* empty css */
|
|
5
|
+
const NumberedList = ({
|
|
6
|
+
className,
|
|
7
|
+
type = "1",
|
|
8
|
+
spacing,
|
|
9
|
+
as,
|
|
10
|
+
children,
|
|
11
|
+
...rest
|
|
12
|
+
}) => {
|
|
13
|
+
const ListElement = as || "ol";
|
|
14
|
+
return /* @__PURE__ */ jsx(
|
|
15
|
+
ListElement,
|
|
16
|
+
{
|
|
17
|
+
className: classNames(
|
|
18
|
+
"eds-text--numbered-list",
|
|
19
|
+
{ [`eds-text--numbered-list--type-${type}`]: type },
|
|
20
|
+
getSpacingClasses(spacing, "eds-text--numbered-list"),
|
|
21
|
+
className
|
|
22
|
+
),
|
|
23
|
+
type,
|
|
24
|
+
...rest,
|
|
25
|
+
children
|
|
26
|
+
}
|
|
27
|
+
);
|
|
28
|
+
};
|
|
29
|
+
export {
|
|
30
|
+
NumberedList
|
|
31
|
+
};
|
|
32
|
+
//# sourceMappingURL=NumberedList.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NumberedList.mjs","sources":["../../../../src/beta/components/NumberedList.tsx"],"sourcesContent":["import React from 'react';\nimport classNames from 'classnames';\nimport { PolymorphicComponentProps } from '@entur/utils';\nimport { TypographySpacing } from '../types';\nimport { getSpacingClasses } from '../utils/utils';\n\nimport './text.scss';\n\n/**\n * @beta Experimental component - may have breaking changes in future releases\n */\ntype NumberedListBaseProps = {\n /** Ekstra klassenavn */\n className?: string;\n /** Innholdet */\n children: React.ReactNode;\n /** List type (1, A, a, I, i) */\n type?: '1' | 'A' | 'a' | 'I' | 'i';\n /** Spacing around the component (same as Text and Heading components) */\n spacing?: TypographySpacing;\n};\n\nexport type NumberedListProps<C extends React.ElementType> =\n PolymorphicComponentProps<C, NumberedListBaseProps>;\n\n/**\n * @beta Experimental component - may have breaking changes in future releases\n */\nexport const NumberedList = <C extends React.ElementType = 'ol'>({\n className,\n type = '1',\n spacing,\n as,\n children,\n ...rest\n}: NumberedListProps<C>): JSX.Element => {\n const ListElement: React.ElementType = as || 'ol';\n\n return (\n <ListElement\n className={classNames(\n 'eds-text--numbered-list',\n { [`eds-text--numbered-list--type-${type}`]: type },\n getSpacingClasses(spacing, 'eds-text--numbered-list'),\n className,\n )}\n type={type}\n {...rest}\n >\n {children}\n </ListElement>\n );\n};\n"],"names":[],"mappings":";;;;AA4BO,MAAM,eAAe,CAAqC;AAAA,EAC/D;AAAA,EACA,OAAO;AAAA,EACP;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG;AACL,MAAyC;AACvC,QAAM,cAAiC,MAAM;AAE7C,SACE;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,WAAW;AAAA,QACT;AAAA,QACA,EAAE,CAAC,iCAAiC,IAAI,EAAE,GAAG,KAAA;AAAA,QAC7C,kBAAkB,SAAS,yBAAyB;AAAA,QACpD;AAAA,MAAA;AAAA,MAEF;AAAA,MACC,GAAG;AAAA,MAEH;AAAA,IAAA;AAAA,EAAA;AAGP;"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import classNames from "classnames";
|
|
3
|
+
import { getSemanticTypeFromTextVariant, getSpacingClasses } from "../utils/utils.mjs";
|
|
4
|
+
import '../../styles/components/text.css';/* empty css */
|
|
5
|
+
const TypographyText = ({
|
|
6
|
+
children,
|
|
7
|
+
as,
|
|
8
|
+
size,
|
|
9
|
+
variant,
|
|
10
|
+
weight = "medium",
|
|
11
|
+
spacing,
|
|
12
|
+
className,
|
|
13
|
+
...rest
|
|
14
|
+
}) => {
|
|
15
|
+
const BodyElement = as || getSemanticTypeFromTextVariant(variant);
|
|
16
|
+
return /* @__PURE__ */ jsx(
|
|
17
|
+
BodyElement,
|
|
18
|
+
{
|
|
19
|
+
className: classNames(
|
|
20
|
+
"eds-text",
|
|
21
|
+
variant && `eds-text--${variant}`,
|
|
22
|
+
size && `eds-text--${size}`,
|
|
23
|
+
weight && `eds-text--weight-${weight}`,
|
|
24
|
+
getSpacingClasses(spacing, "eds-text"),
|
|
25
|
+
className
|
|
26
|
+
),
|
|
27
|
+
...rest,
|
|
28
|
+
children
|
|
29
|
+
}
|
|
30
|
+
);
|
|
31
|
+
};
|
|
32
|
+
const Text = TypographyText;
|
|
33
|
+
export {
|
|
34
|
+
Text
|
|
35
|
+
};
|
|
36
|
+
//# sourceMappingURL=Text.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Text.mjs","sources":["../../../../src/beta/components/Text.tsx"],"sourcesContent":["import React from 'react';\n\nimport classNames from 'classnames';\n\nimport { PolymorphicComponentProps } from '@entur/utils';\n\nimport {\n getSpacingClasses,\n getSemanticTypeFromTextVariant,\n} from '../utils/utils';\n\nimport {\n TypographySize,\n TypographyTextVariant,\n TypographyWeight,\n TypographySpacing,\n} from '../types';\n\nimport './text.scss';\n\ntype TextBaseProps = {\n /** Visuell tekststørrelse (typografi-token) */\n size?: TypographySize;\n /** Fontvekt */\n weight?: TypographyWeight;\n /** Variant (kan brukes til spesielle typer tekst som for eksempel caption) */\n variant?: TypographyTextVariant;\n /** Innhold */\n children: React.ReactNode;\n /** Spacing around the component */\n spacing?: TypographySpacing;\n /** Ekstra klassenavn */\n className?: string;\n};\n\nexport type TextProps<C extends React.ElementType> = PolymorphicComponentProps<\n C,\n TextBaseProps\n>;\n\nconst TypographyText = <C extends React.ElementType = 'p'>({\n children,\n as,\n size,\n variant,\n weight = 'medium',\n spacing,\n className,\n ...rest\n}: TextProps<C>) => {\n const BodyElement = as || getSemanticTypeFromTextVariant(variant);\n\n return (\n <BodyElement\n className={classNames(\n 'eds-text',\n variant && `eds-text--${variant}`,\n size && `eds-text--${size}`,\n weight && `eds-text--weight-${weight}`,\n getSpacingClasses(spacing, 'eds-text'),\n className,\n )}\n {...rest}\n >\n {children}\n </BodyElement>\n );\n};\n\n// Export as Text to avoid DOM conflicts\nexport const Text = TypographyText;\n"],"names":[],"mappings":";;;;AAwCA,MAAM,iBAAiB,CAAoC;AAAA,EACzD;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,SAAS;AAAA,EACT;AAAA,EACA;AAAA,EACA,GAAG;AACL,MAAoB;AAClB,QAAM,cAAc,MAAM,+BAA+B,OAAO;AAEhE,SACE;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,WAAW;AAAA,QACT;AAAA,QACA,WAAW,aAAa,OAAO;AAAA,QAC/B,QAAQ,aAAa,IAAI;AAAA,QACzB,UAAU,oBAAoB,MAAM;AAAA,QACpC,kBAAkB,SAAS,UAAU;AAAA,QACrC;AAAA,MAAA;AAAA,MAED,GAAG;AAAA,MAEH;AAAA,IAAA;AAAA,EAAA;AAGP;AAGO,MAAM,OAAO;"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import classNames from "classnames";
|
|
3
|
+
import { getSpacingClasses } from "../utils/utils.mjs";
|
|
4
|
+
import '../../styles/components/text.css';/* empty css */
|
|
5
|
+
const UnorderedList = ({
|
|
6
|
+
className,
|
|
7
|
+
spacing,
|
|
8
|
+
as,
|
|
9
|
+
children,
|
|
10
|
+
...rest
|
|
11
|
+
}) => {
|
|
12
|
+
const ListElement = as || "ul";
|
|
13
|
+
return /* @__PURE__ */ jsx(
|
|
14
|
+
ListElement,
|
|
15
|
+
{
|
|
16
|
+
className: classNames(
|
|
17
|
+
"eds-text--unordered-list",
|
|
18
|
+
getSpacingClasses(spacing, "eds-text--unordered-list"),
|
|
19
|
+
className
|
|
20
|
+
),
|
|
21
|
+
...rest,
|
|
22
|
+
children
|
|
23
|
+
}
|
|
24
|
+
);
|
|
25
|
+
};
|
|
26
|
+
export {
|
|
27
|
+
UnorderedList
|
|
28
|
+
};
|
|
29
|
+
//# sourceMappingURL=UnorderedList.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"UnorderedList.mjs","sources":["../../../../src/beta/components/UnorderedList.tsx"],"sourcesContent":["import React from 'react';\nimport classNames from 'classnames';\nimport { PolymorphicComponentProps } from '@entur/utils';\nimport { TypographySpacing } from '../types';\nimport { getSpacingClasses } from '../utils/utils';\n\nimport './text.scss';\n\n/**\n * @beta Experimental component - may have breaking changes in future releases\n */\ntype UnorderedListBaseProps = {\n /** Ekstra klassenavn */\n className?: string;\n /** Innholdet */\n children: React.ReactNode;\n /** Spacing around the component (same as Text and Heading components) */\n spacing?: TypographySpacing;\n};\n\nexport type UnorderedListProps<C extends React.ElementType> =\n PolymorphicComponentProps<C, UnorderedListBaseProps>;\n\n/**\n * @beta Experimental component - may have breaking changes in future releases\n */\nexport const UnorderedList = <C extends React.ElementType = 'ul'>({\n className,\n spacing,\n as,\n children,\n ...rest\n}: UnorderedListProps<C>): JSX.Element => {\n const ListElement: React.ElementType = as || 'ul';\n\n return (\n <ListElement\n className={classNames(\n 'eds-text--unordered-list',\n getSpacingClasses(spacing, 'eds-text--unordered-list'),\n className,\n )}\n {...rest}\n >\n {children}\n </ListElement>\n );\n};\n"],"names":[],"mappings":";;;;AA0BO,MAAM,gBAAgB,CAAqC;AAAA,EAChE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG;AACL,MAA0C;AACxC,QAAM,cAAiC,MAAM;AAE7C,SACE;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,WAAW;AAAA,QACT;AAAA,QACA,kBAAkB,SAAS,0BAA0B;AAAA,QACrD;AAAA,MAAA;AAAA,MAED,GAAG;AAAA,MAEH;AAAA,IAAA;AAAA,EAAA;AAGP;"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Heading } from "./components/Heading.mjs";
|
|
2
|
+
import { Text } from "./components/Text.mjs";
|
|
3
|
+
import { Link } from "./components/Link.mjs";
|
|
4
|
+
import { Blockquote, BlockquoteFooter } from "./components/Blockquote.mjs";
|
|
5
|
+
import { UnorderedList } from "./components/UnorderedList.mjs";
|
|
6
|
+
import { NumberedList } from "./components/NumberedList.mjs";
|
|
7
|
+
import { ListItem } from "./components/ListItem.mjs";
|
|
8
|
+
export {
|
|
9
|
+
Blockquote,
|
|
10
|
+
BlockquoteFooter,
|
|
11
|
+
Heading,
|
|
12
|
+
Link,
|
|
13
|
+
ListItem,
|
|
14
|
+
NumberedList,
|
|
15
|
+
Text,
|
|
16
|
+
UnorderedList
|
|
17
|
+
};
|
|
18
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;"}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
function getSpacingClasses(spacing, baseClass) {
|
|
2
|
+
if (!spacing) return "";
|
|
3
|
+
const spacingMap = {
|
|
4
|
+
none: `${baseClass}--spacing-none`,
|
|
5
|
+
xs2: `${baseClass}--spacing-xs2`,
|
|
6
|
+
"xs2-top": `${baseClass}--spacing-xs2-top`,
|
|
7
|
+
"xs2-bottom": `${baseClass}--spacing-xs2-bottom`,
|
|
8
|
+
xs: `${baseClass}--spacing-xs`,
|
|
9
|
+
"xs-top": `${baseClass}--spacing-xs-top`,
|
|
10
|
+
"xs-bottom": `${baseClass}--spacing-xs-bottom`,
|
|
11
|
+
sm: `${baseClass}--spacing-sm`,
|
|
12
|
+
"sm-top": `${baseClass}--spacing-sm-top`,
|
|
13
|
+
"sm-bottom": `${baseClass}--spacing-sm-bottom`,
|
|
14
|
+
md: `${baseClass}--spacing-md`,
|
|
15
|
+
"md-top": `${baseClass}--spacing-md-top`,
|
|
16
|
+
"md-bottom": `${baseClass}--spacing-md-bottom`,
|
|
17
|
+
lg: `${baseClass}--spacing-lg`,
|
|
18
|
+
"lg-top": `${baseClass}--spacing-lg-top`,
|
|
19
|
+
"lg-bottom": `${baseClass}--spacing-lg-bottom`,
|
|
20
|
+
xl: `${baseClass}--spacing-xl`,
|
|
21
|
+
"xl-top": `${baseClass}--spacing-xl-top`,
|
|
22
|
+
"xl-bottom": `${baseClass}--spacing-xl-bottom`
|
|
23
|
+
};
|
|
24
|
+
return spacingMap[spacing] || "";
|
|
25
|
+
}
|
|
26
|
+
function getHeadingVariantFromSemanticType(element) {
|
|
27
|
+
const elementStr = typeof element === "string" ? element : element.toString();
|
|
28
|
+
switch (elementStr.toLowerCase()) {
|
|
29
|
+
case "h1":
|
|
30
|
+
return "title-1";
|
|
31
|
+
case "h2":
|
|
32
|
+
return "title-2";
|
|
33
|
+
case "h3":
|
|
34
|
+
return "subtitle-1";
|
|
35
|
+
case "h4":
|
|
36
|
+
return "subtitle-2";
|
|
37
|
+
case "h5":
|
|
38
|
+
return "section-1";
|
|
39
|
+
case "h6":
|
|
40
|
+
return "section-2";
|
|
41
|
+
default:
|
|
42
|
+
return "title-1";
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
function getSemanticTypeFromTextVariant(variant) {
|
|
46
|
+
if (!variant) return "p";
|
|
47
|
+
switch (variant) {
|
|
48
|
+
case "label":
|
|
49
|
+
return "label";
|
|
50
|
+
case "sublabel":
|
|
51
|
+
return "span";
|
|
52
|
+
case "caption":
|
|
53
|
+
return "span";
|
|
54
|
+
case "overline":
|
|
55
|
+
return "span";
|
|
56
|
+
case "link":
|
|
57
|
+
return "a";
|
|
58
|
+
case "code-text":
|
|
59
|
+
return "code";
|
|
60
|
+
case "preformatted-text":
|
|
61
|
+
return "pre";
|
|
62
|
+
case "quote":
|
|
63
|
+
return "blockquote";
|
|
64
|
+
case "leading":
|
|
65
|
+
case "paragraph":
|
|
66
|
+
case "subparagraph":
|
|
67
|
+
case "emphasized":
|
|
68
|
+
default:
|
|
69
|
+
return "p";
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
export {
|
|
73
|
+
getHeadingVariantFromSemanticType,
|
|
74
|
+
getSemanticTypeFromTextVariant,
|
|
75
|
+
getSpacingClasses
|
|
76
|
+
};
|
|
77
|
+
//# sourceMappingURL=utils.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.mjs","sources":["../../../../src/beta/utils/utils.ts"],"sourcesContent":["import {\n TypographySpacing,\n TypographyHeadingVariant,\n TypographyTextVariant,\n} from '../types';\n\n/**\n * Get spacing classes for a component\n */\nexport function getSpacingClasses(\n spacing: TypographySpacing | undefined,\n baseClass: string,\n): string {\n if (!spacing) return '';\n\n const spacingMap: Record<string, string> = {\n none: `${baseClass}--spacing-none`,\n xs2: `${baseClass}--spacing-xs2`,\n 'xs2-top': `${baseClass}--spacing-xs2-top`,\n 'xs2-bottom': `${baseClass}--spacing-xs2-bottom`,\n xs: `${baseClass}--spacing-xs`,\n 'xs-top': `${baseClass}--spacing-xs-top`,\n 'xs-bottom': `${baseClass}--spacing-xs-bottom`,\n sm: `${baseClass}--spacing-sm`,\n 'sm-top': `${baseClass}--spacing-sm-top`,\n 'sm-bottom': `${baseClass}--spacing-sm-bottom`,\n md: `${baseClass}--spacing-md`,\n 'md-top': `${baseClass}--spacing-md-top`,\n 'md-bottom': `${baseClass}--spacing-md-bottom`,\n lg: `${baseClass}--spacing-lg`,\n 'lg-top': `${baseClass}--spacing-lg-top`,\n 'lg-bottom': `${baseClass}--spacing-lg-bottom`,\n xl: `${baseClass}--spacing-xl`,\n 'xl-top': `${baseClass}--spacing-xl-top`,\n 'xl-bottom': `${baseClass}--spacing-xl-bottom`,\n };\n\n return spacingMap[spacing] || '';\n}\n\n/**\n * Get heading variant based on semantic HTML element\n */\nexport function getHeadingVariantFromSemanticType(\n element: string | React.ElementType,\n): TypographyHeadingVariant {\n const elementStr = typeof element === 'string' ? element : element.toString();\n\n switch (elementStr.toLowerCase()) {\n case 'h1':\n return 'title-1';\n case 'h2':\n return 'title-2';\n case 'h3':\n return 'subtitle-1';\n case 'h4':\n return 'subtitle-2';\n case 'h5':\n return 'section-1';\n case 'h6':\n return 'section-2';\n default:\n return 'title-1';\n }\n}\n\n/**\n * Get semantic HTML element from text variant\n */\nexport function getSemanticTypeFromTextVariant(\n variant: TypographyTextVariant | undefined,\n): string {\n if (!variant) return 'p';\n\n switch (variant) {\n case 'label':\n return 'label';\n case 'sublabel':\n return 'span';\n case 'caption':\n return 'span';\n case 'overline':\n return 'span';\n case 'link':\n return 'a';\n case 'code-text':\n return 'code';\n case 'preformatted-text':\n return 'pre';\n case 'quote':\n return 'blockquote';\n case 'leading':\n case 'paragraph':\n case 'subparagraph':\n case 'emphasized':\n default:\n return 'p';\n }\n}\n"],"names":[],"mappings":"AASO,SAAS,kBACd,SACA,WACQ;AACR,MAAI,CAAC,QAAS,QAAO;AAErB,QAAM,aAAqC;AAAA,IACzC,MAAM,GAAG,SAAS;AAAA,IAClB,KAAK,GAAG,SAAS;AAAA,IACjB,WAAW,GAAG,SAAS;AAAA,IACvB,cAAc,GAAG,SAAS;AAAA,IAC1B,IAAI,GAAG,SAAS;AAAA,IAChB,UAAU,GAAG,SAAS;AAAA,IACtB,aAAa,GAAG,SAAS;AAAA,IACzB,IAAI,GAAG,SAAS;AAAA,IAChB,UAAU,GAAG,SAAS;AAAA,IACtB,aAAa,GAAG,SAAS;AAAA,IACzB,IAAI,GAAG,SAAS;AAAA,IAChB,UAAU,GAAG,SAAS;AAAA,IACtB,aAAa,GAAG,SAAS;AAAA,IACzB,IAAI,GAAG,SAAS;AAAA,IAChB,UAAU,GAAG,SAAS;AAAA,IACtB,aAAa,GAAG,SAAS;AAAA,IACzB,IAAI,GAAG,SAAS;AAAA,IAChB,UAAU,GAAG,SAAS;AAAA,IACtB,aAAa,GAAG,SAAS;AAAA,EAAA;AAG3B,SAAO,WAAW,OAAO,KAAK;AAChC;AAKO,SAAS,kCACd,SAC0B;AAC1B,QAAM,aAAa,OAAO,YAAY,WAAW,UAAU,QAAQ,SAAA;AAEnE,UAAQ,WAAW,eAAY;AAAA,IAC7B,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AACH,aAAO;AAAA,IACT;AACE,aAAO;AAAA,EAAA;AAEb;AAKO,SAAS,+BACd,SACQ;AACR,MAAI,CAAC,QAAS,QAAO;AAErB,UAAQ,SAAA;AAAA,IACN,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AAAA,IACL;AACE,aAAO;AAAA,EAAA;AAEb;"}
|