fix(SW-203): removed hidden prop inside RoomCard and added logic to parent
This commit is contained in:
@@ -14,7 +14,6 @@ import { RoomCardProps } from "@/types/components/hotelPage/roomCard"
|
|||||||
|
|
||||||
export function RoomCard({
|
export function RoomCard({
|
||||||
badgeTextTransKey,
|
badgeTextTransKey,
|
||||||
hidden,
|
|
||||||
id,
|
id,
|
||||||
images,
|
images,
|
||||||
subtitle,
|
subtitle,
|
||||||
@@ -34,7 +33,7 @@ export function RoomCard({
|
|||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<article className={`${styles.roomCard} ${hidden ? styles.hidden : ""}`}>
|
<article className={styles.roomCard}>
|
||||||
<button className={styles.imageWrapper} onClick={handleImageClick}>
|
<button className={styles.imageWrapper} onClick={handleImageClick}>
|
||||||
{badgeTextTransKey && (
|
{badgeTextTransKey && (
|
||||||
<span className={styles.badge}>
|
<span className={styles.badge}>
|
||||||
|
|||||||
@@ -5,10 +5,6 @@
|
|||||||
display: grid;
|
display: grid;
|
||||||
}
|
}
|
||||||
|
|
||||||
.hidden {
|
|
||||||
display: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*TODO: Build Chip/Badge component. */
|
/*TODO: Build Chip/Badge component. */
|
||||||
.badge {
|
.badge {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ import { RoomsProps } from "./types"
|
|||||||
import styles from "./rooms.module.css"
|
import styles from "./rooms.module.css"
|
||||||
|
|
||||||
export function Rooms({ rooms }: RoomsProps) {
|
export function Rooms({ rooms }: RoomsProps) {
|
||||||
const { formatMessage } = useIntl()
|
const intl = useIntl()
|
||||||
const [allRoomsVisible, setAllRoomsVisible] = useState(false)
|
const [allRoomsVisible, setAllRoomsVisible] = useState(false)
|
||||||
const scrollRef = useRef<HTMLDivElement>(null)
|
const scrollRef = useRef<HTMLDivElement>(null)
|
||||||
|
|
||||||
@@ -24,8 +24,8 @@ export function Rooms({ rooms }: RoomsProps) {
|
|||||||
const size = `${room.attributes.roomSize.min} - ${room.attributes.roomSize.max} m²`
|
const size = `${room.attributes.roomSize.min} - ${room.attributes.roomSize.max} m²`
|
||||||
const personLabel =
|
const personLabel =
|
||||||
room.attributes.occupancy.total === 1
|
room.attributes.occupancy.total === 1
|
||||||
? formatMessage({ id: "hotelPages.rooms.roomCard.person" })
|
? intl.formatMessage({ id: "hotelPages.rooms.roomCard.person" })
|
||||||
: formatMessage({ id: "hotelPages.rooms.roomCard.persons" })
|
: intl.formatMessage({ id: "hotelPages.rooms.roomCard.persons" })
|
||||||
|
|
||||||
const subtitle = `${size} (${room.attributes.occupancy.total} ${personLabel})`
|
const subtitle = `${size} (${room.attributes.occupancy.total} ${personLabel})`
|
||||||
|
|
||||||
@@ -53,21 +53,26 @@ export function Rooms({ rooms }: RoomsProps) {
|
|||||||
<div ref={scrollRef}></div>
|
<div ref={scrollRef}></div>
|
||||||
<SectionHeader
|
<SectionHeader
|
||||||
textTransform="uppercase"
|
textTransform="uppercase"
|
||||||
title={formatMessage({ id: "Rooms" })}
|
title={intl.formatMessage({ id: "Rooms" })}
|
||||||
subtitle={null}
|
subtitle={null}
|
||||||
/>
|
/>
|
||||||
<Grids.Stackable>
|
<Grids.Stackable>
|
||||||
{mappedRooms.map(
|
{mappedRooms.map(
|
||||||
({ id, images, title, subtitle, popularChoice }, index) => (
|
({ id, images, title, subtitle, popularChoice }, index) => (
|
||||||
<RoomCard
|
<div
|
||||||
key={id}
|
key={id}
|
||||||
id={id}
|
className={
|
||||||
hidden={!allRoomsVisible && index > 2}
|
!allRoomsVisible && index > 2 ? styles.hiddenRoomCard : ""
|
||||||
images={images}
|
}
|
||||||
title={title}
|
>
|
||||||
subtitle={subtitle}
|
<RoomCard
|
||||||
badgeTextTransKey={popularChoice ? "Popular choice" : null}
|
id={id}
|
||||||
/>
|
images={images}
|
||||||
|
title={title}
|
||||||
|
subtitle={subtitle}
|
||||||
|
badgeTextTransKey={popularChoice ? "Popular choice" : null}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
)
|
)
|
||||||
)}
|
)}
|
||||||
</Grids.Stackable>
|
</Grids.Stackable>
|
||||||
@@ -80,7 +85,9 @@ export function Rooms({ rooms }: RoomsProps) {
|
|||||||
className={`${styles.showMoreButton} ${allRoomsVisible ? styles.showLess : ""}`}
|
className={`${styles.showMoreButton} ${allRoomsVisible ? styles.showLess : ""}`}
|
||||||
>
|
>
|
||||||
<ChevronDownIcon className={styles.chevron} />
|
<ChevronDownIcon className={styles.chevron} />
|
||||||
{formatMessage({ id: allRoomsVisible ? "Show less" : "Show more" })}
|
{intl.formatMessage({
|
||||||
|
id: allRoomsVisible ? "Show less" : "Show more",
|
||||||
|
})}
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
</SectionContainer>
|
</SectionContainer>
|
||||||
|
|||||||
@@ -3,6 +3,10 @@
|
|||||||
justify-content: center;
|
justify-content: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.hiddenRoomCard {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
.showMoreButton.showLess .chevron {
|
.showMoreButton.showLess .chevron {
|
||||||
transform: rotate(180deg);
|
transform: rotate(180deg);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ import { RoomData } from "@/types/hotel"
|
|||||||
export interface RoomCardProps {
|
export interface RoomCardProps {
|
||||||
id: string
|
id: string
|
||||||
images: RoomData["attributes"]["content"]["images"]
|
images: RoomData["attributes"]["content"]["images"]
|
||||||
hidden?: boolean
|
|
||||||
title: string
|
title: string
|
||||||
subtitle: string
|
subtitle: string
|
||||||
badgeTextTransKey: string | null
|
badgeTextTransKey: string | null
|
||||||
|
|||||||
Reference in New Issue
Block a user