feat(SW-285): Add support for sidebar

This commit is contained in:
Chuma McPhoy
2024-09-02 22:43:08 +02:00
parent 60636d8cbe
commit a444746ccb
14 changed files with 594 additions and 1 deletions

View File

@@ -0,0 +1,5 @@
.link {
display: flex;
align-items: center;
gap: var(--Spacing-x1);
}

View File

@@ -0,0 +1,57 @@
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/content/sidebar"
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)
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>
<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 color="burgundy">{contact.footnote}</Footnote>
</div>
)
}