From 34683a54fd774603034f2e95b0a765a6f0ac79bb Mon Sep 17 00:00:00 2001
From: Benson Cho <100653148+bcho892@users.noreply.github.com>
Date: Thu, 29 Aug 2024 12:21:33 +1200
Subject: [PATCH] Restyle lodge booking page to be more robust (#770)
* try out new style
* simplify the information screen
* improve docs and add the handler to book the lodge button
* rename image src props
* constrain image max width
* improve docs
---
client/src/app/bookings/page.tsx | 2 +-
.../composite/LodgeInfo/LodgeInfo.story.tsx | 6 +-
.../composite/LodgeInfo/LodgeInfo.tsx | 41 +++++++---
.../LodgeInfoComponent/LodgeInfoComponent.tsx | 26 ++++--
.../LodgeInfoGallery.story.tsx | 6 +-
.../LodgeInfoGallery/LodgeInfoGallery.tsx | 81 ++++++++-----------
6 files changed, 89 insertions(+), 73 deletions(-)
diff --git a/client/src/app/bookings/page.tsx b/client/src/app/bookings/page.tsx
index 335770cfb..9521a3828 100644
--- a/client/src/app/bookings/page.tsx
+++ b/client/src/app/bookings/page.tsx
@@ -40,7 +40,7 @@ const BookingPage = async () => {
enableNetworkRequests
lodgeInfoProps={{
children: ,
- images: processedImages
+ imageSrcs: processedImages
}}
/>
>
diff --git a/client/src/components/composite/LodgeInfo/LodgeInfo.story.tsx b/client/src/components/composite/LodgeInfo/LodgeInfo.story.tsx
index aa87943da..42fd29005 100644
--- a/client/src/components/composite/LodgeInfo/LodgeInfo.story.tsx
+++ b/client/src/components/composite/LodgeInfo/LodgeInfo.story.tsx
@@ -12,7 +12,7 @@ type Story = StoryObj
export const Default: Story = {
args: {
handleBookLodgeClick: () => console.log(""),
- images: [
+ imageSrcs: [
"https://via.placeholder.com/400x400?text=Image+1",
"https://via.placeholder.com/400x400?text=I+SUPPORT+LGBT",
"https://via.placeholder.com/400x400?text=Image+3",
@@ -21,6 +21,10 @@ export const Default: Story = {
children: (
<>
+
+ Visit for the Whakapapa Ski field status, lift, food and retail
+ status and status of other activities.
+
The UASC Lodge is located in the Whakapapa Ski field and is just a
3-5 min walk from the bottom of the Sky Waka Gondola, meaning you
diff --git a/client/src/components/composite/LodgeInfo/LodgeInfo.tsx b/client/src/components/composite/LodgeInfo/LodgeInfo.tsx
index 4ac3c57a6..783ac19d6 100644
--- a/client/src/components/composite/LodgeInfo/LodgeInfo.tsx
+++ b/client/src/components/composite/LodgeInfo/LodgeInfo.tsx
@@ -1,3 +1,4 @@
+import Button from "@/components/generic/FigmaButtons/FigmaButton"
import LodgeInfoComponent from "./LodgeInfoComponent/LodgeInfoComponent"
import LodgeInfoGallery from "./LodgeInfoGallery/LodgeInfoGallery"
import { ReactNode } from "react"
@@ -10,25 +11,43 @@ export interface ILodgeInfo {
/**
* List of image srcs
*/
- images?: string[]
+ imageSrcs?: string[]
/**
* Handler to be called once the user clicks the call to action
*/
handleBookLodgeClick?: () => void
}
-const LodgeInfo = ({ children, images, handleBookLodgeClick }: ILodgeInfo) => {
+/**
+ * Component displaying information about the lodge before the user makes a booking
+ *
+ * Use case - if someone new to the club wants to know what the lodge is, or are unsure about
+ * how to prepare/find more information
+ */
+const LodgeInfo = ({
+ children,
+ imageSrcs,
+ handleBookLodgeClick
+}: ILodgeInfo) => {
return (
-
-
-
+
+
+
-
- handleBookLodgeClick?.()}
- >
- {children}
-
+
+
+ handleBookLodgeClick?.()}
+ >
+ {children}
+
+
+
+
+
+
)
diff --git a/client/src/components/composite/LodgeInfo/LodgeInfoComponent/LodgeInfoComponent.tsx b/client/src/components/composite/LodgeInfo/LodgeInfoComponent/LodgeInfoComponent.tsx
index 1fe968830..cb9dbe454 100644
--- a/client/src/components/composite/LodgeInfo/LodgeInfoComponent/LodgeInfoComponent.tsx
+++ b/client/src/components/composite/LodgeInfo/LodgeInfoComponent/LodgeInfoComponent.tsx
@@ -2,25 +2,35 @@ import Button from "@/components/generic/FigmaButtons/FigmaButton"
import { ReactNode } from "react"
interface ILodgeInfoComponent {
+ /**
+ * The **pre-rendered** children that should be displayed in the the container
+ * (This should generally be text content)
+ */
children: ReactNode
+ /**
+ * Handler to be called when call to action button is clicked
+ *
+ * @example
+ * () => navigateToActualBookLodgeScreen()
+ */
handleBookLodgeClick: () => void
}
+/**
+ * @deprecated do not consume directly on page, use `LodgeInfo` instead
+ */
const LodgeInfoComponent = ({
children,
handleBookLodgeClick
}: ILodgeInfoComponent) => {
return (
-
-
+
+
{children}
-
-
-
-
+
)
}
diff --git a/client/src/components/composite/LodgeInfo/LodgeInfoGallery/LodgeInfoGallery.story.tsx b/client/src/components/composite/LodgeInfo/LodgeInfoGallery/LodgeInfoGallery.story.tsx
index 6eedc050f..fee1711d0 100644
--- a/client/src/components/composite/LodgeInfo/LodgeInfoGallery/LodgeInfoGallery.story.tsx
+++ b/client/src/components/composite/LodgeInfo/LodgeInfoGallery/LodgeInfoGallery.story.tsx
@@ -11,7 +11,7 @@ type Story = StoryObj
export const Default: Story = {
args: {
- images: [
+ imageSrcs: [
"https://via.placeholder.com/400x400?text=Image+1",
"https://via.placeholder.com/400x400?text=Image+2",
"https://via.placeholder.com/400x400?text=Image+3",
@@ -23,14 +23,14 @@ export const Default: Story = {
export const SingleImage: Story = {
args: {
- images: ["https://via.placeholder.com/400x400?text=Single+Image"]
+ imageSrcs: ["https://via.placeholder.com/400x400?text=Single+Image"]
},
tags: ["autodocs"]
}
export const NoImages: Story = {
args: {
- images: []
+ imageSrcs: []
},
tags: ["autodocs"]
}
diff --git a/client/src/components/composite/LodgeInfo/LodgeInfoGallery/LodgeInfoGallery.tsx b/client/src/components/composite/LodgeInfo/LodgeInfoGallery/LodgeInfoGallery.tsx
index c5a6e9a32..6d60c34e3 100644
--- a/client/src/components/composite/LodgeInfo/LodgeInfoGallery/LodgeInfoGallery.tsx
+++ b/client/src/components/composite/LodgeInfo/LodgeInfoGallery/LodgeInfoGallery.tsx
@@ -1,57 +1,40 @@
-import { useState, FC } from "react"
import Image from "next/image"
-import RightArrow from "@/assets/icons/whitearrowright.svg"
-import LeftArrow from "@/assets/icons/whitearrowleft.svg"
-interface LodgeInfoGalleryProps {
- images: string[]
+interface ILodgeInfoGallery {
+ /**
+ * A list of srcs for all the images in the gallery.
+ *
+ * This should be **pre-sorted** and **unique**
+ *
+ * @example
+ * ['https://image-url-1.com', 'https://image-url-2.com', 'https://image-url-3.com']
+ */
+ imageSrcs: string[]
}
-const LodgeInfoGallery: FC = ({ images }) => {
- const [currentIndex, setCurrentIndex] = useState(0)
-
- const handlePreviousClick = () => {
- setCurrentIndex((prevIndex) =>
- prevIndex === 0 ? images.length - 1 : prevIndex - 1
- )
- }
-
- const handleNextClick = () => {
- setCurrentIndex((prevIndex) =>
- prevIndex === images.length - 1 ? 0 : prevIndex + 1
- )
- }
-
+/**
+ * Simple photo gallery that displays images in a single row (can be scrolled horizontally)
+ */
+const LodgeInfoGallery = ({ imageSrcs = [] }: ILodgeInfoGallery) => {
return (
-
- {images.length > 0 ? (
-
- ) : (
-
No images available
- )}
-
-
-
-
+ <>
+
+ {imageSrcs.map((url, index) => (
+ <>
+ {/* We require a `max-width` style to constrain the image on smaller screens */}
+