Merged in feat/SW-1276-implement-design (pull request #1348)

Feat/SW-1276 implement design

* feat(SW-1276) UI implementation Desktop part 1 for MyStay

* feat(SW-1276) UI implementation Desktop part 2 for MyStay

* feat(SW-1276) UI implementation Mobile part 1 for MyStay

* refactor: move files from MyStay/MyStay to MyStay

* feat(SW-1276) Sidepeek implementation

* feat(SW-1276): Refactoring

* feat(SW-1276) UI implementation Mobile part 2 for MyStay

* feat(SW-1276): translations

* feat(SW-1276) fixed skeleton

* feat(SW-1276): Added missing translations

* feat(SW-1276): Removed console log

* feat(SW-1276) fixed translations

* feat(SW-1276): Added translations

* feat(SW-1276) fix dynamic ID:s

* feat(SW-1276) removed createElement

* feat(SW-1276): Fixed build errors

* feat(SW-1276): Updated label

* feat(SW-1276): Rewrite SummaryCard


Approved-by: Niclas Edenvin
This commit is contained in:
Pontus Dreij
2025-02-18 14:20:54 +00:00
parent 90fee1b0c4
commit 8616e4ab76
56 changed files with 4163 additions and 227 deletions

View File

@@ -0,0 +1,74 @@
import Image from "@/components/Image"
import Link from "@/components/TempDesignSystem/Link"
import Body from "@/components/TempDesignSystem/Text/Body"
import Caption from "@/components/TempDesignSystem/Text/Caption"
import styles from "./summaryCard.module.css"
interface SummaryCardProps {
title: string
image: {
src: string
alt: string
}
texts: string[]
supportingText?: string
links?: {
href: string
text: string
icon: React.ReactNode
}[]
chip?: React.ReactNode
}
export default function SummaryCard({
title,
texts,
image,
supportingText,
links,
chip,
}: SummaryCardProps) {
return (
<div className={styles.card}>
<div className={styles.image}>
<Image src={image.src} alt={image.alt} width={152} height={152} />
</div>
<div className={styles.content}>
<div className={styles.topContent}>
<Body textTransform="bold" color="uiTextHighContrast">
{title}
</Body>
{texts.map((text) => (
<Body color="uiTextHighContrast" key={text}>
{text}
</Body>
))}
</div>
{supportingText && (
<Caption color="uiTextPlaceholder">{supportingText}</Caption>
)}
<div className={styles.bottomContent}>
{chip}
{links && (
<div className={styles.links}>
{links.map((link) => (
<Caption asChild type="bold" color="burgundy" key={link.href}>
<Link
href={link.href}
target="_blank"
color="burgundy"
className={styles.link}
>
{link.icon}
{link.text}
</Link>
</Caption>
))}
</div>
)}
</div>
</div>
</div>
)
}

View File

@@ -0,0 +1,52 @@
.card {
display: flex;
flex-direction: column;
align-items: center;
gap: var(--Spacing-x2);
}
@media (min-width: 768px) {
.card {
align-items: flex-start;
flex-direction: row;
}
}
.image {
width: 152px;
height: 152px;
border-radius: var(--Corner-radius-Medium);
}
@media (min-width: 768px) {
.image {
background-color: var(--Base-Surface-Secondary-light-Normal);
}
}
.content {
display: flex;
flex-direction: column;
height: 100%;
}
.topContent {
margin-bottom: 10px;
}
.bottomContent {
margin-top: auto;
}
.links {
display: flex;
gap: var(--Spacing-x2);
padding-bottom: 10px;
}
.link {
display: flex;
align-items: center;
gap: var(--Spacing-x-half);
}

View File

@@ -0,0 +1,22 @@
.bookingSummary {
display: flex;
flex-direction: column;
gap: var(--Spacing-x5);
}
.bookingSummaryContent {
display: flex;
flex-direction: column;
gap: 80px;
}
@media (min-width: 768px) {
.bookingSummaryContent {
flex-direction: row;
}
}
.toast {
width: var(--max-width-content);
margin: 0 auto;
}

View File

@@ -0,0 +1,130 @@
import { dt } from "@/lib/dt"
import {
CheckCircleIcon,
DirectionsIcon,
EmailIcon,
LinkIcon,
} from "@/components/Icons"
import CrossCircleIcon from "@/components/Icons/CrossCircle"
import IconChip from "@/components/TempDesignSystem/IconChip"
import Body from "@/components/TempDesignSystem/Text/Body"
import Caption from "@/components/TempDesignSystem/Text/Caption"
import Subtitle from "@/components/TempDesignSystem/Text/Subtitle"
import { Toast } from "@/components/TempDesignSystem/Toasts"
import { getIntl } from "@/i18n"
import { getLang } from "@/i18n/serverContext"
import { formatPrice } from "@/utils/numberFormatting"
import SummaryCard from "./SummaryCard"
import styles from "./bookingSummary.module.css"
import type { Hotel } from "@/types/hotel"
import type { BookingConfirmation } from "@/types/trpc/routers/booking/confirmation"
interface BookingSummaryProps {
booking: BookingConfirmation["booking"]
hotel: Hotel
}
export default async function BookingSummary({
booking,
hotel,
}: BookingSummaryProps) {
const intl = await getIntl()
const lang = getLang()
const directionsUrl = `https://www.google.com/maps/dir/?api=1&destination=${hotel.location.latitude},${hotel.location.longitude}`
const isPaid =
booking.rateDefinition.cancellationRule !== "CancellableBefore6PM"
const bookingDate = dt(booking.createDateTime)
.locale(lang)
.format("D MMMM YYYY")
return (
<div className={styles.bookingSummary}>
<Subtitle textTransform="uppercase" color="burgundy">
{intl.formatMessage({ id: "Booking summary" })}
</Subtitle>
<div className={styles.bookingSummaryContent}>
<SummaryCard
title={formatPrice(intl, booking.totalPrice, booking.currencyCode)}
image={{
src: "/_static/img/scandic-coin.svg",
alt: "Scandic coin",
}}
texts={[`${intl.formatMessage({ id: "Payment" })}: N/A`]}
supportingText={bookingDate}
chip={
<IconChip
color={isPaid ? "green" : "red"}
icon={
isPaid ? (
<CheckCircleIcon width={20} height={20} color="green" />
) : (
<CrossCircleIcon width={20} height={20} color="red" />
)
}
>
<Caption color={isPaid ? "green" : "red"}>
<strong>{intl.formatMessage({ id: "Status" })}:</strong>{" "}
{isPaid
? intl.formatMessage({ id: "Paid" })
: intl.formatMessage({ id: "Unpaid" })}
</Caption>
</IconChip>
}
/>
<SummaryCard
title={hotel.name}
image={{
src: "/_static/img/scandic-service.svg",
alt: "Scandic service",
}}
texts={[
hotel.address.streetAddress,
`${hotel.address.zipCode} ${hotel.address.city}`,
]}
supportingText={intl.formatMessage(
{ id: "Long {long} ∙ Lat {lat}" },
{
lat: hotel.location.latitude,
long: hotel.location.longitude,
}
)}
links={[
{
href: directionsUrl,
text: intl.formatMessage({ id: "Directions" }),
icon: <DirectionsIcon width={20} height={20} color="burgundy" />,
},
{
href: `mailto:${hotel.contactInformation.email}`,
text: intl.formatMessage({ id: "Email" }),
icon: <EmailIcon width={20} height={20} color="burgundy" />,
},
{
href: hotel.contactInformation.websiteUrl,
text: intl.formatMessage({ id: "Homepage" }),
icon: <LinkIcon width={20} height={20} color="burgundy" />,
},
]}
/>
</div>
{hotel.specialAlerts.length > 0 && (
<div className={styles.toast}>
<Toast variant="info">
<ul className={styles.list}>
{hotel.specialAlerts.map((alert) => (
<li key={alert.id}>
<Body color="uiTextHighContrast">{alert.text}</Body>
</li>
))}
</ul>
</Toast>
</div>
)}
</div>
)
}