From 00deef4f6da0931b2d8d582563459709ebbde653 Mon Sep 17 00:00:00 2001 From: "modeinspect-eu[bot]" <204106916+modeinspect-eu[bot]@users.noreply.github.com> Date: Mon, 5 May 2025 15:22:47 +0000 Subject: [PATCH] "Added interactive seat visualization with toggle controls for seat types and sizes, and created a customizable Seat component for improved flight booking experience" --- src/app/page.tsx | 183 ++++++++++++++++++++++++++++++++++++- src/components/ui/seat.tsx | 77 ++++++++++++++++ 2 files changed, 259 insertions(+), 1 deletion(-) create mode 100644 src/components/ui/seat.tsx diff --git a/src/app/page.tsx b/src/app/page.tsx index 07a01d9..6172c35 100644 --- a/src/app/page.tsx +++ b/src/app/page.tsx @@ -1,3 +1,184 @@ +"use client"; + +import { useState } from "react"; +import { Seat } from "@/components/ui/seat"; + export default function Home() { - return (
); + // State for controlling seat properties + const [seatType, setSeatType] = useState<"window" | "middle" | "aisle">("window"); + const [seatSize, setSeatSize] = useState<"default" | "sm" | "lg">("default"); + const [showAllTypes, setShowAllTypes] = useState(true); + const [showAllSizes, setShowAllSizes] = useState(true); + + return ( +
+

Kiwi.com Seat Selection

+ + {/* Toggle controls */} +
+

Toggle Controls

+ +
+ {/* Seat Type Controls */} +
+
+

Seat Type:

+ +
+ + {!showAllTypes && ( +
+ {["window", "middle", "aisle"].map((type) => ( + + ))} +
+ )} +
+ + {/* Seat Size Controls */} +
+
+

Seat Size:

+ +
+ + {!showAllSizes && ( +
+ {[ + { value: "default", label: "Default" }, + { value: "sm", label: "Small" }, + { value: "lg", label: "Large" } + ].map((size) => ( + + ))} +
+ )} +
+
+
+ + {/* Display seats based on toggle state */} + {showAllTypes ? ( +
+
+ +

Window Seat

+
+ +
+ +

Middle Seat

+
+ +
+ +

Aisle Seat

+
+
+ ) : ( +
+ +

{seatType} Seat

+
+ )} + + {/* Size variations */} + {showAllSizes ? ( +
+

Size Variations

+
+
+ +

Small

+
+ +
+ +

Default

+
+ +
+ +

Large

+
+
+
+ ) : ( +
+ +

+ {seatSize === "default" ? "Default" : seatSize === "sm" ? "Small" : "Large"} Size +

+
+ )} +
+ ); } diff --git a/src/components/ui/seat.tsx b/src/components/ui/seat.tsx new file mode 100644 index 0000000..1bd9cae --- /dev/null +++ b/src/components/ui/seat.tsx @@ -0,0 +1,77 @@ +import * as React from "react" +import { cva, type VariantProps } from "class-variance-authority" + +import { cn } from "@/lib/utils" + +const seatVariants = cva( + "inline-flex flex-col items-center justify-center rounded-md border text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 relative overflow-hidden", + { + variants: { + variant: { + window: "bg-blue-50 border-blue-200 hover:bg-blue-100", + aisle: "bg-green-50 border-green-200 hover:bg-green-100", + middle: "bg-gray-50 border-gray-200 hover:bg-gray-100", + }, + size: { + default: "h-16 w-12", + sm: "h-12 w-9", + lg: "h-20 w-16", + }, + }, + defaultVariants: { + variant: "middle", + size: "default", + }, + } +) + +export interface SeatProps + extends React.HTMLAttributes, + VariantProps { + title?: string + seatType?: "window" | "aisle" | "middle" +} + +const Seat = React.forwardRef( + ({ className, variant, size, title, seatType, ...props }, ref) => { + // Use the seatType to determine the variant if provided + const seatVariant = seatType || variant + + return ( +
+ {/* Seat title (e.g., 24B) */} +
{title}
+ + {/* Seat type label */} +
+ {seatType || variant} +
+ + {/* Seat icon visual */} +
+ + + + +
+
+ ) + } +) + +Seat.displayName = "Seat" + +export { Seat, seatVariants } \ No newline at end of file