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,11 @@
.wrapper {
display: flex;
flex-direction: column;
gap: var(--Spacing-x-half);
}
.link {
display: flex;
align-items: center;
gap: var(--Spacing-x1);
}

View File

@@ -0,0 +1,60 @@
import { serverClient } from "@/lib/trpc/server"
import { EmailIcon, PhoneIcon } from "@/components/Icons"
import Link from "@/components/TempDesignSystem/Link"
import Body from "@/components/TempDesignSystem/Text/Body"
import Footnote from "@/components/TempDesignSystem/Text/Footnote"
import { getValueFromContactConfig } from "@/utils/contactConfig"
import styles from "./contactRow.module.css"
import type { ContactRowProps } from "@/types/components/sidebar/joinLoyaltyContact"
export default async function ContactRow({ contact }: ContactRowProps) {
const data = await serverClient().contentstack.base.contact()
if (!data) {
return null
}
const val = getValueFromContactConfig(contact.contact_field, data)
const footnote = contact.footnote
? getValueFromContactConfig(contact.footnote, data)
: null
if (!val) {
return null
}
let Icon = null
if (contact.contact_field.includes("email")) {
Icon = EmailIcon
} else if (contact.contact_field.includes("phone")) {
Icon = PhoneIcon
}
let openableLink = val
if (contact.contact_field.includes("email")) {
openableLink = `mailto:${val}`
} else if (contact.contact_field.includes("phone")) {
openableLink = `tel:${val}`
}
return (
<div className={styles.wrapper}>
<Body color="burgundy" textTransform="bold">
{contact.display_text}
</Body>
<Link
className={styles.link}
href={openableLink}
variant="underscored"
color="burgundy"
size="small"
>
{Icon ? <Icon width="20" height="20" color="burgundy" /> : null}
{val}
</Link>
{footnote && <Footnote color="burgundy">{footnote}</Footnote>}
</div>
)
}

View File

@@ -0,0 +1,30 @@
.contactContainer {
border-top: 1px solid var(--UI-Grey-30);
display: flex;
flex-direction: column;
gap: var(--Spacing-x2);
justify-content: center;
align-items: center;
padding-top: var(--Spacing-x5);
}
.contact {
display: grid;
gap: var(--Spacing-x-one-and-half);
}
.contact > div {
display: flex;
justify-content: center;
}
@media screen and (min-width: 1367px) {
.contactContainer {
align-items: start;
padding-top: var(--Spacing-x2);
}
.contact > div {
justify-content: start;
}
}

View File

@@ -0,0 +1,33 @@
import Subtitle from "@/components/TempDesignSystem/Text/Subtitle"
import { getIntl } from "@/i18n"
import ContactRow from "./ContactRow"
import styles from "./contact.module.css"
import type { ContactProps } from "@/types/components/sidebar/joinLoyaltyContact"
import { JoinLoyaltyContactEnums } from "@/types/enums/joinLoyaltyContact"
export default async function Contact({ contactBlock }: ContactProps) {
const intl = await getIntl()
return (
<article className={styles.contactContainer}>
<Subtitle>{intl.formatMessage({ id: "Contact us" })}</Subtitle>
<section className={styles.contact}>
{contactBlock.map((contact, i) => {
switch (contact.typename) {
case JoinLoyaltyContactEnums.contact.Contact:
return (
<ContactRow
key={`${contact.display_text}-${i}`}
contact={contact}
/>
)
default:
return null
}
})}
</section>
</article>
)
}

View File

