Skip to content
Open
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: 2 additions & 0 deletions apps/next/src/app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { useEffect, useState } from "react";

import PopularDishCard from "@/components/ui/card/popular-dish-card";
import UpcomingEventCard from "@/components/ui/card/upcoming-event-card";
import HomeOnboarding from "@/components/ui/home-onboarding";
import OnboardingDialog from "@/components/ui/onboarding";
import PageContainer from "@/components/ui/page-container";
import { useDate } from "@/context/date-context";
Expand Down Expand Up @@ -118,6 +119,7 @@ export default function Home() {
return (
<>
{showOnboardDialog && <OnboardingDialog />}
<HomeOnboarding />
{isDesktop ? <DesktopHome /> : <MobileHome />}
</>
);
Expand Down
95 changes: 95 additions & 0 deletions apps/next/src/components/ui/home-onboarding.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
"use client";

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

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

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

const placement = isDesktop ? "bottom-end" : "top";
const steps: Step[] = [
{
target: "#tour-home-dining",
title: "Switch Dining Halls",
content: isDesktop
? "Click here to switch between Brandywine and Anteatery dining halls."
: "Tap Dining to view menus, then switch between Brandywine and Anteatery dining halls.",
placement,
},
{
target: "#tour-home-events",
title: "Explore Events",
content: "View upcoming dining hall events and special celebrations.",
placement,
},
{
target: "#tour-home-my-foods",
title: "My Foods",
content:
"Access all the dishes you've rated and favorited across UCI dining halls.",
placement,
},
{
target: "#tour-home-tracker",
title: "Meal Tracker",
content:
"Track your daily nutrition and monitor your progress towards your goals.",
placement,
},
{
target: isDesktop ? "#tour-help-desktop" : "#tour-help-mobile",
title: "Need this tutorial again?",
content: isDesktop
? "Click the help icon anytime to restart this tutorial!"
: "Tap the help icon anytime to restart this tutorial!",
placement: "bottom-end",
},
];

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

if (!running) return null;

return (
<Joyride
key={`${launchId}-${isDesktop}`}
steps={steps}
run
continuous
onEvent={handleEvent}
tooltipComponent={CustomTooltip}
locale={{ last: "Done", skip: "Skip Tour" }}
floatingOptions={{ hideArrow: true }}
options={{
skipBeacon: true,
skipScroll: true,
overlayColor: "rgba(0, 0, 0, 0.2)",
spotlightPadding: 4,
spotlightRadius: 8,
overlayClickAction: false,
blockTargetInteraction: true,
zIndex: 1500,
}}
/>
);
}
18 changes: 18 additions & 0 deletions apps/next/src/components/ui/toolbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ import { WelcomeView } from "./onboarding";
import SidebarContent from "./sidebar/sidebar-content";

const TOURS_BY_PATH: Record<string, { id: TourId; label: string }> = {
"/": {
id: "home",
label: "Home page tutorial",
},
"/nutrition": {
id: "nutrition",
label: "Tracker tutorial",
Expand Down Expand Up @@ -75,6 +79,7 @@ export type CalendarRange = {
type ToolbarElement = {
/* The display name of the link */
title: string;
tourId?: string;
/* If present, will hyperlink to the href */
href?: string;
/* If present, will create a dropdown of each of the children */
Expand All @@ -86,6 +91,7 @@ type ToolbarElement = {
const DESKTOP_TOOLBAR_ELEMENTS: ToolbarElement[] = [
{
title: "Dining Halls",
tourId: "tour-home-dining",
children: [
{
title: "Brandywine",
Expand All @@ -99,14 +105,17 @@ const DESKTOP_TOOLBAR_ELEMENTS: ToolbarElement[] = [
},
{
title: "Events",
tourId: "tour-home-events",
href: "/events",
},
{
title: "My Foods",
tourId: "tour-home-my-foods",
href: "/my-foods",
},
{
title: "Tracker",
tourId: "tour-home-tracker",
href: "/nutrition",
},
];
Expand All @@ -119,21 +128,25 @@ const MOBILE_TOOLBAR_ELEMENTS: ToolbarElement[] = [
},
{
title: "Dining",
tourId: "tour-home-dining",
href: "/brandywine", // defaults to brandywine for now, we'd need to add anteatery
icon: <RestaurantRoundedIcon />,
},
{
title: "Events",
tourId: "tour-home-events",
href: "/events",
icon: <InsertInvitation />,
},
{
title: "My Foods",
tourId: "tour-home-my-foods",
href: "/my-foods",
icon: <FavoriteBorder />,
},
{
title: "Tracker",
tourId: "tour-home-tracker",
href: "/nutrition",
icon: <ListAltRoundedIcon />,
},
Expand Down Expand Up @@ -166,6 +179,7 @@ function ToolbarDropdown({
return (
<>
<Button
id={element.tourId}
onClick={handleClick}
endIcon={<ArrowDropDownIcon fontSize="small" />}
className={`capitalize text-[20px] !font-medium bg-transparent ${
Expand Down Expand Up @@ -338,6 +352,7 @@ export function DesktopToolbar(): React.JSX.Element {
return (
<Button
key={element.title}
id={element.tourId}
component={Link}
href={element.href || "#"}
className={`normal-case text-[20px] !font-medium ${
Expand All @@ -359,6 +374,7 @@ export function DesktopToolbar(): React.JSX.Element {
<Tooltip title={tour.label}>
<span>
<IconButton
id="tour-help-desktop"
onClick={() => start(tour.id)}
aria-label={`Start ${tour.label.toLowerCase()}`}
sx={{ color: isTransparent ? "white" : "text.primary" }}
Expand Down Expand Up @@ -657,6 +673,7 @@ function MobileToolbar(): React.JSX.Element {
<Tooltip title={tour.label}>
<span>
<IconButton
id="tour-help-mobile"
onClick={() => start(tour.id)}
aria-label={`Start ${tour.label.toLowerCase()}`}
sx={{ color: isTransparent ? "white" : "text.primary" }}
Expand Down Expand Up @@ -749,6 +766,7 @@ function MobileToolbar(): React.JSX.Element {
return (
<Link
key={element.title}
id={element.tourId}
href={effectiveHref}
className={`
flex flex-col items-center justify-center
Expand Down
2 changes: 1 addition & 1 deletion apps/next/src/components/ui/tracker-onboarding.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export const CustomTooltip = ({
return (
<div
{...tooltipProps}
className="bg-white dark:bg-[#323235] p-5 rounded-lg shadow-xl w-80 flex flex-col gap-2 relative"
className="bg-white dark:bg-[#323235] p-5 rounded-lg shadow-xl w-80 max-w-[calc(100vw-2rem)] flex flex-col gap-2 relative"
>
<button
{...skipProps}
Expand Down
7 changes: 6 additions & 1 deletion apps/next/src/context/useTourStore.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
import { create } from "zustand";

export type TourId = "nutrition" | "events" | "my-foods" | "restaurant";
export type TourId =
| "home"
| "nutrition"
| "events"
| "my-foods"
| "restaurant";

type TourState = {
activeTour: TourId | null;
Expand Down
Loading