Merged in monorepo-step-1 (pull request #1080)

Migrate to a monorepo setup - step 1

* Move web to subfolder /apps/scandic-web

* Yarn + transitive deps

- Move to yarn
- design-system package removed for now since yarn doesn't
support the parameter for token (ie project currently broken)
- Add missing transitive dependencies as Yarn otherwise
prevents these imports
- VS Code doesn't pick up TS path aliases unless you open
/apps/scandic-web instead of root (will be fixed with monorepo)

* Pin framer-motion to temporarily fix typing issue

https://github.com/adobe/react-spectrum/issues/7494

* Pin zod to avoid typ error

There seems to have been a breaking change in the types
returned by zod where error is now returned as undefined
instead of missing in the type. We should just handle this
but to avoid merge conflicts just pin the dependency for
now.

* Pin react-intl version

Pin version of react-intl to avoid tiny type issue where formatMessage
does not accept a generic any more. This will be fixed in a future
commit, but to avoid merge conflicts just pin for now.

* Pin typescript version

Temporarily pin version as newer versions as stricter and results in
a type error. Will be fixed in future commit after merge.

* Setup workspaces

* Add design-system as a monorepo package

* Remove unused env var DESIGN_SYSTEM_ACCESS_TOKEN

* Fix husky for monorepo setup

* Update netlify.toml

* Add lint script to root package.json

* Add stub readme

* Fix react-intl formatMessage types

* Test netlify.toml in root

* Remove root toml

* Update netlify.toml publish path

* Remove package-lock.json

* Update build for branch/preview builds


Approved-by: Linus Flood
This commit is contained in:
Anton Gunnarsson
2025-02-26 10:36:17 +00:00
committed by Linus Flood
parent 667cab6fb6
commit 80100e7631
2731 changed files with 30986 additions and 23708 deletions

View File

@@ -0,0 +1,99 @@
.text {
display: block;
font-family: var(--typography-Script-1-fontFamily);
text-transform: none;
}
.one {
font-size: clamp(
var(--typography-Script-1-Mobile-fontSize),
1.3vw + 14px,
var(--typography-Script-1-Desktop-fontSize)
);
font-weight: var(--typography-Script-1-fontWeight);
letter-spacing: var(--typography-Script-1-letterSpacing);
line-height: var(--typography-Script-1-lineHeight);
}
.two {
font-size: clamp(
var(--typography-Script-2-Mobile-fontSize),
0.6vw + 15px,
var(--typography-Script-2-Desktop-fontSize)
);
font-weight: var(--typography-Script-2-fontWeight);
letter-spacing: var(--typography-Script-2-letterSpacing);
line-height: var(--typography-Script-2-lineHeight);
}
.tiltedExtraSmall {
transform: rotate(-2deg);
}
.tiltedSmall {
transform: rotate(-3deg);
}
.tiltedMedium {
transform: rotate(-4deg) translate(0px, -15px);
}
.tiltedLarge {
transform: rotate(-13deg) translate(0px, -15px);
}
.center {
text-align: center;
}
.left {
text-align: left;
}
.black {
color: var(--Main-Grey-100);
}
.burgundy {
color: var(--Scandic-Brand-Burgundy);
}
.pale {
color: var(--Scandic-Brand-Pale-Peach);
}
.peach80 {
color: var(--Base-Text-Medium-contrast);
}
.plosa {
color: var(--Primary-Light-On-Surface-Accent);
}
.red {
color: var(--Scandic-Brand-Scandic-Red);
}
.pink {
color: var(--Primary-Dark-On-Surface-Accent);
}
.secondaryLightAccent {
color: var(--Secondary-Light-On-Surface-Accent);
}
.tertiaryLightAccent {
color: var(--Tertiary-Light-On-Surface-Accent);
}
.primaryDimAccent {
color: var(--Primary-Dim-On-Surface-Accent);
}
.primaryStrongAccent {
color: var(--Primary-Strong-On-Surface-Accent);
}
.baseText {
color: var(--Base-Text-Inverted);
}

View File

@@ -0,0 +1,9 @@
import type { VariantProps } from "class-variance-authority"
import type { biroScriptVariants } from "./variants"
export interface BiroScriptProps
extends Omit<React.HTMLAttributes<HTMLSpanElement>, "color">,
VariantProps<typeof biroScriptVariants> {
asChild?: boolean
}

View File

@@ -0,0 +1,25 @@
import { Slot } from "@radix-ui/react-slot"
import { biroScriptVariants } from "./variants"
import type { BiroScriptProps } from "./biroScript"
export default function BiroScript({
asChild = false,
className,
color,
textAlign,
type,
tilted,
...props
}: BiroScriptProps) {
const Comp = asChild ? Slot : "span"
const classNames = biroScriptVariants({
className,
color,
textAlign,
type,
tilted,
})
return <Comp className={classNames} {...props} />
}

View File

@@ -0,0 +1,41 @@
import { cva } from "class-variance-authority"
import styles from "./biroScript.module.css"
const config = {
variants: {
color: {
black: styles.black,
burgundy: styles.burgundy,
pale: styles.pale,
peach80: styles.peach80,
primaryLightOnSurfaceAccent: styles.plosa,
red: styles.red,
pink: styles.pink,
secondaryLightAccent: styles.secondaryLightAccent,
tertiaryLightAccent: styles.tertiaryLightAccent,
primaryDimAccent: styles.primaryDimAccent,
primaryStrongAccent: styles.primaryStrongAccent,
baseText: styles.baseText,
},
textAlign: {
center: styles.center,
left: styles.left,
},
type: {
one: styles.one,
two: styles.two,
},
tilted: {
extraSmall: styles.tiltedExtraSmall,
small: styles.tiltedSmall,
medium: styles.tiltedMedium,
large: styles.tiltedLarge,
},
},
defaultVariants: {
type: "one",
},
} as const
export const biroScriptVariants = cva(styles.text, config)

View File

@@ -0,0 +1,149 @@
.body {
margin: 0;
padding: 0;
}
.bodyFontOnly {
font-style: normal;
}
.bold {
font-family: var(--typography-Body-Bold-fontFamily);
font-size: var(--typography-Body-Bold-fontSize);
font-weight: 500;
letter-spacing: var(--typography-Body-Bold-letterSpacing);
line-height: var(--typography-Body-Bold-lineHeight);
text-decoration: var(--typography-Body-Bold-textDecoration);
}
.regular {
font-family: var(--typography-Body-Regular-fontFamily);
font-size: var(--typography-Body-Regular-fontSize);
font-weight: 400;
letter-spacing: var(--typography-Body-Regular-letterSpacing);
line-height: var(--typography-Body-Regular-lineHeight);
text-decoration: var(--typography-Body-Regular-textDecoration);
}
.underlined {
font-family: var(--typography-Body-Underline-fontFamily);
font-size: var(--typography-Body-Underline-fontSize);
font-weight: 500;
letter-spacing: var(--typography-Body-Underline-letterSpacing);
line-height: var(--typography-Body-Underline-lineHeight);
text-decoration: var(--typography-Body-Underline-textDecoration);
}
.uppercase {
font-family: var(--typography-Body-Regular-fontFamily);
font-size: var(--typography-Body-Regular-fontSize);
font-weight: var(--typography-Body-Bold-fontWeight);
letter-spacing: var(--typography-Body-Regular-letterSpacing);
line-height: var(--typography-Body-Regular-lineHeight);
text-decoration: var(--typography-Body-Regular-textDecoration);
text-transform: uppercase;
}
.textAlignCenter {
text-align: center;
}
.textAlignLeft {
text-align: left;
}
.textAlignRight {
text-align: right;
}
.black {
color: var(--Main-Grey-100);
}
.burgundy {
color: var(--Scandic-Brand-Burgundy);
}
.grey {
color: var(--UI-Grey-60);
}
.pale {
color: var(--Scandic-Brand-Pale-Peach);
}
.red {
color: var(--Scandic-Brand-Scandic-Red);
}
.textMediumContrast {
color: var(--Base-Text-Medium-contrast);
}
.baseTextHighContrast {
color: var(--Base-Text-High-contrast);
}
.baseTextMediumContrast {
color: var(--Base-Text-Medium-contrast);
}
.white {
color: var(--UI-Opacity-White-100);
}
.peach50 {
color: var(--Primary-Dark-On-Surface-Accent);
}
.baseTextMediumContrast {
color: var(--Base-Text-Medium-contrast);
}
.uiTextHighContrast {
color: var(--UI-Text-High-contrast);
}
.uiTextMediumContrast {
color: var(--UI-Text-Medium-contrast);
}
.uiTextPlaceholder {
color: var(--UI-Text-Placeholder);
}
.disabled {
color: var(--Base-Text-Disabled);
}
.primaryLight {
color: var(--Primary-Light-On-Surface-Text);
}
.secondaryLight {
color: var(--Secondary-Light-On-Surface-Text);
}
.tertiaryLight {
color: var(--Tertiary-Light-On-Surface-Text);
}
.primaryDark {
color: var(--Primary-Dark-On-Surface-Text);
}
.primaryDim {
color: var(--Primary-Dim-On-Surface-Text);
}
.primaryStrong {
color: var(--Primary-Strong-On-Surface-Text);
}
.baseText {
color: var(--Base-Text-Inverted);
}
.success {
color: var(--UI-Semantic-Success);
}

View File

@@ -0,0 +1,10 @@
import type { VariantProps } from "class-variance-authority"
import type { bodyVariants } from "./variants"
export interface BodyProps
extends Omit<React.HTMLAttributes<HTMLHeadingElement>, "color">,
VariantProps<typeof bodyVariants> {
asChild?: boolean
fontOnly?: boolean
}

View File

@@ -0,0 +1,30 @@
import { Slot } from "@radix-ui/react-slot"
import { bodyFontOnlyVariants, bodyVariants } from "./variants"
import type { BodyProps } from "./body"
export default function Body({
asChild = false,
className = "",
color,
fontOnly = false,
textAlign,
textTransform,
...props
}: BodyProps) {
const Comp = asChild ? Slot : "p"
const classNames = fontOnly
? bodyFontOnlyVariants({
className,
textAlign,
textTransform,
})
: bodyVariants({
className,
color,
textAlign,
textTransform,
})
return <Comp className={classNames} {...props} />
}

View File

@@ -0,0 +1,71 @@
import { cva } from "class-variance-authority"
import styles from "./body.module.css"
const config = {
variants: {
color: {
black: styles.black,
burgundy: styles.burgundy,
disabled: styles.disabled,
grey: styles.grey,
pale: styles.pale,
red: styles.red,
textMediumContrast: styles.textMediumContrast,
baseTextMediumContrast: styles.baseTextMediumContrast,
baseTextHighContrast: styles.baseTextHighContrast,
white: styles.white,
peach50: styles.peach50,
uiTextHighContrast: styles.uiTextHighContrast,
uiTextMediumContrast: styles.uiTextMediumContrast,
uiTextPlaceholder: styles.uiTextPlaceholder,
primaryLight: styles.primaryLight,
secondaryLight: styles.secondaryLight,
tertiaryLight: styles.tertiaryLight,
primaryDark: styles.primaryDark,
primaryDim: styles.primaryDim,
primaryStrong: styles.primaryStrong,
baseText: styles.baseText,
success: styles.success,
},
textAlign: {
center: styles.textAlignCenter,
left: styles.textAlignLeft,
right: styles.textAlignRight,
},
textTransform: {
bold: styles.bold,
regular: styles.regular,
underlined: styles.underlined,
uppercase: styles.uppercase,
},
},
defaultVariants: {
color: "black",
textAlign: "left",
textTransform: "regular",
},
} as const
export const bodyVariants = cva(styles.body, config)
const fontOnlyconfig = {
variants: {
textAlign: {
center: styles.textAlignCenter,
left: styles.textAlignLeft,
right: styles.textAlignRight,
},
textTransform: {
bold: styles.bold,
regular: styles.regular,
underlined: styles.underlined,
uppercase: styles.uppercase,
},
},
defaultVariants: {
textAlign: "left",
textTransform: "regular",
},
} as const
export const bodyFontOnlyVariants = cva(styles.bodyFontOnly, fontOnlyconfig)

View File

@@ -0,0 +1,119 @@
p.caption {
margin: 0;
padding: 0;
}
.captionFontOnly {
font-style: normal;
}
.bold {
font-family: var(--typography-Caption-Bold-fontFamily);
font-size: var(--typography-Caption-Bold-fontSize);
font-weight: 500; /* var(--typography-Caption-Bold-fontWeight); /* Commented till figma values are fixed to 500 instead of medium */
letter-spacing: var(--typography-Caption-Bold-letterSpacing);
line-height: var(--typography-Caption-Bold-lineHeight);
text-decoration: var(--typography-Caption-Bold-textDecoration);
}
.labels {
font-family: var(--typography-Caption-Labels-fontFamily);
font-size: var(--typography-Caption-Labels-fontSize);
font-weight: var(--typography-Caption-Labels-fontWeight);
letter-spacing: var(--typography-Caption-Labels-letterSpacing);
line-height: var(--typography-Caption-Labels-lineHeight);
text-decoration: var(--typography-Caption-Labels-textDecoration);
}
.underline {
font-family: var(--typography-Caption-Underline-fontFamily);
font-size: var(--typography-Caption-Underline-fontSize);
font-weight: var(--typography-Caption-Underline-fontWeight);
letter-spacing: var(--typography-Caption-Underline-letterSpacing);
line-height: var(--typography-Caption-Underline-lineHeight);
text-decoration: underline; /* var(--typography-Caption-Underline-textDecoration) /* Commented till figma values are fixed to underline instead of "underline" */
}
.regular {
font-family: var(--typography-Caption-Regular-fontFamily);
font-size: var(--typography-Caption-Regular-fontSize);
font-weight: var(--typography-Caption-Regular-fontWeight);
letter-spacing: var(--typography-Caption-Regular-letterSpacing);
line-height: var(--typography-Caption-Regular-lineHeight);
text-decoration: var(--typography-Caption-Regular-textDecoration);
}
.uppercase {
text-transform: uppercase;
}
.baseTextAccent {
color: var(--Base-Text-Accent);
}
.black {
color: var(--Main-Grey-100);
}
.burgundy {
color: var(--Scandic-Brand-Burgundy);
}
.pale {
color: var(--Scandic-Brand-Pale-Peach);
}
.textMediumContrast {
color: var(--Base-Text-Medium-contrast);
}
.baseTextHighContrast {
color: var(--Base-Text-High-contrast);
}
.baseTextMediumContrast {
color: var(--Base-Text-Medium-contrast);
}
.red {
color: var(--Scandic-Brand-Scandic-Red);
}
.white {
color: var(--UI-Opacity-White-100);
}
.uiTextActive {
color: var(--UI-Text-Active);
}
.uiTextMediumContrast {
color: var(--UI-Text-Medium-contrast);
}
.uiTextHighContrast {
color: var(--UI-Text-High-contrast);
}
.uiTextPlaceholder {
color: var(--UI-Text-Placeholder);
}
.disabled {
color: var(--Base-Text-Disabled);
}
.center {
text-align: center;
}
.left {
text-align: left;
}
.green {
color: var(--UI-Semantic-Success);
}
.blue {
color: var(--UI-Semantic-Information);
}

View File

@@ -0,0 +1,10 @@
import type { VariantProps } from "class-variance-authority"
import type { captionVariants } from "./variants"
export interface CaptionProps
extends Omit<React.HTMLAttributes<HTMLHeadingElement>, "color">,
VariantProps<typeof captionVariants> {
asChild?: boolean
fontOnly?: boolean
}

View File

@@ -0,0 +1,35 @@
import { Slot } from "@radix-ui/react-slot"
import { captionVariants, fontOnlycaptionVariants } from "./variants"
import type { CaptionProps } from "./caption"
export default function Caption({
asChild = false,
className = "",
color,
fontOnly = false,
textAlign,
textTransform,
uppercase,
type,
...props
}: CaptionProps) {
const Comp = asChild ? Slot : "p"
const classNames = fontOnly
? fontOnlycaptionVariants({
className,
textTransform,
uppercase,
type,
})
: captionVariants({
className,
color,
textTransform,
textAlign,
uppercase,
type,
})
return <Comp className={classNames} {...props} />
}

View File

@@ -0,0 +1,73 @@
import { cva } from "class-variance-authority"
import styles from "./caption.module.css"
const config = {
variants: {
type: {
regular: styles.regular,
bold: styles.bold,
label: styles.labels,
underline: styles.underline,
},
color: {
baseTextAccent: styles.baseTextAccent,
black: styles.black,
burgundy: styles.burgundy,
pale: styles.pale,
textMediumContrast: styles.textMediumContrast,
red: styles.red,
white: styles.white,
green: styles.green,
blue: styles.blue,
uiTextHighContrast: styles.uiTextHighContrast,
uiTextActive: styles.uiTextActive,
uiTextMediumContrast: styles.uiTextMediumContrast,
uiTextPlaceholder: styles.uiTextPlaceholder,
disabled: styles.disabled,
baseTextHighContrast: styles.baseTextHighContrast,
baseTextMediumContrast: styles.baseTextMediumContrast,
},
textTransform: {
uppercase: styles.uppercase,
},
textAlign: {
center: styles.center,
left: styles.left,
},
uppercase: {
true: styles.uppercase,
},
},
defaultVariants: {
color: "black",
type: "regular",
},
} as const
export const captionVariants = cva(styles.caption, config)
const fontOnlyConfig = {
variants: {
type: {
regular: styles.regular,
bold: styles.bold,
label: styles.labels,
underline: styles.underline,
},
textTransform: {
uppercase: styles.uppercase,
},
uppercase: {
true: styles.uppercase,
},
},
defaultVariants: {
type: "regular",
},
} as const
export const fontOnlycaptionVariants = cva(
styles.captionFontOnly,
fontOnlyConfig
)

View File

@@ -0,0 +1,82 @@
.footnote {
margin: 0;
padding: 0;
}
.footnoteFontOnly {
font-style: normal;
}
.bold {
font-family: var(--typography-Footnote-Bold-fontFamily);
font-size: var(--typography-Footnote-Bold-fontSize);
font-weight: var(--typography-Footnote-Bold-fontWeight);
letter-spacing: var(--typography-Footnote-Bold-letterSpacing);
line-height: var(--typography-Footnote-Bold-lineHeight);
text-decoration: var(--typography-Footnote-Bold-textDecoration);
}
.regular {
font-family: var(--typography-Footnote-Regular-fontFamily);
font-size: var(--typography-Footnote-Regular-fontSize);
font-weight: var(--typography-Footnote-Regular-fontWeight);
letter-spacing: var(--typography-Footnote-Regular-letterSpacing);
line-height: var(--typography-Footnote-Regular-lineHeight);
text-decoration: var(--typography-Footnote-Regular-textDecoration);
}
.labels {
font-family: var(--typography-Footnote-Labels-fontFamily);
font-size: var(--typography-Footnote-Labels-fontSize);
font-weight: var(--typography-Footnote-Labels-fontWeight);
letter-spacing: var(--typography-Footnote-Labels-letterSpacing);
line-height: var(--typography-Footnote-Labels-lineHeight);
text-decoration: var(--typography-Footnote-Labels-textDecoration);
}
.uppercase {
text-transform: uppercase;
}
.center {
text-align: center;
}
.left {
text-align: left;
}
.black {
color: var(--Main-Grey-100);
}
.burgundy {
color: var(--Scandic-Brand-Burgundy);
}
.pale {
color: var(--Scandic-Brand-Pale-Peach);
}
.peach50 {
color: var(--Scandic-Peach-50);
}
.uiTextMediumContrast {
color: var(--UI-Text-Medium-contrast);
}
.uiTextHighContrast {
color: var(--UI-Text-High-contrast);
}
.uiTextPlaceholder {
color: var(--UI-Text-Placeholder);
}
.white {
color: var(--Main-Grey-White);
}
.baseTextDisabled {
color: var(--Base-Text-Disabled);
}

View File

@@ -0,0 +1,10 @@
import type { VariantProps } from "class-variance-authority"
import type { footnoteVariants } from "./variants"
export interface FootnoteProps
extends Omit<React.HTMLAttributes<HTMLParagraphElement>, "color">,
VariantProps<typeof footnoteVariants> {
asChild?: boolean
fontOnly?: boolean
}

View File

@@ -0,0 +1,33 @@
import { Slot } from "@radix-ui/react-slot"
import { footnoteFontOnlyVariants, footnoteVariants } from "./variants"
import type { FootnoteProps } from "./footnote"
export default function Footnote({
asChild = false,
className = "",
color,
fontOnly = false,
textAlign,
textTransform,
type,
...props
}: FootnoteProps) {
const Comp = asChild ? Slot : "p"
const classNames = fontOnly
? footnoteFontOnlyVariants({
className,
textAlign,
textTransform,
type,
})
: footnoteVariants({
className,
color,
textAlign,
textTransform,
type,
})
return <Comp className={classNames} {...props} />
}

View File

@@ -0,0 +1,61 @@
import { cva } from "class-variance-authority"
import styles from "./footnote.module.css"
const config = {
variants: {
type: {
regular: styles.regular,
bold: styles.bold,
label: styles.labels,
},
color: {
black: styles.black,
burgundy: styles.burgundy,
pale: styles.pale,
peach50: styles.peach50,
uiTextMediumContrast: styles.uiTextMediumContrast,
uiTextHighContrast: styles.uiTextHighContrast,
uiTextPlaceholder: styles.uiTextPlaceholder,
white: styles.white,
baseTextDisabled: styles.baseTextDisabled,
},
textAlign: {
center: styles.center,
left: styles.left,
},
textTransform: {
uppercase: styles.uppercase,
},
},
defaultVariants: {
type: "regular",
},
} as const
export const footnoteVariants = cva(styles.footnote, config)
const fontOnlyConfig = {
variants: {
type: {
regular: styles.regular,
bold: styles.bold,
label: styles.labels,
},
textAlign: {
center: styles.center,
left: styles.left,
},
textTransform: {
uppercase: styles.uppercase,
},
},
defaultVariants: {
type: "regular",
},
} as const
export const footnoteFontOnlyVariants = cva(
styles.footnoteFontOnly,
fontOnlyConfig
)

View File

@@ -0,0 +1,21 @@
import { Slot } from "@radix-ui/react-slot"
import { preambleVariants } from "./variants"
import type { CaptionProps } from "./preamble"
export default function Preamble({
asChild = false,
className = "",
color,
textAlign,
...props
}: CaptionProps) {
const Comp = asChild ? Slot : "p"
const classNames = preambleVariants({
className,
color,
textAlign,
})
return <Comp className={classNames} {...props} />
}

View File

@@ -0,0 +1,46 @@
.preamble {
margin: 0;
padding: 0;
font-family: var(--typography-Preamble-fontFamily);
font-size: clamp(
var(--typography-Preamble-Mobile-fontSize),
0.3vw + 15px,
var(--typography-Preamble-Desktop-fontSize)
);
font-weight: var(--typography-Preamble-fontWeight);
letter-spacing: var(--typography-Preamble-letterSpacing);
line-height: var(--typography-Preamble-lineHeight);
text-decoration: var(--typography-Preamble-textDecoration);
}
.preambleFontOnly {
font-style: normal;
}
.black {
color: var(--Main-Grey-100);
}
.burgundy {
color: var(--Scandic-Brand-Burgundy);
}
.pale {
color: var(--Scandic-Brand-Pale-Peach);
}
.textMediumContrast {
color: var(--Base-Text-UI-Medium-contrast);
}
.baseText {
color: var(--Base-Text-Inverted);
}
.center {
text-align: center;
}
.left {
text-align: left;
}

View File

@@ -0,0 +1,9 @@
import type { VariantProps } from "class-variance-authority"
import type { preambleVariants } from "./variants"
export interface CaptionProps
extends Omit<React.HTMLAttributes<HTMLHeadingElement>, "color">,
VariantProps<typeof preambleVariants> {
asChild?: boolean
}

View File

@@ -0,0 +1,24 @@
import { cva } from "class-variance-authority"
import styles from "./preamble.module.css"
const config = {
variants: {
color: {
black: styles.black,
burgundy: styles.burgundy,
pale: styles.pale,
textMediumContrast: styles.textMediumContrast,
baseText: styles.baseText,
},
textAlign: {
center: styles.center,
left: styles.left,
},
},
defaultVariants: {
color: "black",
},
} as const
export const preambleVariants = cva(styles.preamble, config)

View File

@@ -0,0 +1,29 @@
import { Slot } from "@radix-ui/react-slot"
import { checkForEmptyChildren } from "../../utils/checkForEmptyChildren"
import { subtitleVariants } from "./variants"
import type { SubtitleProps } from "./subtitle"
export default function Subtitle({
asChild = false,
className = "",
color,
textAlign,
textTransform,
type,
...props
}: SubtitleProps) {
if (checkForEmptyChildren(props.children) === 0) {
return null
}
const Comp = asChild ? Slot : "p"
const classNames = subtitleVariants({
className,
color,
textAlign,
textTransform,
type,
})
return <Comp className={classNames} {...props} />
}

View File

@@ -0,0 +1,92 @@
.subtitle {
margin: var(--Spacing-x0);
padding: var(--Spacing-x0);
}
.one {
font-family: var(--typography-Subtitle-1-fontFamily);
font-size: clamp(
var(--typography-Subtitle-1-Mobile-fontSize),
0.3vw + 15px,
var(--typography-Subtitle-1-Desktop-fontSize)
);
font-weight: 500;
letter-spacing: var(--typography-Subtitle-1-letterSpacing);
line-height: var(--typography-Subtitle-1-lineHeight);
}
.two {
font-family: var(--typography-Subtitle-2-fontFamily);
font-size: clamp(
var(--typography-Subtitle-2-Mobile-fontSize),
0.3vw + 15px,
var(--typography-Subtitle-2-Desktop-fontSize)
);
font-weight: 500;
letter-spacing: var(--typography-Subtitle-2-letterSpacing);
line-height: var(--typography-Subtitle-2-lineHeight);
}
.regular {
text-transform: none;
}
.uppercase {
text-transform: uppercase;
}
.capitalize {
text-transform: capitalize;
}
.center {
text-align: center;
}
.left {
text-align: left;
}
.right {
text-align: right;
}
.black {
color: var(--Main-Grey-100);
}
.burgundy {
color: var(--Scandic-Brand-Burgundy);
}
.pale {
color: var(--Scandic-Brand-Pale-Peach);
}
.baseTextHighContrast {
color: var(--Base-Text-High-contrast);
}
.uiTextHighContrast {
color: var(--UI-Text-High-contrast);
}
.uiTextMediumContrast {
color: var(--UI-Text-Medium-contrast);
}
.uiTextPlaceholder {
color: var(--UI-Text-Placeholder);
}
.red {
color: var(--Scandic-Brand-Scandic-Red);
}
.baseTextDisabled {
color: var(--Base-Text-Disabled);
}
.mainGrey60 {
color: var(--Main-Grey-60);
}

View File

@@ -0,0 +1,9 @@
import type { VariantProps } from "class-variance-authority"
import type { subtitleVariants } from "./variants"
export interface SubtitleProps
extends Omit<React.HTMLAttributes<HTMLHeadingElement>, "color">,
VariantProps<typeof subtitleVariants> {
asChild?: boolean
}

View File

@@ -0,0 +1,42 @@
import { cva } from "class-variance-authority"
import styles from "./subtitle.module.css"
const config = {
variants: {
color: {
black: styles.black,
burgundy: styles.burgundy,
baseTextDisabled: styles.baseTextDisabled,
pale: styles.pale,
baseTextHighContrast: styles.baseTextHighContrast,
uiTextHighContrast: styles.uiTextHighContrast,
uiTextMediumContrast: styles.uiTextMediumContrast,
uiTextPlaceholder: styles.uiTextPlaceholder,
red: styles.red,
mainGrey60: styles.mainGrey60,
},
textAlign: {
center: styles.center,
left: styles.left,
right: styles.right,
},
textTransform: {
regular: styles.regular,
uppercase: styles.uppercase,
capitalize: styles.capitalize,
},
type: {
one: styles.one,
two: styles.two,
},
},
defaultVariants: {
color: "black",
textAlign: "left",
textTransform: "regular",
type: "one",
},
} as const
export const subtitleVariants = cva(styles.subtitle, config)

View File

@@ -0,0 +1,39 @@
import { checkForEmptyChildren } from "../../utils/checkForEmptyChildren"
import { headingVariants } from "./variants"
import type { HeadingProps } from "./title"
export default function Title({
/**
* What styling to use, based on heading level. If not provided `level`
* will determine the styling.
*/
as,
children,
className = "",
color,
/**
* What HTML tag to use. Defaults to h1.
*/
level = "h1",
textAlign,
textTransform,
...rest
}: HeadingProps) {
if (checkForEmptyChildren(children) === 0) {
return null
}
const Hx = level
const classNames = headingVariants({
className,
color,
textAlign,
textTransform,
type: as ?? level,
})
return (
<Hx {...rest} className={classNames}>
{children}
</Hx>
)
}

View File

@@ -0,0 +1,143 @@
.heading {
margin: 0;
padding: 0;
font-weight: 500;
}
/* Temporarily remove h1 styling until design tokens är updated */
/* .h1 {
font-family: var(--typography-Title-1-fontFamily);
font-size: clamp(
var(--typography-Title-1-Mobile-fontSize),
2.6vw + 27px,
var(--typography-Title-1-Desktop-fontSize)
);
letter-spacing: var(--typography-Title-1-letterSpacing);
line-height: var(--typography-Title-1-lineHeight);
text-decoration: var(--typography-Title-1-textDecoration);
} */
.h1 {
font-family: var(--typography-Title-2-fontFamily);
font-size: clamp(
var(--typography-Title-2-Mobile-fontSize),
2vw + 20px,
var(--typography-Title-2-Desktop-fontSize)
);
letter-spacing: var(--typography-Title-2-letterSpacing);
line-height: var(--typography-Title-2-lineHeight);
text-decoration: var(--typography-Title-2-textDecoration);
font-weight: var(--typography-Title-2-fontWeight);
}
.h2 {
font-family: var(--typography-Title-3-fontFamily);
font-size: clamp(
var(--typography-Title-3-Mobile-fontSize),
0.6vw + 27px,
var(--typography-Title-3-Desktop-fontSize)
);
letter-spacing: var(--typography-Title-3-letterSpacing);
line-height: var(--typography-Title-3-lineHeight);
text-decoration: var(--typography-Title-3-textDecoration);
font-weight: var(--typography-Title-3-fontWeight);
}
.h3 {
font-family: var(--typography-Title-4-fontFamily);
font-size: clamp(
var(--typography-Title-4-Mobile-fontSize),
0.6vw + 19px,
var(--typography-Title-4-Desktop-fontSize)
);
letter-spacing: var(--typography-Title-4-letterSpacing);
line-height: var(--typography-Title-4-lineHeight);
text-decoration: var(--typography-Title-4-textDecoration);
font-weight: var(--typography-Title-4-fontWeight);
}
.h4 {
font-family: var(--typography-Title-5-fontFamily);
font-size: clamp(
var(--typography-Title-5-Mobile-fontSize),
0.3vw + 17px,
var(--typography-Title-5-Desktop-fontSize)
);
letter-spacing: var(--typography-Title-5-letterSpacing);
line-height: var(--typography-Title-5-lineHeight);
text-decoration: var(--typography-Title-5-textDecoration);
font-weight: var(--typography-Title-5-fontWeight);
}
.capitalize {
text-transform: capitalize;
}
.regular {
text-transform: none;
}
.uppercase {
text-transform: uppercase;
}
.center {
text-align: center;
}
.left {
text-align: left;
}
.black {
color: var(--Main-Grey-100);
}
.burgundy {
color: var(--Scandic-Brand-Burgundy);
}
.pale {
color: var(--Scandic-Brand-Pale-Peach);
}
.peach80 {
color: var(--Scandic-Peach-80);
}
.red {
color: var(--Scandic-Brand-Scandic-Red);
}
.white {
color: var(--UI-Opacity-White-100);
}
.primaryLight {
color: var(--Primary-Light-On-Surface-Text);
}
.secondaryLight {
color: var(--Secondary-Light-On-Surface-Text);
}
.tertiaryLight {
color: var(--Tertiary-Light-On-Surface-Text);
}
.primaryDark {
color: var(--Primary-Dark-On-Surface-Text);
}
.primaryDim {
color: var(--Primary-Dim-On-Surface-Text);
}
.primaryStrong {
color: var(--Primary-Strong-On-Surface-Text);
}
.baseText {
color: var(--Base-Text-Inverted);
}

View File

@@ -0,0 +1,12 @@
import type { VariantProps } from "class-variance-authority"
import type { headingVariants } from "./variants"
type HeadingLevel = "h1" | "h2" | "h3" | "h4" | "h5"
export interface HeadingProps
extends Omit<React.HTMLAttributes<HTMLHeadingElement>, "color">,
VariantProps<typeof headingVariants> {
as?: HeadingLevel
level?: HeadingLevel
}

View File

@@ -0,0 +1,47 @@
import { cva } from "class-variance-authority"
import styles from "./title.module.css"
const config = {
variants: {
color: {
black: styles.black,
burgundy: styles.burgundy,
pale: styles.pale,
peach80: styles.peach80,
red: styles.red,
white: styles.white,
primaryLight: styles.primaryLight,
secondaryLight: styles.secondaryLight,
tertiaryLight: styles.tertiaryLight,
primaryDark: styles.primaryDark,
primaryDim: styles.primaryDim,
primaryStrong: styles.primaryStrong,
baseText: styles.baseText,
},
textAlign: {
center: styles.center,
left: styles.left,
},
textTransform: {
capitalize: styles.capitalize,
regular: styles.regular,
uppercase: styles.uppercase,
},
type: {
h1: styles.h1,
h2: styles.h2,
h3: styles.h3,
h4: styles.h4,
h5: styles.h4,
},
},
defaultVariants: {
color: "burgundy",
textAlign: "left",
textTransform: "uppercase",
type: "h1",
},
} as const
export const headingVariants = cva(styles.heading, config)