@@ -0,0 +1,49 @@
import { faq, membershipTermsAndConditions } from "@/constants/currentWebHrefs"
import ArrowRight from "@/components/Icons/ArrowRight"
import Link from "@/components/TempDesignSystem/Link"
import Subtitle from "@/components/TempDesignSystem/Text/Subtitle"
import { getIntl } from "@/i18n"
import { getLang } from "@/i18n/serverContext"
import styles from "./readMore.module.css"
export default async function ReadMore() {
const [intl, lang] = await Promise.all([getIntl(), getLang()])
const links = [
{
href: faq[lang],
text: intl.formatMessage({ id: "FAQ" }),
},
{
href: membershipTermsAndConditions[lang],
text: intl.formatMessage({ id: "Membership terms and conditions" }),
},
]
return (
<article className={styles.wrapper}>
<Subtitle>{intl.formatMessage({ id: "Read more" })}</Subtitle>
<div className={styles.links}>
{links.map((link) => (
<Link
key={link.text}
size="small"
className={styles.link}
color="burgundy"
href={link.href}
>
<ArrowRight
color="burgundy"
className={styles.icon}
height="20"
width="20"
/>
{link.text}
</Link>
))}
</div>
</article>
)
}

View File

@@ -0,0 +1,27 @@
.wrapper {
display: flex;
flex-direction: column;
align-items: center;
gap: var(--Spacing-x2);
}
.links {
display: grid;
gap: var(--Spacing-x-one-and-half);
justify-items: center;
}
.link {
display: flex;
align-items: center;
}
@media screen and (min-width: 1367px) {
.wrapper {
align-items: start;
}
.links {
justify-items: start;
}
}

View File

@@ -0,0 +1,77 @@
import { auth } from "@/auth"
import ArrowRight from "@/components/Icons/ArrowRight"
import { ScandicFriends } from "@/components/Levels"
import LoginButton from "@/components/LoginButton"
import Button from "@/components/TempDesignSystem/Button"
import Link from "@/components/TempDesignSystem/Link"
import Body from "@/components/TempDesignSystem/Text/Body"
import Title from "@/components/TempDesignSystem/Text/Title"
import { getIntl } from "@/i18n"
import { isValidSession } from "@/utils/session"
import Contact from "./Contact"
import ReadMore from "./ReadMore"
import styles from "./joinLoyalty.module.css"
import type { JoinLoyaltyContactProps } from "@/types/components/sidebar/joinLoyaltyContact"
export default async function JoinLoyaltyContact({
block,
}: JoinLoyaltyContactProps) {
const [intl, session] = await Promise.all([getIntl(), auth()])
// Check if we valid session, that means we are logged in.
if (isValidSession(session)) {
return null
}
return (
<section className={styles.joinLoyaltyContainer}>
<article className={styles.wrapper}>
<Title as="h4" level="h3" textTransform="capitalize">
{block.title}
</Title>
<ScandicFriends color="red" />
{block.preamble ? (
<Body className={styles.preamble}>{block.preamble}</Body>
) : null}
{block.button ? (
<Button
asChild
intent="primary"
theme="base"
className={styles.button}
>
<Link
href={block.button.href}
color="white"
target={block.button.openInNewTab ? "_blank" : "_self"}
>
{block.button.title}
</Link>
</Button>
) : null}
<section className={styles.loginContainer}>
<Body>{intl.formatMessage({ id: "Already a friend?" })}</Body>
<LoginButton
className={styles.link}
trackingId="loginJoinLoyalty"
position="join scandic friends sidebar"
color="burgundy"
>
<ArrowRight
color="burgundy"
className={styles.icon}
height="20"
width="20"
/>
{intl.formatMessage({ id: "Log in here" })}
</LoginButton>
</section>
</article>
{block.contact ? <Contact contactBlock={block.contact} /> : null}
<ReadMore />
</section>
)
}

View File

@@ -0,0 +1,43 @@
.joinLoyaltyContainer {
display: flex;
flex-direction: column;
gap: var(--Spacing-x5);
}
.wrapper {
display: grid;
gap: var(--Spacing-x3);
padding-top: var(--Spacing-x4);
justify-items: center;
}
article.wrapper .preamble {
text-align: center;
}
.loginContainer {
display: grid;
gap: var(--Spacing-x2);
}
.button {
width: fit-content;
}
.link {
display: flex;
align-items: center;
}
.icon {
align-self: center;
}
@media screen and (min-width: 1367px) {
.wrapper {
justify-items: start;
}
article.wrapper .preamble {
text-align: left;
}
}

View File

