Merged in feat/LOY-422-new-upcoming-stays (pull request #3121)

feat(LOY-422): Upcoming Stays Redesign

* feat(LOY-422): Upcoming Stays Redesign

* feat(LOY-422): Carousel next/previous arrows

* chore(LOY-422): add new material icon

* refactor(LOY-422): restructure new and old upcoming stays

* fix(LOY-422): handle less than 1 case

* chore(LOY-422): remove uneeded id

* chore(LOY-422): remove intl label for date edge case


Approved-by: Matilda Landström
This commit is contained in:
Chuma Mcphoy (We Ahead)
2025-11-13 13:05:24 +00:00
parent 66fd7696f7
commit 0b28893e71
25 changed files with 687 additions and 344 deletions

View File

@@ -66,3 +66,5 @@ DTMC_ENTRA_ID_ISSUER=""
DTMC_ENTRA_ID_SECRET="" DTMC_ENTRA_ID_SECRET=""
HOTEL_BRANDING="0" # 0 - disabled, 1 - enabled HOTEL_BRANDING="0" # 0 - disabled, 1 - enabled
NEW_STAYS_ON_MY_PAGES="true"

View File

@@ -30,3 +30,20 @@
justify-content: center; justify-content: center;
align-items: center; align-items: center;
} }
/* Styles for new empty upcoming stays design */
.emptyUpcomingStaysContainer {
display: flex;
padding: var(--Space-x6);
flex-direction: column;
justify-content: center;
align-items: center;
gap: var(--Space-x3);
border-radius: var(--Corner-radius-lg);
background: var(--Surface-Brand-Primary-1-Default);
}
.heading {
color: var(--Text-Heading);
text-align: center;
}

View File

@@ -1,6 +1,10 @@
import ButtonLink from "@scandic-hotels/design-system/ButtonLink"
import { MaterialIcon } from "@scandic-hotels/design-system/Icons/MaterialIcon" import { MaterialIcon } from "@scandic-hotels/design-system/Icons/MaterialIcon"
import Link from "@scandic-hotels/design-system/OldDSLink" import Link from "@scandic-hotels/design-system/OldDSLink"
import Title from "@scandic-hotels/design-system/Title" import Title from "@scandic-hotels/design-system/Title"
import { Typography } from "@scandic-hotels/design-system/Typography"
import { env } from "@/env/server"
import { getIntl } from "@/i18n" import { getIntl } from "@/i18n"
import { getLang } from "@/i18n/serverContext" import { getLang } from "@/i18n/serverContext"
@@ -13,39 +17,60 @@ export default async function EmptyUpcomingStaysBlock() {
const href = `/${lang}` const href = `/${lang}`
return ( if (!env.NEW_STAYS_ON_MY_PAGES) {
<section className={styles.container}> return (
<div className={styles.titleContainer}> <section className={styles.container}>
<Title <div className={styles.titleContainer}>
as="h4" <Title
level="h3" as="h4"
color="red" level="h3"
className={styles.title} color="red"
textAlign="center" className={styles.title}
textAlign="center"
>
{intl.formatMessage({
id: "stays.noUpcomingStays",
defaultMessage: "You have no upcoming stays.",
})}
<span className={styles.burgundyTitle}>
{intl.formatMessage({
id: "stays.whereToGoNext",
defaultMessage: "Where should you go next?",
})}
</span>
</Title>
</div>
<Link
href={href}
className={styles.link}
color="Text/Interactive/Secondary"
> >
{intl.formatMessage({ {intl.formatMessage({
id: "stays.noUpcomingStays", id: "stays.getInspired",
defaultMessage: "You have no upcoming stays.", defaultMessage: "Get inspired",
})} })}
<span className={styles.burgundyTitle}> <MaterialIcon icon="arrow_forward" color="CurrentColor" />
{intl.formatMessage({ </Link>
id: "stays.whereToGoNext", </section>
defaultMessage: "Where should you go next?", )
})} }
</span>
</Title> return (
</div> <section className={styles.emptyUpcomingStaysContainer}>
<Link <Typography variant="Title/Subtitle/md">
href={href} <p className={styles.heading}>
className={styles.link} {intl.formatMessage({
color="Text/Interactive/Secondary" id: "stays.noUpcomingStaysAtTheMoment",
> defaultMessage: "You have no upcoming stays at the moment",
})}
</p>
</Typography>
<ButtonLink href={href} variant="Tertiary" color="Primary" size="Small">
{intl.formatMessage({ {intl.formatMessage({
id: "stays.getInspired", id: "stays.findDestinationOrHotel",
defaultMessage: "Get inspired", defaultMessage: "Find destination or hotel",
})} })}
<MaterialIcon icon="arrow_forward" color="CurrentColor" /> </ButtonLink>
</Link>
</section> </section>
) )
} }

