feat(SW-240): add simple form

This commit is contained in:
Fredrik Thorsson
2024-08-15 11:38:38 +02:00
parent 00a5465485
commit 608fe13004
4 changed files with 87 additions and 83 deletions

View File

@@ -5,11 +5,6 @@
max-width: 1250px;
}
.button {
width: 118px;
justify-content: center;
}
.bodyFontSize {
font-size: var(--typography-Caption-Bold-Desktop-fontSize);
}
@@ -19,9 +14,6 @@
}
.where {
display: flex;
gap: var(--Spacing-x-quarter);
flex-direction: column;
width: 100%;
max-width: 280px;
}
@@ -43,3 +35,7 @@
width: 100%;
max-width: 158px;
}
.option {
display: flex;
}

View File

@@ -2,7 +2,6 @@
import { useIntl } from "react-intl"
import Button from "@/components/TempDesignSystem/Button"
import Body from "@/components/TempDesignSystem/Text/Body"
import styles from "./formContent.module.css"
@@ -16,75 +15,51 @@ export default function FormContent() {
const vouchers = intl.formatMessage({ id: "Booking codes and vouchers" })
const bonus = intl.formatMessage({ id: "Use bonus cheque" })
const reward = intl.formatMessage({ id: "Book reward night" })
const search = intl.formatMessage({ id: "Find hotels" })
return (
<>
<div className={styles.input}>
<div className={`${styles.where} ${styles.border}`}>
<Body
color="red"
textTransform="bold"
className={styles.bodyFontSize}
>
{where}
</Body>
</div>
<div className={`${styles.when} ${styles.border}`}>
<Body
color="red"
textTransform="bold"
className={styles.bodyFontSize}
>
{when}
</Body>
</div>
<div className={`${styles.rooms} ${styles.border}`}>
<Body
color="red"
textTransform="bold"
className={styles.bodyFontSize}
>
{rooms}
</Body>
</div>
<div className={`${styles.vouchers} ${styles.border}`}>
<Body
color="textMediumContrast"
textTransform="bold"
className={styles.bodyFontSize}
>
{vouchers}
</Body>
</div>
<div className={styles.options}>
<div>
<Body color="textMediumContrast" className={styles.bodyFontSize}>
{bonus}
</Body>
</div>
<div>
<Body color="textMediumContrast" className={styles.bodyFontSize}>
{reward}
</Body>
</div>
</div>
<div className={styles.input}>
<div className={`${styles.where} ${styles.border}`}>
<Body color="red" textTransform="bold" className={styles.bodyFontSize}>
{where}
</Body>
<input placeholder={where} />
</div>
<Button
type="submit"
size="small"
theme="base"
intent="primary"
className={styles.button}
>
<div className={`${styles.when} ${styles.border}`}>
<Body color="red" textTransform="bold" className={styles.bodyFontSize}>
{when}
</Body>
<input placeholder={when} />
</div>
<div className={`${styles.rooms} ${styles.border}`}>
<Body color="red" textTransform="bold" className={styles.bodyFontSize}>
{rooms}
</Body>
<input placeholder={rooms} />
</div>
<div className={`${styles.vouchers} ${styles.border}`}>
<Body
color="white"
color="textMediumContrast"
textTransform="bold"
className={styles.bodyFontSize}
>
{search}
{vouchers}
</Body>
</Button>
</>
<input placeholder={vouchers} />
</div>
<div className={styles.options}>
<div className={styles.option}>
<input type="checkbox" />
<Body color="textMediumContrast" className={styles.bodyFontSize}>
{bonus}
</Body>
</div>
<div className={styles.option}>
<input type="checkbox" />
<Body color="textMediumContrast" className={styles.bodyFontSize}>
{reward}
</Body>
</div>
</div>
</div>
)
}

View File

@@ -1,7 +1,18 @@
.form {
.section {
display: flex;
justify-content: space-between;
width: 100%;
max-width: 1432px;
padding: var(--Spacing-x2) var(--Spacing-x5);
}
.form {
width: 100%;
}
.button {
width: 118px;
justify-content: center;
}
.bodyFontSize {
font-size: var(--typography-Caption-Bold-Desktop-fontSize);
}

View File

@@ -1,9 +1,13 @@
"use client"
import { zodResolver } from "@hookform/resolvers/zod"
import { FormProvider, useForm } from "react-hook-form"
import { useIntl } from "react-intl"
import { dt } from "@/lib/dt"
import Button from "@/components/TempDesignSystem/Button"
import Body from "@/components/TempDesignSystem/Text/Body"
import FormContent from "./FormContent"
import { bookingWidgetSchema } from "./schema"
@@ -14,6 +18,7 @@ import { BookingWidgetSchema } from "@/types/components/bookingWidget"
const formId = "booking-widget"
export default function Form() {
const intl = useIntl()
const methods = useForm<BookingWidgetSchema>({
defaultValues: {
search: {
@@ -48,14 +53,31 @@ export default function Form() {
}
return (
<form
onSubmit={methods.handleSubmit(onSubmit)}
className={styles.form}
id={formId}
>
<FormProvider {...methods}>
<FormContent />
</FormProvider>
</form>
<section className={styles.section}>
<form
onSubmit={methods.handleSubmit(onSubmit)}
className={styles.form}
id={formId}
>
<FormProvider {...methods}>
<FormContent />
</FormProvider>
</form>
<Button
type="submit"
size="small"
theme="base"
intent="primary"
className={styles.button}
>
<Body
color="white"
textTransform="bold"
className={styles.bodyFontSize}
>
{intl.formatMessage({ id: "Find hotels" })}
</Body>
</Button>
</section>
)
}