@@ -0,0 +1,19 @@
import { Suspense } from "react"
import { auth } from "@/auth"
import MyPagesSidebar from "@/components/MyPages/Sidebar"
import { isValidSession } from "@/utils/session"
import SidebarNavigationSkeleton from "../MyPages/Sidebar/SidebarNavigationSkeleton"
export default async function MyPagesNavigation() {
const session = await auth()
if (!isValidSession(session)) {
return null
}
return (
<Suspense fallback={<SidebarNavigationSkeleton />}>
<MyPagesSidebar />
</Suspense>
)
}

View File

@@ -0,0 +1,11 @@
import SkeletonShimmer from "../SkeletonShimmer"
import styles from "./sidebar.module.css"
export default function SidebarSkeleton() {
return (
<aside className={styles.aside}>
<SkeletonShimmer width="100%" height="500px" />
</aside>
)
}

View File

@@ -0,0 +1,78 @@
import JsonToHtml from "@/components/JsonToHtml"
import ShortcutsList from "../Blocks/ShortcutsList"
import Card from "../TempDesignSystem/Card"
import TeaserCard from "../TempDesignSystem/TeaserCard"
import JoinLoyaltyContact from "./JoinLoyalty"
import MyPagesNavigation from "./MyPagesNavigation"
import styles from "./sidebar.module.css"
import type { SidebarProps } from "@/types/components/sidebar"
import { DynamicContentEnum } from "@/types/enums/dynamicContent"
import { SidebarEnums } from "@/types/enums/sidebar"
export default function Sidebar({ blocks }: SidebarProps) {
return (
<aside className={styles.aside}>
{blocks.map((block, idx) => {
switch (block.typename) {
case SidebarEnums.blocks.Content:
return (
<section key={`${block.typename}-${idx}`}>
<JsonToHtml
embeds={block.content.embedded_itemsConnection.edges}
nodes={block.content.json.children}
/>
</section>
)
case SidebarEnums.blocks.DynamicContent:
switch (block.dynamic_content.component) {
case DynamicContentEnum.Sidebar.components.my_pages_navigation:
return <MyPagesNavigation key={`${block.typename}-${idx}`} />
default:
return null
}
case SidebarEnums.blocks.JoinLoyaltyContact:
return (
<JoinLoyaltyContact
block={block.join_loyalty_contact}
key={`${block.typename}-${idx}`}
/>
)
case SidebarEnums.blocks.ScriptedCard:
return (
<Card
key={block.scripted_card.system.uid}
heading={block.scripted_card.heading}
secondaryButton={block.scripted_card.secondaryButton}
primaryButton={block.scripted_card.primaryButton}
bodyText={block.scripted_card.body_text}
scriptedTopTitle={block.scripted_card.scripted_top_title}
theme={block.scripted_card.theme ?? "image"}
/>
)
case SidebarEnums.blocks.TeaserCard:
return (
<TeaserCard
title={block.teaser_card.heading}
description={block.teaser_card.body_text}
intent={block.teaser_card.theme}
key={block.teaser_card.system.uid}
primaryButton={block.teaser_card.primaryButton}
secondaryButton={block.teaser_card.secondaryButton}
sidePeekButton={block.teaser_card.sidePeekButton}
sidePeekContent={block.teaser_card.sidePeekContent}
image={block.teaser_card.image}
/>
)
case SidebarEnums.blocks.QuickLinks:
return <ShortcutsList {...block.shortcuts} hasTwoColumns={false} />
default:
return null
}
})}
</aside>
)
}

View File

@@ -0,0 +1,20 @@
.aside {
grid-area: sidebar;
display: grid;
gap: var(--Spacing-x4);
container-name: sidebar;
container-type: inline-size;
gap: var(--Spacing-x3);
border-top: 1px solid var(--Base-Border-Subtle);
padding-top: var(--Spacing-x4);
}
@media screen and (min-width: 1367px) {
.aside {
align-content: flex-start;
gap: var(--Spacing-x4);
border-top: 0;
padding-top: 0;
}
}