View File

@@ -8,7 +8,7 @@ import { Typography } from "@scandic-hotels/design-system/Typography"
import { getIntl } from "@/i18n" import { getIntl } from "@/i18n"
import { getLang } from "@/i18n/serverContext" import { getLang } from "@/i18n/serverContext"
import { getDaysUntilText } from "./utils" import { getDaysUntilText } from "../utils/getDaysUntilText"
import styles from "./nextStay.module.css" import styles from "./nextStay.module.css"

View File

@@ -1,9 +1,11 @@
import { env } from "@/env/server"
import { serverClient } from "@/lib/trpc/server" import { serverClient } from "@/lib/trpc/server"
import { Section } from "@/components/Section" import { Section } from "@/components/Section"
import { SectionHeader } from "@/components/Section/Header" import { SectionHeader } from "@/components/Section/Header"
import SectionLink from "@/components/Section/Link" import SectionLink from "@/components/Section/Link"
import EmptyUpcomingStaysBlock from "../EmptyUpcomingStays"
import NextStayContent from "./NextStayContent" import NextStayContent from "./NextStayContent"
import styles from "./nextStay.module.css" import styles from "./nextStay.module.css"
@@ -15,7 +17,7 @@ export default async function NextStay({ title, link }: NextStayProps) {
const nextStay = await caller.user.stays.next() const nextStay = await caller.user.stays.next()
if (!nextStay) { if (!nextStay) {
return null return env.NEW_STAYS_ON_MY_PAGES ? <EmptyUpcomingStaysBlock /> : null
} }
return ( return (

View File

@@ -29,10 +29,7 @@
.imageOverlay { .imageOverlay {
position: absolute; position: absolute;
top: 0; inset: 0;
left: 0;
right: 0;
bottom: 0;
background: linear-gradient( background: linear-gradient(
to bottom, to bottom,
rgba(0, 0, 0, 0.1) 0%, rgba(0, 0, 0, 0.1) 0%,

View File

@@ -1,3 +0,0 @@
.container {
display: inline-grid;
}

View File

@@ -0,0 +1,67 @@
"use client"
import { LoadingSpinner } from "@scandic-hotels/design-system/LoadingSpinner"
import { trpc } from "@scandic-hotels/trpc/client"
import { Carousel } from "@/components/Carousel"
import useLang from "@/hooks/useLang"
import CarouselCard from "./CarouselCard"
import styles from "./upcoming.module.css"
import type {
UpcomingStaysClientProps,
UpcomingStaysNonNullResponseObject,
} from "@/types/components/myPages/stays/upcoming"
export default function UpcomingStaysCarousel({
initialUpcomingStays,
}: UpcomingStaysClientProps) {
const lang = useLang()
const { data, isLoading } = trpc.user.stays.upcoming.useInfiniteQuery(
{
limit: 6,
lang,
},
{
getNextPageParam: (lastPage) => {
return lastPage?.nextCursor
},
initialData: {
pageParams: [undefined, 1],
pages: [initialUpcomingStays],
},
}
)
if (isLoading) {
return <LoadingSpinner />
}
const stays = data.pages
.filter((page): page is UpcomingStaysNonNullResponseObject => !!page?.data)
.flatMap((page) => page.data)
if (!stays.length) {
return null
}
return (
<Carousel className={styles.carousel}>
<Carousel.Content>
{stays.map((stay) => (
<Carousel.Item
key={stay.attributes.confirmationNumber}
className={styles.carouselItem}
>
<CarouselCard stay={stay} />
</Carousel.Item>
))}
</Carousel.Content>
<Carousel.Previous className={styles.navigationButton} />
<Carousel.Next className={styles.navigationButton} />
<Carousel.Dots />
</Carousel>
)
}

View File

@@ -0,0 +1,69 @@
.card {
display: flex;
flex-direction: column;
background: var(--Base-Surface-Primary-light-Normal);
border: 1px solid var(--Border-Default);
overflow: hidden;
border-radius: var(--Corner-radius-lg);
}
.imageContainer {
position: relative;
width: 100%;
aspect-ratio: 16/9;
border-radius: var(--Corner-radius-lg) var(--Corner-radius-lg) 0 0;
background:
linear-gradient(0deg, rgba(0, 0, 0, 0.4) 0%, rgba(0, 0, 0, 0.4) 100%),
lightgray 50% / cover no-repeat,
var(--Neutral-20);
overflow: hidden;
}
.image {
width: 100%;
height: 100%;
object-fit: cover;
position: relative;
z-index: 1;
}
.imageOverlay {
position: absolute;
inset: 0;
background: linear-gradient(
180deg,
rgba(0, 0, 0, 0.4) 0%,
rgba(0, 0, 0, 0.2) 50%,
rgba(0, 0, 0, 0.6) 100%
);
display: flex;
flex-direction: column;
z-index: 2;
padding: var(--Space-x2);
color: var(--Text-Inverted);
place-content: center;
text-align: center;
}
.content {
display: flex;
flex-direction: column;
gap: var(--Space-x1);
padding: var(--Space-x2);
}
.infoRow {
display: flex;
justify-content: space-between;
align-items: center;
}
.infoItem {
display: flex;
align-items: center;
gap: var(--Space-x05);
}
.dateRange {
text-align: right;
}

View File

@@ -0,0 +1,114 @@
"use client"
import { useIntl } from "react-intl"
import { dt } from "@scandic-hotels/common/dt"
import ButtonLink from "@scandic-hotels/design-system/ButtonLink"
import { Divider } from "@scandic-hotels/design-system/Divider"
import { MaterialIcon } from "@scandic-hotels/design-system/Icons/MaterialIcon"
import Image from "@scandic-hotels/design-system/Image"
import { Typography } from "@scandic-hotels/design-system/Typography"
import useLang from "@/hooks/useLang"
import { getDaysUntilText } from "../../utils/getDaysUntilText"
import styles from "./carouselCard.module.css"
import type { Stay } from "@scandic-hotels/trpc/routers/user/output"
interface CarouselCardProps {
stay: Stay
}
export default function CarouselCard({ stay }: CarouselCardProps) {
const intl = useIntl()
const lang = useLang()
const { attributes } = stay
const {
checkinDate,
checkoutDate,
hotelInformation,
isWebAppOrigin,
bookingUrl,
} = attributes
const daysUntilText = getDaysUntilText(checkinDate, lang, intl)
return (
<article className={styles.card}>
<div className={styles.imageContainer}>
<Image
className={styles.image}
alt={
hotelInformation.hotelContent.images.altText ||
hotelInformation.hotelContent.images.altText_En ||
hotelInformation.hotelName
}
src={hotelInformation.hotelContent.images.src}
width={400}
height={300}
priority
/>
<div className={styles.imageOverlay}>
<Typography variant="Title/Overline/sm">
<span>{daysUntilText}</span>
</Typography>
<Typography variant="Title/md">
<span>{hotelInformation.hotelName}</span>
</Typography>
{hotelInformation.cityName && (
<Typography variant="Title/Overline/sm">
<span>{hotelInformation.cityName}</span>
</Typography>
)}
</div>
</div>
<div className={styles.content}>
<div className={styles.infoRow}>
<Typography variant="Body/Paragraph/mdRegular">
<span className={styles.infoItem}>
<MaterialIcon icon="calendar_month" color="Icon/Default" />
{intl.formatMessage({
id: "common.dates",
defaultMessage: "Dates",
})}
</span>
</Typography>
<Typography variant="Body/Paragraph/mdRegular">
<span className={styles.dateRange}>
<time>{dt(checkinDate).locale(lang).format("D MMM")}</time>
{/* eslint-disable-next-line formatjs/no-literal-string-in-jsx */}
{" → "}
<time>{dt(checkoutDate).locale(lang).format("D MMM, YYYY")}</time>
</span>
</Typography>
</div>
{isWebAppOrigin && (
<>
<Divider variant="horizontal" color="Border/Divider/Default" />
<ButtonLink
variant="Text"
color="Primary"
size="Small"
href={bookingUrl}
>
{intl.formatMessage({
id: "nextStay.seeDetailsAndExtras",
defaultMessage: "See details & extras",
})}
<MaterialIcon
icon="keyboard_arrow_right"
color="CurrentColor"
size={20}
/>
</ButtonLink>
</>
)}
</div>
</article>
)
}

View File

@@ -1,10 +1,12 @@
import { env } from "@/env/server"
import { serverClient } from "@/lib/trpc/server" import { serverClient } from "@/lib/trpc/server"
import { Section } from "@/components/Section" import { Section } from "@/components/Section"
import SectionHeader from "@/components/Section/Header/Deprecated" import { SectionHeader } from "@/components/Section/Header"
import SectionLink from "@/components/Section/Link" import SectionLink from "@/components/Section/Link"
import EmptyUpcomingStaysBlock from "../EmptyUpcomingStays" import EmptyUpcomingStaysBlock from "../EmptyUpcomingStays"
import UpcomingStaysCarousel from "./Carousel"
import ClientUpcomingStays from "./Client" import ClientUpcomingStays from "./Client"
import styles from "./upcoming.module.css" import styles from "./upcoming.module.css"
@@ -20,10 +22,25 @@ export default async function UpcomingStays({
limit: 6, limit: 6,
}) })
const hasStays =
initialUpcomingStays?.data && initialUpcomingStays.data.length > 0
if (env.NEW_STAYS_ON_MY_PAGES) {
if (!hasStays) return null
return (
<Section className={styles.container}>
{title && <SectionHeader heading={title} link={link} />}
<UpcomingStaysCarousel initialUpcomingStays={initialUpcomingStays} />
<SectionLink link={link} variant="mobile" />
</Section>
)
}
return ( return (
<Section className={styles.container}> <Section className={styles.container}>
<SectionHeader title={title} link={link} /> {title && <SectionHeader heading={title} link={link} />}
{initialUpcomingStays?.data.length ? ( {hasStays ? (
<ClientUpcomingStays initialUpcomingStays={initialUpcomingStays} /> <ClientUpcomingStays initialUpcomingStays={initialUpcomingStays} />
) : ( ) : (
<EmptyUpcomingStaysBlock /> <EmptyUpcomingStaysBlock />

View File

@@ -0,0 +1,11 @@
.container {
display: inline-grid;
}
.carousel {
width: 100%;
}
.carousel .navigationButton {
top: 40%;
}

View File

@@ -3,7 +3,7 @@ import { describe, expect, it } from "vitest"
import { Lang } from "@scandic-hotels/common/constants/language" import { Lang } from "@scandic-hotels/common/constants/language"
import { dt } from "@scandic-hotels/common/dt" import { dt } from "@scandic-hotels/common/dt"
import { getDaysUntilText } from "./utils" import { getDaysUntilText } from "./getDaysUntilText"
import type { IntlShape, MessageDescriptor } from "react-intl" import type { IntlShape, MessageDescriptor } from "react-intl"
@@ -13,7 +13,6 @@ const mockIntl = {
values?: Record<string, string | number | boolean | Date> values?: Record<string, string | number | boolean | Date>
) => { ) => {
const messages: Record<string, string> = { const messages: Record<string, string> = {
"nextStay.past": `{date}`,
"nextStay.today": "Today", "nextStay.today": "Today",
"nextStay.tomorrow": "Tomorrow", "nextStay.tomorrow": "Tomorrow",
"nextStay.inXDays": `In {days} days`, "nextStay.inXDays": `In {days} days`,

View File

@@ -14,15 +14,7 @@ export function getDaysUntilText(
// Handle past dates edge case. // Handle past dates edge case.
if (daysUntil < 0) { if (daysUntil < 0) {
return intl.formatMessage( return dt(checkinDate).locale(lang).format("D MMM YYYY")
{
id: "nextStay.past",
defaultMessage: "{date} ",
},
{
date: dt(checkinDate).locale(lang).format("D MMM YYYY"),
}
)
} }
if (daysUntil === 0) { if (daysUntil === 0) {

View File

@@ -21,7 +21,7 @@ import SASTierComparisonBlock from "@/components/Blocks/DynamicContent/SASTierCo
import SignupFormWrapper from "@/components/Blocks/DynamicContent/SignupFormWrapper" import SignupFormWrapper from "@/components/Blocks/DynamicContent/SignupFormWrapper"
import NextStay from "@/components/Blocks/DynamicContent/Stays/NextStay" import NextStay from "@/components/Blocks/DynamicContent/Stays/NextStay"
import PreviousStays from "@/components/Blocks/DynamicContent/Stays/Previous" import PreviousStays from "@/components/Blocks/DynamicContent/Stays/Previous"
import UpcomingStays from "@/components/Blocks/DynamicContent/Stays/Upcoming" import UpcomingStays from "@/components/Blocks/DynamicContent/Stays/UpcomingStays"
import { SJWidget } from "@/components/SJWidget" import { SJWidget } from "@/components/SJWidget"
import JobylonFeed from "./JobylonFeed" import JobylonFeed from "./JobylonFeed"

View File

@@ -136,6 +136,13 @@ export const env = createEnv({
.string() .string()
.optional() .optional()
.transform((s) => s?.split(",") || []), .transform((s) => s?.split(",") || []),
NEW_STAYS_ON_MY_PAGES: z
.string()
// only allow "true" or "false"
.refine((s) => s === "true" || s === "false")
// transform to boolean
.transform((s) => s === "true")
.default("false"),
}, },
emptyStringAsUndefined: true, emptyStringAsUndefined: true,
runtimeEnv: { runtimeEnv: {
@@ -213,6 +220,7 @@ export const env = createEnv({
DTMC_ENTRA_ID_SECRET: process.env.DTMC_ENTRA_ID_SECRET, DTMC_ENTRA_ID_SECRET: process.env.DTMC_ENTRA_ID_SECRET,
HOTEL_BRANDING: process.env.HOTEL_BRANDING, HOTEL_BRANDING: process.env.HOTEL_BRANDING,
CHATBOT_LIVE_LANGS: process.env.CHATBOT_LIVE_LANGS, CHATBOT_LIVE_LANGS: process.env.CHATBOT_LIVE_LANGS,
NEW_STAYS_ON_MY_PAGES: process.env.NEW_STAYS_ON_MY_PAGES,
}, },
}) })

View File

@@ -2,7 +2,7 @@
display: grid; display: grid;
gap: var(--Space-x3); gap: var(--Space-x3);
align-items: center; align-items: center;
grid-template-areas: grid-template-areas:
"availableRoomsCount" "availableRoomsCount"
"noAvailabilityAlert" "noAvailabilityAlert"
"filters"; "filters";
@@ -26,7 +26,8 @@
@media screen and (min-width: 768px) { @media screen and (min-width: 768px) {
.container { .container {
grid-template-columns: 1fr auto; grid-template-columns: 1fr auto;
grid-template-areas: "availableRoomsCount filters" grid-template-areas:
"noAvailabilityAlert noAvailabilityAlert"; "availableRoomsCount filters"
"noAvailabilityAlert noAvailabilityAlert";
} }
} }

View File

@@ -276,7 +276,7 @@
font-style: normal; font-style: normal;
font-weight: 400; font-weight: 400;
font-display: block; font-display: block;
src: url(/_static/shared/fonts/material-symbols/rounded-1db5531f.woff2) src: url(/_static/shared/fonts/material-symbols/rounded-1b8067b7.woff2)
format('woff2'); format('woff2');
} }

View File

@@ -36,6 +36,13 @@ export const env = createEnv({
SENTRY_ENVIRONMENT: z.string().default("development"), SENTRY_ENVIRONMENT: z.string().default("development"),
PUBLIC_URL: z.string().default(""), PUBLIC_URL: z.string().default(""),
SALESFORCE_PREFERENCE_BASE_URL: z.string(), SALESFORCE_PREFERENCE_BASE_URL: z.string(),
NEW_STAYS_ON_MY_PAGES: z
.string()
// only allow "true" or "false"
.refine((s) => s === "true" || s === "false")
// transform to boolean
.transform((s) => s === "true")
.default("false"),
}, },
emptyStringAsUndefined: true, emptyStringAsUndefined: true,
runtimeEnv: { runtimeEnv: {
@@ -56,5 +63,6 @@ export const env = createEnv({
SENTRY_ENVIRONMENT: process.env.SENTRY_ENVIRONMENT, SENTRY_ENVIRONMENT: process.env.SENTRY_ENVIRONMENT,
PUBLIC_URL: process.env.NEXT_PUBLIC_PUBLIC_URL, PUBLIC_URL: process.env.NEXT_PUBLIC_PUBLIC_URL,
SALESFORCE_PREFERENCE_BASE_URL: process.env.SALESFORCE_PREFERENCE_BASE_URL, SALESFORCE_PREFERENCE_BASE_URL: process.env.SALESFORCE_PREFERENCE_BASE_URL,
NEW_STAYS_ON_MY_PAGES: process.env.NEW_STAYS_ON_MY_PAGES,
}, },
}) })

View File

@@ -1,6 +1,7 @@
import { createCounter } from "@scandic-hotels/common/telemetry" import { createCounter } from "@scandic-hotels/common/telemetry"
import { safeTry } from "@scandic-hotels/common/utils/safeTry" import { safeTry } from "@scandic-hotels/common/utils/safeTry"
import { env } from "../../../../env/server"
import { router } from "../../.." import { router } from "../../.."
import * as api from "../../../api" import * as api from "../../../api"
import { Transactions } from "../../../enums/transactions" import { Transactions } from "../../../enums/transactions"
@@ -184,6 +185,20 @@ export const userQueryRouter = router({
language language
) )
if (env.NEW_STAYS_ON_MY_PAGES) {
if (updatedData.length <= 1) {
// If there are 1 or fewer stays, return null since NextStay handles this
return null
}
// If there are multiple stays, filter out the first one since NextStay shows it
const filteredData = updatedData.slice(1)
return {
data: filteredData,
nextCursor,
}
}
return { return {
data: updatedData, data: updatedData,
nextCursor, nextCursor,

View File

@@ -19,327 +19,329 @@ const FONT_BASE_URL = `https://fonts.googleapis.com/css2?family=Material+Symbols
// Defines the subset of icons for the font // Defines the subset of icons for the font
const icons = [ const icons = [
"accessibility", "accessibility",
"accessible", "accessible",
"add_circle", "add_circle",
"add", "add",
"air_purifier_gen", "air_purifier_gen",
"air", "air",
"airline_seat_recline_normal", "airline_seat_recline_normal",
"airplane_ticket", "airplane_ticket",
"apartment", "apartment",
"apparel", "apparel",
"arrow_back_ios", "arrow_back_ios",
"arrow_back", "arrow_back",
"arrow_forward_ios", "arrow_forward_ios",
"arrow_forward", "arrow_forward",
"arrow_right", "arrow_right",
"arrow_upward", "arrow_upward",
"assistant_navigation", "assistant_navigation",
"asterisk", "asterisk",
"attractions", "attractions",
"award_star", "award_star",
"bakery_dining", "bakery_dining",
"balcony", "balcony",
"bathroom", "bathroom",
"bathtub", "bathtub",
"beach_access", "beach_access",
"bed", "bed",
"bedroom_parent", "bedroom_parent",
"box", "box",
"brunch_dining", "brunch_dining",
"business_center", "business_center",
"calendar_add_on", "calendar_add_on",
"calendar_clock", "calendar_clock",
"calendar_month", "calendar_month",
"calendar_today", "calendar_today",
"call_quality", "call_quality",
"call", "call",
"camera", "camera",
"cancel", "cancel",
"chair", "chair",
"charging_station", "charging_station",
"check_box", "check_box",
"check_circle", "check_circle",
"check", "check",
"checked_bag", "checked_bag",
"checkroom", "checkroom",
"chevron_left", "chevron_left",
"chevron_right", "chevron_right",
"close", "close",
"coffee_maker", "coffee_maker",
"coffee", "coffee",
"compare_arrows", "compare_arrows",
"computer", "computer",
"concierge", "concierge",
"confirmation_number", "confirmation_number",
"connected_tv", "connected_tv",
"content_copy", "content_copy",
"contract", "contract",
"cool_to_dry", "cool_to_dry",
"countertops", "countertops",
"credit_card_heart", "credit_card_heart",
"credit_card", "credit_card",
"curtains_closed", "curtains_closed",
"curtains", "curtains",
"deck", "deck",
"delete", "delete",
"desk", "desk",
"device_thermostat", "device_thermostat",
"diamond", "diamond",
"dining", "dining",
"directions_run", "directions_run",
"directions_subway", "directions_subway",
"directions", "directions",
"downhill_skiing", "downhill_skiing",
"download", "download",
"dresser", "dresser",
"edit_calendar", "edit_calendar",
"edit_square", "edit_square",
"edit", "edit",
"electric_bike", "electric_bike",
"electric_car", "electric_car",
"elevator", "elevator",
"emoji_transportation", "emoji_transportation",
"error_circle_rounded", "error_circle_rounded",
"error", "error",
"exercise", "exercise",
"family_restroom", "family_restroom",
"fastfood", "fastfood",
"favorite", "favorite",
"fax", "fax",
"featured_seasonal_and_gifts", "featured_seasonal_and_gifts",
"festival", "festival",
"filter_alt", "filter_alt",
"filter", "filter",
"format_list_bulleted", "format_list_bulleted",
"floor_lamp", "floor_lamp",
"forest", "forest",
"garage", "garage",
"globe", "globe",
"golf_course", "golf_course",
"groups", "groups",
"health_and_beauty", "health_and_beauty",
"heat", "heat",
"hiking", "hiking",
"home", "home",
"hot_tub", "hot_tub",
"houseboat", "houseboat",
"hvac", "hvac",
"id_card", "id_card",
"imagesmode", "imagesmode",
"info", "info",
"iron", "iron",
"kayaking", "kayaking",
"kettle", "kettle",
"keyboard_arrow_down", "keyboard_arrow_down",
"keyboard_arrow_up", "keyboard_arrow_right",
"king_bed", "keyboard_arrow_up",
"kitchen", "king_bed",
"landscape", "kitchen",
"laundry", "landscape",
"link", "laundry",
"liquor", "link",
"live_tv", "liquor",
"local_bar", "live_tv",
"local_cafe", "local_bar",
"local_convenience_store", "local_cafe",
"local_drink", "local_convenience_store",
"local_laundry_service", "local_drink",
"local_parking", "local_laundry_service",
"location_city", "local_parking",
"location_on", "location_city",
"lock", "location_on",
"loyalty", "lock",
"luggage", "loyalty",
"mail", "luggage",
"map", "mail",
"meeting_room", "map",
"microwave", "meeting_room",
"mode_fan", "microwave",
"museum", "mode_fan",
"music_cast", "museum",
"music_note", "music_cast",
"nature", "music_note",
"night_shelter", "nature",
"nightlife", "night_shelter",
"open_in_new", "nightlife",
"pan_zoom", "open_in_new",
"panorama", "pan_zoom",
"pedal_bike", "panorama",
"person", "pedal_bike",
"pets", "person",
"phone", "pets",
"photo_camera", "phone",
"pool", "photo_camera",
"print", "pool",
"radio", "print",
"recommend", "radio",
"redeem", "recommend",
"refresh", "redeem",
"remove", "refresh",
"restaurant", "remove",
"room_service", "restaurant",
"router", "room_service",
"sailing", "router",
"sauna", "sailing",
"scene", "sauna",
"search", "scene",
"sell", "search",
"shopping_bag", "sell",
"shower", "shopping_bag",
"single_bed", "shower",
"skateboarding", "single_bed",
"smoke_free", "skateboarding",
"smoking_rooms", "smoke_free",
"spa", "smoking_rooms",
"sports_esports", "spa",
"sports_golf", "sports_esports",
"sports_handball", "sports_golf",
"sports_tennis", "sports_handball",
"stairs", "sports_tennis",
"star", "stairs",
"straighten", "star",
"styler", "straighten",
"support_agent", "styler",
"swipe", "support_agent",
"sync_saved_locally", "swipe",
"table_bar", "sync_saved_locally",
"theater_comedy", "table_bar",
"things_to_do", "theater_comedy",
"train", "things_to_do",
"tram", "train",
"transit_ticket", "tram",
"travel_luggage_and_bags", "transit_ticket",
"travel", "travel_luggage_and_bags",
"trophy", "travel",
"tv_guide", "trophy",
"tv_remote", "tv_guide",
"upload", "tv_remote",
"visibility_off", "upload",
"visibility", "visibility_off",
"ward", "visibility",
"warning", "ward",
"water_full", "warning",
"wifi", "water_full",
"yard", "wifi",
"yard",
].sort(); ].sort();
function createHash(value: unknown) { function createHash(value: unknown) {
const stringified = stringify(value); const stringified = stringify(value);
const hash = crypto.createHash("sha256"); const hash = crypto.createHash("sha256");
hash.update(stringified); hash.update(stringified);
return hash.digest("hex"); return hash.digest("hex");
} }
const hash = createHash(icons).substring(0, 8); const hash = createHash(icons).substring(0, 8);
async function fetchIconUrl(url: string) { async function fetchIconUrl(url: string) {
const response = await fetch(url, { const response = await fetch(url, {
headers: { headers: {
Accept: "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7", Accept:
"User-Agent": "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7",
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/134.0.0.0 Safari/537.36", "User-Agent":
}, "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/134.0.0.0 Safari/537.36",
}); },
});
if (!response.ok) { if (!response.ok) {
console.error(`Unable to fetch woff2 for ${url}`); console.error(`Unable to fetch woff2 for ${url}`);
process.exit(1); process.exit(1);
} }
const text = await response.text(); const text = await response.text();
const isWoff2 = /format\('woff2'\)/.test(text); const isWoff2 = /format\('woff2'\)/.test(text);
if (!isWoff2) { if (!isWoff2) {
console.error(`Unable to identify woff2 font in response`); console.error(`Unable to identify woff2 font in response`);
process.exit(1); process.exit(1);
} }
const srcUrl = text.match(/src: url\(([^)]+)\)/); const srcUrl = text.match(/src: url\(([^)]+)\)/);
if (srcUrl && srcUrl[1]) { if (srcUrl && srcUrl[1]) {
return srcUrl[1]; return srcUrl[1];
} }
return null; return null;
} }
async function download(url: string, destFolder: string) { async function download(url: string, destFolder: string) {
const dest = resolve(join(destFolder, `/rounded-${hash}.woff2`)); const dest = resolve(join(destFolder, `/rounded-${hash}.woff2`));
try { try {
const response = await fetch(url); const response = await fetch(url);
if (!response.ok) { if (!response.ok) {
console.error(`Unable to fetch ${url}`); console.error(`Unable to fetch ${url}`);
process.exit(1); process.exit(1);
}
if (!response.body) {
console.error(`Bad response from ${url}`);
process.exit(1);
}
const fileStream = createWriteStream(dest);
// @ts-expect-error: type mismatch
const readableNodeStream = Readable.fromWeb(response.body);
await pipeline(readableNodeStream, fileStream);
} catch (error) {
console.error(`Error downloading file from ${url}:`, error);
process.exit(1);
} }
if (!response.body) {
console.error(`Bad response from ${url}`);
process.exit(1);
}
const fileStream = createWriteStream(dest);
// @ts-expect-error: type mismatch
const readableNodeStream = Readable.fromWeb(response.body);
await pipeline(readableNodeStream, fileStream);
} catch (error) {
console.error(`Error downloading file from ${url}:`, error);
process.exit(1);
}
} }
async function cleanFontDirs() { async function cleanFontDirs() {
await rm(FONT_DIR, { recursive: true, force: true }); await rm(FONT_DIR, { recursive: true, force: true });
await mkdir(FONT_DIR, { recursive: true }); await mkdir(FONT_DIR, { recursive: true });
await writeFile( await writeFile(
join(FONT_DIR, ".auto-generated"), join(FONT_DIR, ".auto-generated"),
`Auto-generated, do not edit. Use scripts/material-symbols-update.mts to update.\nhash=${hash}\ncreated=${new Date().toISOString()}\n`, `Auto-generated, do not edit. Use scripts/material-symbols-update.mts to update.\nhash=${hash}\ncreated=${new Date().toISOString()}\n`,
{ encoding: "utf-8" } { encoding: "utf-8" },
); );
} }
async function updateFontCSS() { async function updateFontCSS() {
const file = resolve(__dirname, "../packages/design-system/lib/fonts.css"); const file = resolve(__dirname, "../packages/design-system/lib/fonts.css");
const css = await readFile(file, { const css = await readFile(file, {
encoding: "utf-8", encoding: "utf-8",
}); });
await writeFile( await writeFile(
file, file,
css.replace( css.replace(
/url\(\/_static\/shared\/fonts\/material-symbols\/rounded[^)]+\)/, /url\(\/_static\/shared\/fonts\/material-symbols\/rounded[^)]+\)/,
`url(/_static/shared/fonts/material-symbols/rounded-${hash}.woff2)` `url(/_static/shared/fonts/material-symbols/rounded-${hash}.woff2)`,
), ),
{ {
encoding: "utf-8", encoding: "utf-8",
} },
); );
} }
async function main() { async function main() {
const fontUrl = `${FONT_BASE_URL}&icon_names=${icons.join(",")}&display=block`; const fontUrl = `${FONT_BASE_URL}&icon_names=${icons.join(",")}&display=block`;
const iconUrl = await fetchIconUrl(fontUrl); const iconUrl = await fetchIconUrl(fontUrl);
if (iconUrl) { if (iconUrl) {
await cleanFontDirs(); await cleanFontDirs();
await download(iconUrl, FONT_DIR); await download(iconUrl, FONT_DIR);
await updateFontCSS(); await updateFontCSS();
console.log("Successfully updated icons!"); console.log("Successfully updated icons!");
process.exit(0); process.exit(0);
} else { } else {
console.error( console.error(
`Unable to find the icon font src URL in CSS response from Google Fonts at ${fontUrl}` `Unable to find the icon font src URL in CSS response from Google Fonts at ${fontUrl}`,
); );
} }
} }
main(); main();

View File

@@ -1,3 +1,3 @@
Auto-generated, do not edit. Use scripts/material-symbols-update.mts to update. Auto-generated, do not edit. Use scripts/material-symbols-update.mts to update.
hash=1db5531f hash=1b8067b7
created=2025-09-17T06:58:37.841Z created=2025-11-11T10:02:22.385Z

Binary file not shown.