feat: rename form/card to form/choicecard

This commit is contained in:
Simon Emanuelsson
2024-10-08 11:06:09 +02:00
parent 9b9c1b0e14
commit 155b6683c4
8 changed files with 21 additions and 23 deletions

View File

@@ -5,7 +5,7 @@ import { FormProvider, useForm } from "react-hook-form"
import { useIntl } from "react-intl" import { useIntl } from "react-intl"
import { KingBedIcon } from "@/components/Icons" import { KingBedIcon } from "@/components/Icons"
import RadioCard from "@/components/TempDesignSystem/Form/Card/Radio" import RadioCard from "@/components/TempDesignSystem/Form/ChoiceCard/Radio"
import { bedTypeSchema } from "./schema" import { bedTypeSchema } from "./schema"
@@ -24,9 +24,7 @@ export default function BedType() {
reValidateMode: "onChange", reValidateMode: "onChange",
}) })
// @ts-expect-error - Types mismatch docs as this is const text = intl.formatMessage<React.ReactNode>(
// a pattern that is allowed https://formatjs.io/docs/react-intl/api#usage
const text = intl.formatMessage(
{ id: "<b>Included</b> (based on availability)" }, { id: "<b>Included</b> (based on availability)" },
{ b: (str) => <b>{str}</b> } { b: (str) => <b>{str}</b> }
) )

View File

@@ -5,7 +5,7 @@ import { FormProvider, useForm } from "react-hook-form"
import { useIntl } from "react-intl" import { useIntl } from "react-intl"
import { BreakfastIcon, NoBreakfastIcon } from "@/components/Icons" import { BreakfastIcon, NoBreakfastIcon } from "@/components/Icons"
import RadioCard from "@/components/TempDesignSystem/Form/Card/Radio" import RadioCard from "@/components/TempDesignSystem/Form/ChoiceCard/Radio"
import { breakfastSchema } from "./schema" import { breakfastSchema } from "./schema"
@@ -31,9 +31,7 @@ export default function Breakfast() {
Icon={BreakfastIcon} Icon={BreakfastIcon}
id={breakfastEnum.BREAKFAST} id={breakfastEnum.BREAKFAST}
name="breakfast" name="breakfast"
// @ts-expect-error - Types mismatch docs as this is subtitle={intl.formatMessage<React.ReactNode>(
// a pattern that is allowed https://formatjs.io/docs/react-intl/api#usage
subtitle={intl.formatMessage(
{ id: "<b>{amount} {currency}</b>/night per adult" }, { id: "<b>{amount} {currency}</b>/night per adult" },
{ {
amount: "150", amount: "150",

View File

@@ -4,7 +4,7 @@ import { FormProvider, useForm } from "react-hook-form"
import { useIntl } from "react-intl" import { useIntl } from "react-intl"
import Button from "@/components/TempDesignSystem/Button" import Button from "@/components/TempDesignSystem/Button"
import CheckboxCard from "@/components/TempDesignSystem/Form/Card/Checkbox" import CheckboxCard from "@/components/TempDesignSystem/Form/ChoiceCard/Checkbox"
import CountrySelect from "@/components/TempDesignSystem/Form/Country" import CountrySelect from "@/components/TempDesignSystem/Form/Country"
import Input from "@/components/TempDesignSystem/Form/Input" import Input from "@/components/TempDesignSystem/Form/Input"
import Phone from "@/components/TempDesignSystem/Form/Phone" import Phone from "@/components/TempDesignSystem/Form/Phone"
@@ -88,8 +88,9 @@ export default function Details({ user }: DetailsProps) {
<footer className={styles.footer}> <footer className={styles.footer}>
{user ? null : ( {user ? null : (
<CheckboxCard <CheckboxCard
highlightSubtitle
list={list} list={list}
saving name="join"
subtitle={intl.formatMessage( subtitle={intl.formatMessage(
{ {
id: "{difference}{amount} {currency}", id: "{difference}{amount} {currency}",

View File

@@ -1,6 +1,6 @@
import Card from "." import Card from "./_Card"
import type { CheckboxProps } from "./card" import type { CheckboxProps } from "./_Card/card"
export default function CheckboxCard(props: CheckboxProps) { export default function CheckboxCard(props: CheckboxProps) {
return <Card {...props} type="checkbox" /> return <Card {...props} type="checkbox" />

View File

@@ -1,6 +1,6 @@
import Card from "." import Card from "./_Card"
import type { RadioProps } from "./card" import type { RadioProps } from "./_Card/card"
export default function RadioCard(props: RadioProps) { export default function RadioCard(props: RadioProps) {
return <Card {...props} type="radio" /> return <Card {...props} type="radio" />

View File

@@ -1,14 +1,15 @@
import type { IconProps } from "@/types/components/icon" import type { IconProps } from "@/types/components/icon"
interface BaseCardProps extends React.LabelHTMLAttributes<HTMLLabelElement> { interface BaseCardProps
extends Omit<React.LabelHTMLAttributes<HTMLLabelElement>, "title"> {
Icon?: (props: IconProps) => JSX.Element Icon?: (props: IconProps) => JSX.Element
declined?: boolean declined?: boolean
highlightSubtitle?: boolean
iconHeight?: number iconHeight?: number
iconWidth?: number iconWidth?: number
name?: string name: string
saving?: boolean subtitle?: React.ReactNode
subtitle?: string title: React.ReactNode
title: string
type: "checkbox" | "radio" type: "checkbox" | "radio"
value?: string value?: string
} }
@@ -22,7 +23,7 @@ interface ListCardProps extends BaseCardProps {
interface TextCardProps extends BaseCardProps { interface TextCardProps extends BaseCardProps {
list?: never list?: never
text: string text: React.ReactNode
} }
export type CardProps = ListCardProps | TextCardProps export type CardProps = ListCardProps | TextCardProps

View File

@@ -13,10 +13,10 @@ export default function Card({
iconHeight = 32, iconHeight = 32,
iconWidth = 32, iconWidth = 32,
declined = false, declined = false,
highlightSubtitle = false,
id, id,
list, list,
name = "join", name,
saving = false,
subtitle, subtitle,
text, text,
title, title,
@@ -31,7 +31,7 @@ export default function Card({
{subtitle ? ( {subtitle ? (
<Caption <Caption
className={styles.subtitle} className={styles.subtitle}
color={saving ? "baseTextAccent" : "uiTextHighContrast"} color={highlightSubtitle ? "baseTextAccent" : "uiTextHighContrast"}
textTransform="bold" textTransform="bold"
> >
{subtitle} {subtitle}