fix(sw-350): fixed ui-comments for calendar, search and widget
This commit is contained in:
@@ -60,10 +60,9 @@ export default function DatePickerDesktop({
|
|||||||
lang={lang}
|
lang={lang}
|
||||||
locale={locale}
|
locale={locale}
|
||||||
mode="range"
|
mode="range"
|
||||||
numberOfMonths={2}
|
onDayClick={(day) => handleOnSelect(day)}
|
||||||
onSelect={handleOnSelect}
|
|
||||||
pagedNavigation
|
pagedNavigation
|
||||||
required
|
required={false}
|
||||||
selected={selectedDate}
|
selected={selectedDate}
|
||||||
startMonth={currentDate}
|
startMonth={currentDate}
|
||||||
weekStartsOn={1}
|
weekStartsOn={1}
|
||||||
|
|||||||
@@ -78,7 +78,7 @@ export default function DatePickerMobile({
|
|||||||
mode="range"
|
mode="range"
|
||||||
/** Showing full year or what's left of it */
|
/** Showing full year or what's left of it */
|
||||||
numberOfMonths={12}
|
numberOfMonths={12}
|
||||||
onSelect={handleOnSelect}
|
onDayClick={(day) => handleOnSelect(day)}
|
||||||
required
|
required
|
||||||
selected={selectedDate}
|
selected={selectedDate}
|
||||||
startMonth={startMonth}
|
startMonth={startMonth}
|
||||||
|
|||||||
@@ -47,8 +47,8 @@ td.rangeStart[aria-selected="true"] button.dayButton:hover {
|
|||||||
}
|
}
|
||||||
|
|
||||||
td.rangeEnd[aria-selected="true"]:not([data-outside="true"]) button.dayButton,
|
td.rangeEnd[aria-selected="true"]:not([data-outside="true"]) button.dayButton,
|
||||||
td.rangeStart[aria-selected="true"]:not([data-outside="true"])
|
td.rangeStart[aria-selected="true"]:not([data-outside="true"]) button.dayButton,
|
||||||
button.dayButton {
|
td.day[aria-selected="true"] button.dayButton {
|
||||||
background: var(--Primary-Light-On-Surface-Accent);
|
background: var(--Primary-Light-On-Surface-Accent);
|
||||||
border: none;
|
border: none;
|
||||||
color: var(--Base-Button-Inverted-Fill-Normal);
|
color: var(--Base-Button-Inverted-Fill-Normal);
|
||||||
@@ -75,6 +75,7 @@ td.rangeMiddle[aria-selected="true"] button.dayButton {
|
|||||||
background: var(--Base-Background-Primary-Normal);
|
background: var(--Base-Background-Primary-Normal);
|
||||||
border: none;
|
border: none;
|
||||||
border-radius: 0;
|
border-radius: 0;
|
||||||
|
color: var(--UI-Text-High-contrast);
|
||||||
}
|
}
|
||||||
|
|
||||||
td.day[data-disabled="true"],
|
td.day[data-disabled="true"],
|
||||||
|
|||||||
@@ -113,8 +113,8 @@ td.rangeStart[aria-selected="true"] button.dayButton:hover {
|
|||||||
}
|
}
|
||||||
|
|
||||||
td.rangeEnd[aria-selected="true"]:not([data-outside="true"]) button.dayButton,
|
td.rangeEnd[aria-selected="true"]:not([data-outside="true"]) button.dayButton,
|
||||||
td.rangeStart[aria-selected="true"]:not([data-outside="true"])
|
td.rangeStart[aria-selected="true"]:not([data-outside="true"]) button.dayButton,
|
||||||
button.dayButton {
|
td.day[aria-selected="true"] button.dayButton {
|
||||||
background: var(--Primary-Light-On-Surface-Accent);
|
background: var(--Primary-Light-On-Surface-Accent);
|
||||||
border: none;
|
border: none;
|
||||||
color: var(--Base-Button-Inverted-Fill-Normal);
|
color: var(--Base-Button-Inverted-Fill-Normal);
|
||||||
@@ -141,6 +141,7 @@ td.rangeMiddle[aria-selected="true"] button.dayButton {
|
|||||||
background: var(--Base-Background-Primary-Normal);
|
background: var(--Base-Background-Primary-Normal);
|
||||||
border: none;
|
border: none;
|
||||||
border-radius: 0;
|
border-radius: 0;
|
||||||
|
color: var(--UI-Text-High-contrast);
|
||||||
}
|
}
|
||||||
|
|
||||||
td.day[data-disabled="true"],
|
td.day[data-disabled="true"],
|
||||||
|
|||||||
@@ -22,6 +22,11 @@
|
|||||||
|
|
||||||
.hideWrapper {
|
.hideWrapper {
|
||||||
background-color: var(--Main-Grey-White);
|
background-color: var(--Main-Grey-White);
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.container[data-isopen="true"] .hideWrapper {
|
||||||
|
display: block;
|
||||||
}
|
}
|
||||||
|
|
||||||
@media screen and (max-width: 1366px) {
|
@media screen and (max-width: 1366px) {
|
||||||
|
|||||||
@@ -14,8 +14,6 @@ import DatePickerMobile from "./Screen/Mobile"
|
|||||||
|
|
||||||
import styles from "./date-picker.module.css"
|
import styles from "./date-picker.module.css"
|
||||||
|
|
||||||
import type { DateRange } from "react-day-picker"
|
|
||||||
|
|
||||||
import type { DatePickerFormProps } from "@/types/components/datepicker"
|
import type { DatePickerFormProps } from "@/types/components/datepicker"
|
||||||
|
|
||||||
const locales = {
|
const locales = {
|
||||||
@@ -26,26 +24,54 @@ const locales = {
|
|||||||
[Lang.sv]: sv,
|
[Lang.sv]: sv,
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function DatePickerForm({ name = "date" }: DatePickerFormProps) {
|
export default function DatePickerForm({
|
||||||
|
name = "date",
|
||||||
|
onToggleOpen,
|
||||||
|
}: DatePickerFormProps) {
|
||||||
const lang = useLang()
|
const lang = useLang()
|
||||||
const [isOpen, setIsOpen] = useState(false)
|
const [isOpen, setIsOpen] = useState(false)
|
||||||
const selectedDate = useWatch({ name })
|
const selectedDate = useWatch({ name })
|
||||||
const { register, setValue } = useFormContext()
|
const { register, setValue } = useFormContext()
|
||||||
const ref = useRef<HTMLDivElement | null>(null)
|
const ref = useRef<HTMLDivElement | null>(null)
|
||||||
|
|
||||||
|
const [isSelectingFrom, setIsSelectingFrom] = useState(true)
|
||||||
|
|
||||||
function close() {
|
function close() {
|
||||||
setIsOpen(false)
|
setIsOpen(false)
|
||||||
|
onToggleOpen && onToggleOpen(false)
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleOnClick() {
|
function handleOnClick() {
|
||||||
setIsOpen((prevIsOpen) => !prevIsOpen)
|
setIsOpen((prevIsOpen) => {
|
||||||
|
const newState = !prevIsOpen
|
||||||
|
onToggleOpen && onToggleOpen(newState)
|
||||||
|
return newState
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleSelectDate(selected: DateRange) {
|
function handleSelectDate(selected: Date) {
|
||||||
setValue(name, {
|
if (isSelectingFrom) {
|
||||||
from: dt(selected.from).format("YYYY-MM-DD"),
|
setValue(name, {
|
||||||
to: dt(selected.to).format("YYYY-MM-DD"),
|
from: dt(selected).format("YYYY-MM-DD"),
|
||||||
})
|
to: undefined,
|
||||||
|
})
|
||||||
|
setIsSelectingFrom(false)
|
||||||
|
} else {
|
||||||
|
const fromDate = dt(selectedDate.from)
|
||||||
|
const toDate = dt(selected)
|
||||||
|
if (toDate.isAfter(fromDate)) {
|
||||||
|
setValue(name, {
|
||||||
|
from: selectedDate.from,
|
||||||
|
to: toDate.format("YYYY-MM-DD"),
|
||||||
|
})
|
||||||
|
setIsSelectingFrom(true)
|
||||||
|
} else {
|
||||||
|
setValue(name, {
|
||||||
|
from: selectedDate.from,
|
||||||
|
to: undefined,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@@ -53,13 +79,14 @@ export default function DatePickerForm({ name = "date" }: DatePickerFormProps) {
|
|||||||
const target = evt.target as HTMLElement
|
const target = evt.target as HTMLElement
|
||||||
if (ref.current && target && !ref.current.contains(target)) {
|
if (ref.current && target && !ref.current.contains(target)) {
|
||||||
setIsOpen(false)
|
setIsOpen(false)
|
||||||
|
onToggleOpen && onToggleOpen(false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
document.body.addEventListener("click", handleClickOutside)
|
document.body.addEventListener("click", handleClickOutside)
|
||||||
return () => {
|
return () => {
|
||||||
document.body.removeEventListener("click", handleClickOutside)
|
document.body.removeEventListener("click", handleClickOutside)
|
||||||
}
|
}
|
||||||
}, [setIsOpen])
|
}, [setIsOpen, onToggleOpen])
|
||||||
|
|
||||||
const selectedFromDate = dt(selectedDate.from)
|
const selectedFromDate = dt(selectedDate.from)
|
||||||
.locale(lang)
|
.locale(lang)
|
||||||
|
|||||||
@@ -48,15 +48,6 @@ export default function Search({ locations }: SearchProps) {
|
|||||||
dispatch({ type: ActionType.CLEAR_HISTORY_LOCATIONS })
|
dispatch({ type: ActionType.CLEAR_HISTORY_LOCATIONS })
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleOnBlur() {
|
|
||||||
if (!value && state.searchData?.name) {
|
|
||||||
setValue(name, state.searchData.name)
|
|
||||||
// Always need to manually trigger
|
|
||||||
// revalidation when setting value r-h-f
|
|
||||||
trigger()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function handleOnChange(
|
function handleOnChange(
|
||||||
evt: FormEvent<HTMLInputElement> | ChangeEvent<HTMLInputElement>
|
evt: FormEvent<HTMLInputElement> | ChangeEvent<HTMLInputElement>
|
||||||
) {
|
) {
|
||||||
@@ -67,6 +58,7 @@ export default function Search({ locations }: SearchProps) {
|
|||||||
type: ActionType.SEARCH_LOCATIONS,
|
type: ActionType.SEARCH_LOCATIONS,
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
|
console.log("clear")
|
||||||
dispatch({ type: ActionType.CLEAR_SEARCH_LOCATIONS })
|
dispatch({ type: ActionType.CLEAR_SEARCH_LOCATIONS })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -156,7 +148,6 @@ export default function Search({ locations }: SearchProps) {
|
|||||||
}),
|
}),
|
||||||
...register(name, {
|
...register(name, {
|
||||||
onBlur: function () {
|
onBlur: function () {
|
||||||
handleOnBlur()
|
|
||||||
closeMenu()
|
closeMenu()
|
||||||
},
|
},
|
||||||
onChange: handleOnChange,
|
onChange: handleOnChange,
|
||||||
|
|||||||
@@ -24,8 +24,3 @@
|
|||||||
p {
|
p {
|
||||||
color: var(--UI-Text-Active);
|
color: var(--UI-Text-Active);
|
||||||
}
|
}
|
||||||
|
|
||||||
.container:hover:has(input:not(:active, :focus, :focus-within))
|
|
||||||
input::-webkit-search-cancel-button {
|
|
||||||
display: none;
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
"use client"
|
"use client"
|
||||||
import { useIntl } from "react-intl"
|
import { useIntl } from "react-intl"
|
||||||
|
|
||||||
import Body from "@/components/TempDesignSystem/Text/Body"
|
import Checkbox from "@/components/TempDesignSystem/Form/Checkbox"
|
||||||
import Caption from "@/components/TempDesignSystem/Text/Caption"
|
import Caption from "@/components/TempDesignSystem/Text/Caption"
|
||||||
import { Tooltip } from "@/components/TempDesignSystem/Tooltip"
|
import { Tooltip } from "@/components/TempDesignSystem/Tooltip"
|
||||||
|
|
||||||
@@ -50,17 +50,17 @@ export default function Voucher() {
|
|||||||
>
|
>
|
||||||
<div className={styles.options}>
|
<div className={styles.options}>
|
||||||
<label className={`${styles.option} ${styles.checkboxVoucher}`}>
|
<label className={`${styles.option} ${styles.checkboxVoucher}`}>
|
||||||
<input type="checkbox" disabled className={styles.checkbox} />
|
<Checkbox name="useVouchers" registerOptions={{ disabled: true }} />
|
||||||
<Caption color="disabled">{useVouchers}</Caption>
|
<Caption color="disabled">{useVouchers}</Caption>
|
||||||
{/* <InfoCircleIcon color="white" className={styles.infoIcon} /> Out of scope for this release */}
|
{/* <InfoCircleIcon color="white" className={styles.infoIcon} /> Out of scope for this release */}
|
||||||
</label>
|
</label>
|
||||||
<label className={styles.option}>
|
<label className={styles.option}>
|
||||||
<input type="checkbox" disabled className={styles.checkbox} />
|
<Checkbox name="useBonus" registerOptions={{ disabled: true }} />
|
||||||
<Caption color="disabled">{bonus}</Caption>
|
<Caption color="disabled">{bonus}</Caption>
|
||||||
{/* <InfoCircleIcon color="white" className={styles.infoIcon} /> Out of scope for this release */}
|
{/* <InfoCircleIcon color="white" className={styles.infoIcon} /> Out of scope for this release */}
|
||||||
</label>
|
</label>
|
||||||
<label className={styles.option}>
|
<label className={styles.option}>
|
||||||
<input type="checkbox" disabled className={styles.checkbox} />
|
<Checkbox name="useReward" registerOptions={{ disabled: true }} />
|
||||||
<Caption color="disabled">{reward}</Caption>
|
<Caption color="disabled">{reward}</Caption>
|
||||||
{/* <InfoCircleIcon color="white" className={styles.infoIcon} /> Out of scope for this release */}
|
{/* <InfoCircleIcon color="white" className={styles.infoIcon} /> Out of scope for this release */}
|
||||||
</label>
|
</label>
|
||||||
|
|||||||
@@ -68,7 +68,7 @@
|
|||||||
.options {
|
.options {
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
max-width: 190px;
|
max-width: 190px;
|
||||||
gap: 0;
|
gap: var(--Spacing-x-half);
|
||||||
}
|
}
|
||||||
.vouchers:hover,
|
.vouchers:hover,
|
||||||
.option:hover {
|
.option:hover {
|
||||||
@@ -76,6 +76,7 @@
|
|||||||
}
|
}
|
||||||
.optionsContainer {
|
.optionsContainer {
|
||||||
flex-direction: row;
|
flex-direction: row;
|
||||||
|
align-items: center;
|
||||||
}
|
}
|
||||||
.checkboxVoucher {
|
.checkboxVoucher {
|
||||||
display: none;
|
display: none;
|
||||||
|
|||||||
@@ -27,6 +27,7 @@
|
|||||||
.rooms,
|
.rooms,
|
||||||
.vouchers,
|
.vouchers,
|
||||||
.when,
|
.when,
|
||||||
|
.whenOpen,
|
||||||
.where {
|
.where {
|
||||||
background-color: var(--Base-Background-Primary-Normal);
|
background-color: var(--Base-Background-Primary-Normal);
|
||||||
border-radius: var(--Corner-radius-Medium);
|
border-radius: var(--Corner-radius-Medium);
|
||||||
@@ -34,7 +35,8 @@
|
|||||||
|
|
||||||
.rooms,
|
.rooms,
|
||||||
.vouchers,
|
.vouchers,
|
||||||
.when {
|
.when,
|
||||||
|
.whenOpen {
|
||||||
padding: var(--Spacing-x1) var(--Spacing-x-one-and-half);
|
padding: var(--Spacing-x1) var(--Spacing-x-one-and-half);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -61,6 +63,7 @@
|
|||||||
|
|
||||||
.rooms,
|
.rooms,
|
||||||
.when,
|
.when,
|
||||||
|
.whenOpen,
|
||||||
.where {
|
.where {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
}
|
}
|
||||||
@@ -71,12 +74,14 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.rooms,
|
.rooms,
|
||||||
.when {
|
.when,
|
||||||
|
.whenOpen {
|
||||||
padding: var(--Spacing-x1) var(--Spacing-x-one-and-half);
|
padding: var(--Spacing-x1) var(--Spacing-x-one-and-half);
|
||||||
border-radius: var(--Corner-radius-Small);
|
border-radius: var(--Corner-radius-Small);
|
||||||
}
|
}
|
||||||
.when:hover,
|
.when:hover,
|
||||||
.rooms:hover,
|
.rooms:hover,
|
||||||
|
.whenOpen,
|
||||||
.rooms:has(.input:active, .input:focus, .input:focus-within) {
|
.rooms:has(.input:active, .input:focus, .input:focus-within) {
|
||||||
background-color: var(--Base-Surface-Primary-light-Hover-alt);
|
background-color: var(--Base-Surface-Primary-light-Hover-alt);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
"use client"
|
"use client"
|
||||||
|
import { useState } from "react"
|
||||||
import { useWatch } from "react-hook-form"
|
import { useWatch } from "react-hook-form"
|
||||||
import { useIntl } from "react-intl"
|
import { useIntl } from "react-intl"
|
||||||
|
|
||||||
@@ -22,6 +23,7 @@ export default function FormContent({
|
|||||||
formId,
|
formId,
|
||||||
}: BookingWidgetFormContentProps) {
|
}: BookingWidgetFormContentProps) {
|
||||||
const intl = useIntl()
|
const intl = useIntl()
|
||||||
|
const [isDatePickerOpen, setIsDatePickerOpen] = useState(false)
|
||||||
const selectedDate = useWatch({ name: "date" })
|
const selectedDate = useWatch({ name: "date" })
|
||||||
|
|
||||||
const rooms = intl.formatMessage({ id: "Guests & Rooms" })
|
const rooms = intl.formatMessage({ id: "Guests & Rooms" })
|
||||||
@@ -35,14 +37,14 @@ export default function FormContent({
|
|||||||
<div className={styles.where}>
|
<div className={styles.where}>
|
||||||
<Search locations={locations} />
|
<Search locations={locations} />
|
||||||
</div>
|
</div>
|
||||||
<div className={styles.when}>
|
<div className={isDatePickerOpen ? styles.whenOpen : styles.when}>
|
||||||
<Caption color="red" textTransform="bold">
|
<Caption color="red" textTransform="bold">
|
||||||
{intl.formatMessage(
|
{intl.formatMessage(
|
||||||
{ id: "booking.nights" },
|
{ id: "booking.nights" },
|
||||||
{ totalNights: nights }
|
{ totalNights: nights }
|
||||||
)}
|
)}
|
||||||
</Caption>
|
</Caption>
|
||||||
<DatePicker />
|
<DatePicker onToggleOpen={setIsDatePickerOpen} />
|
||||||
</div>
|
</div>
|
||||||
<div className={styles.rooms}>
|
<div className={styles.rooms}>
|
||||||
<label>
|
<label>
|
||||||
|
|||||||
@@ -9,6 +9,11 @@
|
|||||||
background: var(--UI-Input-Controls-Fill-Selected);
|
background: var(--UI-Input-Controls-Fill-Selected);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.container[data-disabled] .checkbox {
|
||||||
|
border: 1px solid var(--UI-Input-Controls-Border-Disabled);
|
||||||
|
background: var(--UI-Input-Controls-Surface-Disabled);
|
||||||
|
}
|
||||||
|
|
||||||
.checkboxContainer {
|
.checkboxContainer {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: flex-start;
|
align-items: flex-start;
|
||||||
@@ -20,13 +25,12 @@
|
|||||||
width: 24px;
|
width: 24px;
|
||||||
height: 24px;
|
height: 24px;
|
||||||
min-width: 24px;
|
min-width: 24px;
|
||||||
border: 2px solid var(--UI-Input-Controls-Border-Normal);
|
border: 1px solid var(--UI-Input-Controls-Border-Normal);
|
||||||
border-radius: 4px;
|
border-radius: 4px;
|
||||||
transition: all 200ms;
|
transition: all 200ms;
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
transition: all 200ms;
|
|
||||||
forced-color-adjust: none;
|
forced-color-adjust: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -7,10 +7,10 @@ import { InfoCircleIcon } from "@/components/Icons"
|
|||||||
import CheckIcon from "@/components/Icons/Check"
|
import CheckIcon from "@/components/Icons/Check"
|
||||||
import Caption from "@/components/TempDesignSystem/Text/Caption"
|
import Caption from "@/components/TempDesignSystem/Text/Caption"
|
||||||
|
|
||||||
import { CheckboxProps } from "./checkbox"
|
|
||||||
|
|
||||||
import styles from "./checkbox.module.css"
|
import styles from "./checkbox.module.css"
|
||||||
|
|
||||||
|
import { CheckboxProps } from "@/types/components/checkbox"
|
||||||
|
|
||||||
export default function Checkbox({
|
export default function Checkbox({
|
||||||
name,
|
name,
|
||||||
children,
|
children,
|
||||||
@@ -29,6 +29,7 @@ export default function Checkbox({
|
|||||||
isSelected={field.value}
|
isSelected={field.value}
|
||||||
onChange={field.onChange}
|
onChange={field.onChange}
|
||||||
data-testid={name}
|
data-testid={name}
|
||||||
|
isDisabled={registerOptions?.disabled}
|
||||||
>
|
>
|
||||||
{({ isSelected }) => (
|
{({ isSelected }) => (
|
||||||
<>
|
<>
|
||||||
|
|||||||
@@ -5,13 +5,14 @@ import type { DateRange } from "react-day-picker"
|
|||||||
|
|
||||||
export interface DatePickerFormProps {
|
export interface DatePickerFormProps {
|
||||||
name?: string
|
name?: string
|
||||||
|
onToggleOpen?: (isDatePickerOpen: boolean) => void
|
||||||
}
|
}
|
||||||
|
|
||||||
type LangWithoutEn = Lang.da | Lang.de | Lang.fi | Lang.no | Lang.sv
|
type LangWithoutEn = Lang.da | Lang.de | Lang.fi | Lang.no | Lang.sv
|
||||||
|
|
||||||
export interface DatePickerProps {
|
export interface DatePickerProps {
|
||||||
close: () => void
|
close: () => void
|
||||||
handleOnSelect: (selected: DateRange) => void
|
handleOnSelect: (selected: Date) => void
|
||||||
locales: Record<LangWithoutEn, Locale>
|
locales: Record<LangWithoutEn, Locale>
|
||||||
selectedDate: DateRange
|
selectedDate: DateRange
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user