Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion apps/next/src/components/ui/my-foods-onboarding.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export default function MyFoodsOnboarding() {
options={{
skipBeacon: true,
overlayClickAction: false,
blockTargetInteraction: false,
blockTargetInteraction: true,
zIndex: 1500,
}}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export function DesktopTabs({
)}
{/* Card / compact view toggles */}
<div className="flex justify-end mt-2">
<div className="flex gap-2">
<div id="tour-view-toggle-desktop" className="flex gap-2">
<Button
variant="outlined"
size="small"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ export function RestaurantFilters({
: "grid grid-cols-2 gap-3 w-full"
}
>
<div className={isDesktop ? "w-52 grow" : "w-full"}>
<div id="tour-meal-select" className={isDesktop ? "w-52 grow" : "w-full"}>
<FormControl fullWidth size="small" variant="outlined">
<InputLabel
id="meal-select-label"
Expand Down Expand Up @@ -166,7 +166,10 @@ export function RestaurantFilters({
</div>

{calendarRange && (
<div className={isDesktop ? "w-[240px] grow" : "w-full"}>
<div
id="tour-date-picker"
className={isDesktop ? "w-[240px] grow" : "w-full"}
>
<LocalizationProvider dateAdapter={AdapterDateFns}>
<DatePicker
label="Select date"
Expand Down
78 changes: 61 additions & 17 deletions apps/next/src/components/ui/restaurant/restaurant-controls.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
import type { Station } from "@api/index";
import { MoreHoriz } from "@mui/icons-material";
import { IconButton, Typography } from "@mui/material";
import type { DishWithRating, Event } from "@peterplate/validators";
import { DiningHallStatus } from "@/components/ui/status";
import type { CalendarRange } from "@/components/ui/toolbar";
import { useRestaurantUIStore } from "@/context/useRestaurantUIStore";
import { toTitleCase } from "@/utils/funcs";
import type { HallEnum, HallStatusEnum } from "@/utils/types";
import { DesktopTabs } from "./header/desktop-tabs";
import { MobileActions } from "./header/mobile-actions";
Expand Down Expand Up @@ -41,6 +45,13 @@ export function RestaurantControls({
stations,
hallEvents,
}: RestaurantControlsProps) {
const isFiltersExpanded = useRestaurantUIStore((s) => s.isFiltersExpanded);
const setIsFiltersExpanded = useRestaurantUIStore(
(s) => s.setIsFiltersExpanded,
);
const selectedPeriod = useRestaurantUIStore((s) => s.selectedPeriod);
const showFilters = isDesktop || isFiltersExpanded;

return (
// Sticky while scrolling
<div
Expand All @@ -58,26 +69,59 @@ export function RestaurantControls({
</div>
)}

<div className="flex flex-col gap-3 w-full md:w-auto md:grow md:flex-row md:items-center md:justify-end">
{/* Mobile summary row — the button expands the filters below */}
{!isDesktop && (
<div className="flex w-full items-center justify-between px-3">
<div className="flex items-baseline gap-4 text-sky-700 dark:text-blue-300">
<Typography variant="h6" fontWeight={700} component="span">
{selectedDate
? `${selectedDate.toLocaleDateString("en-US")} (${selectedDate.toLocaleDateString("en-US", { weekday: "short" })})`
: ""}
</Typography>
<Typography variant="body1" component="span">
{toTitleCase(selectedPeriod)}
</Typography>
</div>
<IconButton
id="tour-expand-filters"
onClick={() => setIsFiltersExpanded(!isFiltersExpanded)}
aria-label={isFiltersExpanded ? "Hide filters" : "Show filters"}
aria-expanded={isFiltersExpanded}
size="small"
className="!text-sky-700 dark:!text-blue-300"
>
<MoreHoriz />
</IconButton>
</div>
)}

<div
id="tour-filters-mobile"
className="flex flex-col gap-3 w-full md:w-auto md:grow md:flex-row md:items-center md:justify-end"
>
{/* Meal & date selectors */}
<RestaurantFilters
isDesktop={isDesktop}
periods={periods}
availablePeriodTimes={availablePeriodTimes}
selectedDate={selectedDate}
handleDateSelect={handleDateSelect}
calendarRange={calendarRange}
/>
{showFilters && (
<RestaurantFilters
isDesktop={isDesktop}
periods={periods}
availablePeriodTimes={availablePeriodTimes}
selectedDate={selectedDate}
handleDateSelect={handleDateSelect}
calendarRange={calendarRange}
/>
)}

{/* Menu / schedule drawers & view-toggle (mobile only) */}
<MobileActions
isDesktop={isDesktop}
isLoading={isLoading}
isError={isError}
dishes={dishes}
stations={stations}
hallEvents={hallEvents}
/>
{showFilters && (
<MobileActions
isDesktop={isDesktop}
isLoading={isLoading}
isError={isError}
dishes={dishes}
stations={stations}
hallEvents={hallEvents}
/>
)}
</div>
</div>

Expand Down
152 changes: 152 additions & 0 deletions apps/next/src/components/ui/restaurant/restaurant-onboarding.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
"use client";

import { useEffect } from "react";
import { type EventData, Joyride, STATUS, type Step } from "react-joyride";
import { useRestaurantUIStore } from "@/context/useRestaurantUIStore";
import { useTourStore } from "@/context/useTourStore";
import { useMediaQuery } from "@/hooks/useMediaQuery";
import { CustomTooltip } from "../tracker-onboarding";

const FOOD_CARD_TARGET = "#food-scroll .MuiCard-root";
// Leaves room below the card for the tooltip instead of scrolling it to the bottom edge
const FOOD_CARD_SCROLL_OFFSET = 250;
const FAVORITE_TARGET = `${FOOD_CARD_TARGET} button[aria-label*="favorites"]`;

export default function RestaurantOnboarding() {
const running = useTourStore((state) => state.activeTour === "restaurant");
const launchId = useTourStore((state) => state.launchId);
const stop = useTourStore((state) => state.stop);
const isDesktop = useMediaQuery("(min-width: 768px)");

// Mobile starts collapsed so the "Expand Filters" step has something to expand
// biome-ignore lint/correctness/useExhaustiveDependencies: launchId re-collapses the filters every time the tour restarts
useEffect(() => {
if (running) useRestaurantUIStore.getState().setIsFiltersExpanded(false);
}, [running, launchId]);

const desktopSteps: Step[] = [
{
target: "#tour-meal-select",
content:
"Choose which meal you want to see: breakfast, lunch, or dinner.",
title: "Select Meal Type",
skipBeacon: true,
placement: "bottom",
},
{
target: "#tour-date-picker",
content: "Select a date to view a menu for that specific day.",
title: "Pick a Date",
skipBeacon: true,
placement: "bottom",
},
{
target: "#tour-view-toggle-desktop",
content:
"Toggle between card or compact view to change how dishes are displayed.",
title: "Switch Views",
skipBeacon: true,
placement: "bottom",
},
{
target: FOOD_CARD_TARGET,
scrollOffset: FOOD_CARD_SCROLL_OFFSET,
content:
"Click the meal card to view its nutrition facts, add it to your meal tracker, or to rate the dish itself.",
title: "View Food Content",
skipBeacon: true,
placement: "right",
},
{
target: FAVORITE_TARGET,
scrollOffset: FOOD_CARD_SCROLL_OFFSET,
content:
"Click the heart button to favorite dishes and see them in your My Foods page.",
title: "Favorite Dishes",
skipBeacon: true,
placement: "right",
},
{
target: "#tour-special-schedules",
content: "Toggle to see upcoming schedule changes during certain breaks.",
title: "Special Schedules",
skipBeacon: true,
placement: "left",
},
];

const mobileSteps: Step[] = [
{
target: "#tour-switch-hall",
content:
"Click here to switch between Brandywine and Anteatery dining halls.",
title: "Switch Dining Halls",
skipBeacon: true,
placement: "bottom",
},
{
target: "#tour-expand-filters",
content: "Click the three buttons to open up food filters.",
title: "Expand Filters",
skipBeacon: true,
placement: "bottom",
},
{
target: "#tour-filters-mobile",
content:
"Use these filter buttons to filter out what foods you would like to see!",
title: "Filter Foods",
skipBeacon: true,
placement: "bottom",
before: async () => {
useRestaurantUIStore.getState().setIsFiltersExpanded(true);
},
},
{
target: FOOD_CARD_TARGET,
scrollOffset: FOOD_CARD_SCROLL_OFFSET,
content:
"Click the meal card to view its nutrition facts, add it to your meal tracker, or to rate the dish itself!",
title: "View Food Content",
skipBeacon: true,
placement: "bottom",
},
{
target: FAVORITE_TARGET,
scrollOffset: FOOD_CARD_SCROLL_OFFSET,
content:
"Click the heart button to favorite dishes and see them in your My Foods page.",
title: "Favorite Dishes",
skipBeacon: true,
placement: "bottom",
},
];

const handleEvent = ({ status, action }: EventData) => {
if (
status === STATUS.FINISHED ||
status === STATUS.SKIPPED ||
action === "close"
)
stop();
};

if (!running) return null;
return (
<Joyride
key={launchId}
steps={isDesktop ? desktopSteps : mobileSteps}
run
continuous
scrollToFirstStep
onEvent={handleEvent}
tooltipComponent={CustomTooltip}
options={{
skipBeacon: true,
overlayClickAction: false,
blockTargetInteraction: true,
zIndex: 1500,
}}
/>
);
}
22 changes: 21 additions & 1 deletion apps/next/src/components/ui/restaurant/restaurant-page.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
"use client";

import type { AppRouter } from "@api/index";
import { LocationOn } from "@mui/icons-material";
import { LocationOn, SwapHorizOutlined } from "@mui/icons-material";
import { Box, Container, Link, Typography } from "@mui/material";
import type { TRPCClientErrorLike } from "@trpc/client";
import Image from "next/image";
import NextLink from "next/link";
import { useEffect } from "react";
import { useTourStore } from "@/context/useTourStore";
import { useMediaQuery } from "@/hooks/useMediaQuery";
import { useRestaurantPage } from "@/hooks/useRestaurantPage";
import { cn } from "@/utils/tw";
Expand All @@ -16,6 +19,7 @@ import {
import { DiningHallStatus } from "../status";
import { DishesView } from "./dishes-view";
import { RestaurantControls } from "./restaurant-controls";
import RestaurantOnboarding from "./restaurant-onboarding";
import { Sidebar } from "./sidebar";
import RestaurantSpinner from "./spinner";

Expand All @@ -28,6 +32,13 @@ export function RestaurantPage({
}: RestaurantPageProps): React.JSX.Element {
const isDesktop = useMediaQuery("(min-width: 768px)");

useEffect(() => {
return () => {
const { activeTour, stop } = useTourStore.getState();
if (activeTour === "restaurant") stop();
};
}, []);

const {
hallData,
isLoading,
Expand All @@ -54,6 +65,7 @@ export function RestaurantPage({

return (
<Box sx={{ bgcolor: "background.default", minHeight: "100vh" }}>
<RestaurantOnboarding />
{/* Hero image & mobile header */}
<div className="relative w-full h-[200px] md:h-[250px]">
<Image
Expand Down Expand Up @@ -96,6 +108,14 @@ export function RestaurantPage({
? "4001 Mesa Rd, Irvine, CA 92617"
: "Middle Earth Community Irvine, CA 92697"}
</Link>
<NextLink
id="tour-switch-hall"
href={hall === HallEnum.ANTEATERY ? "/brandywine" : "/anteatery"}
aria-label={`Switch to ${hall === HallEnum.ANTEATERY ? "Brandywine" : "Anteatery"}`}
className="absolute bottom-[19px] right-3.5 flex h-8 w-8 items-center justify-center rounded-md bg-white text-sky-700"
>
<SwapHorizOutlined />
</NextLink>
</div>
)}
</div>
Expand Down
5 changes: 4 additions & 1 deletion apps/next/src/components/ui/restaurant/sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,16 @@ interface SidebarProps {

function SidebarSection({
title,
id,
children,
}: {
title: string;
id?: string;
children: React.ReactNode;
}) {
return (
<Paper
id={id}
elevation={0}
className="mb-4 overflow-hidden dark:bg-[var(--surface-modal)]"
sx={{ border: 1, borderColor: "divider" }}
Expand Down Expand Up @@ -147,7 +150,7 @@ export function Sidebar({
</SidebarSection>

{/* Special Schedules card */}
<SidebarSection title="Special Schedules">
<SidebarSection title="Special Schedules" id="tour-special-schedules">
{hallEvents.length > 0 ? (
<div className="space-y-2">
{hallEvents.map((event) => {
Expand Down
8 changes: 8 additions & 0 deletions apps/next/src/components/ui/toolbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,14 @@ const TOURS_BY_PATH: Record<string, { id: TourId; label: string }> = {
id: "my-foods",
label: "My Foods tutorial",
},
"/anteatery": {
id: "restaurant",
label: "Restaurant tutorial",
},
"/brandywine": {
id: "restaurant",
label: "Restaurant tutorial",
},
};

export type CalendarRange = {
Expand Down
Loading
Loading