Trip planner app
A city trip day by day: a big cover photo, day tabs that stick to the top, and a timeline of photo stops that fills in blue up to where you are now.
"use client";
import {
useEffect,
useLayoutEffect,
useRef,
useState,
type CSSProperties,
type PointerEvent,
} from "react";
import "./trip-planner.css";
export type Stop = {
time: string;
title: string;
place: string;
photo: string;
/** How long you stay, e.g. "1h 30m". */
stay: string;
/** Walking minutes to the next stop. */
walk?: number;
note: string;
};
export type Day = { label: string; date: string; stops: Stop[] };
type TripPlannerProps = {
city: string;
dates: string;
cover: string;
days: Day[];
/** Where you are right now: which day and which stop. */
now?: { day: number; stop: number };
};
type Box = { x: number; y: number; w: number; h: number; r: number };
const EASE = "cubic-bezier(0.2, 0.85, 0.2, 1)";
/**
* TripPlanner: a city trip, day by day.
* - A big cover that drifts slower than the page (parallax), then day tabs that stick under the status bar.
* - Each day is a timeline whose line draws itself down; the day slides in from the side you picked.
* - Tap a stop: its photo flies out of the card and grows into the sheet. Drag the sheet down (or tap outside) and the photo flies back.
*/
export function TripPlanner({
city,
dates,
cover,
days,
now,
}: TripPlannerProps) {
const [day, setDay] = useState(now?.day ?? 0);
const [dir, setDir] = useState(0);
const [open, setOpen] = useState<Stop | null>(null);
const [leaving, setLeaving] = useState(false);
const [saved, setSaved] = useState<Set<string>>(new Set());
const [stuck, setStuck] = useState(false);
const root = useRef<HTMLDivElement>(null);
const scroller = useRef<HTMLDivElement>(null);
const plan = useRef<HTMLDivElement>(null);
const coverEl = useRef<HTMLElement>(null);
const bar = useRef<HTMLDivElement>(null);
const sheet = useRef<HTMLDivElement>(null);
const sheetPhoto = useRef<HTMLImageElement>(null);
const backdrop = useRef<HTMLDivElement>(null);
const ghost = useRef<HTMLDivElement>(null);
const closeBtn = useRef<HTMLButtonElement>(null);
const lastCard = useRef<HTMLButtonElement | null>(null);
const drag = useRef<{ y: number; t: number; dy: number; v: number } | null>(
null,
);
const d = days[day];
const here =
now && now.day === day
? now.stop
: day < (now?.day ?? 0)
? d.stops.length
: -1;
const calm = () =>
window.matchMedia("(prefers-reduced-motion: reduce)").matches;
/** Where an element is, in the app's own pixels (the app may be scaled, e.g. inside a phone mockup). */
const boxOf = (el: Element, radius: number): Box => {
const host = root.current!;
const hb = host.getBoundingClientRect();
const k = hb.width / host.offsetWidth || 1;
const b = el.getBoundingClientRect();
return {
x: (b.left - hb.left) / k,
y: (b.top - hb.top) / k,
w: b.width / k,
h: b.height / k,
r: radius,
};
};
/** The shared photo: one image flies between the card and the sheet. */
const fly = (
src: string,
from: Box,
to: Box,
hide: (HTMLElement | null)[],
done?: () => void,
) => {
const g = ghost.current;
if (!g || calm()) return done?.();
hide.forEach((el) => el && (el.style.visibility = "hidden"));
g.style.backgroundImage = `url("${src}")`;
g.hidden = false;
const px = (b: Box) => ({
left: `${b.x}px`,
top: `${b.y}px`,
width: `${b.w}px`,
height: `${b.h}px`,
borderRadius: `${b.r}px`,
});
const anim = g.animate([px(from), px(to)], {
duration: 560,
easing: EASE,
fill: "forwards",
});
anim.onfinish = () => {
hide.forEach((el) => el && (el.style.visibility = ""));
g.hidden = true;
anim.cancel();
done?.();
};
};
// Opening: the card's photo grows into the sheet's photo while the sheet rises.
useLayoutEffect(() => {
if (!open || leaving) return;
const img = lastCard.current?.querySelector("img");
const s = sheet.current;
const p = sheetPhoto.current;
if (!img || !s || !p) return;
// Measured without transforms: where the photo will be once the sheet has risen.
const to: Box = {
x: s.offsetLeft + p.offsetLeft,
y: s.offsetTop + p.offsetTop,
w: p.offsetWidth,
h: p.offsetHeight,
r: 22,
};
fly(open.photo, boxOf(img, 14), to, [img, p]);
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [open]);
const close = () => {
if (!open || leaving) return;
const img = lastCard.current?.querySelector("img");
const p = sheetPhoto.current;
setLeaving(true);
const finish = () => {
setOpen(null);
setLeaving(false);
lastCard.current?.focus();
};
if (img && p)
fly(open.photo, boxOf(p, 22), boxOf(img, 14), [img, p], finish);
else finish();
};
useEffect(() => {
if (!open) return;
closeBtn.current?.focus({ preventScroll: true });
const onKey = (e: KeyboardEvent) => e.key === "Escape" && close();
window.addEventListener("keydown", onKey);
return () => window.removeEventListener("keydown", onKey);
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [open]);
// Drag the sheet down to close it. A quick flick closes it too.
const sheetDown = (e: PointerEvent<HTMLDivElement>) => {
if ((e.target as HTMLElement).closest("button") || leaving) return;
e.currentTarget.setPointerCapture(e.pointerId);
drag.current = { y: e.clientY, t: performance.now(), dy: 0, v: 0 };
e.currentTarget.dataset.dragging = "true";
};
const sheetMove = (e: PointerEvent<HTMLDivElement>) => {
const g = drag.current;
if (!g) return;
const raw = e.clientY - g.y;
const dy = raw < 0 ? raw * 0.15 : raw; // pulling up resists
const t = performance.now();
g.v = (dy - g.dy) / Math.max(1, t - g.t);
g.dy = dy;
g.t = t;
e.currentTarget.style.transform = `translateY(${dy}px)`;
backdrop.current?.style.setProperty(
"opacity",
`${Math.max(0, 1 - dy / 400)}`,
);
};
const sheetUp = (e: PointerEvent<HTMLDivElement>) => {
const g = drag.current;
if (!g) return;
drag.current = null;
const el = e.currentTarget;
el.dataset.dragging = "false";
backdrop.current?.style.removeProperty("opacity");
if (g.dy > 110 || g.v > 0.6) close();
else el.style.transform = "";
};
const pick = (i: number) => {
if (i === day) return;
setDir(i - day);
setDay(i);
// Bring the plan back to the top of the new day, under the sticky tabs.
const sc = scroller.current;
const p = plan.current;
if (sc && p && sc.scrollTop > p.offsetTop - 140)
sc.scrollTo({
top: p.offsetTop - 140,
behavior: calm() ? "auto" : "smooth",
});
};
const onScroll = () => {
const sc = scroller.current;
if (!sc || !coverEl.current || !bar.current) return;
// Parallax for the cover, kept on the cover so nothing else restyles while scrolling.
coverEl.current.style.setProperty("--sy", `${Math.min(sc.scrollTop, 400)}`);
// Once the cover has scrolled away, the area behind the status bar turns solid.
setStuck(
sc.scrollTop + bar.current.offsetHeight >= coverEl.current.offsetHeight,
);
};
const toggleSave = (title: string) =>
setSaved((s) => {
const c = new Set(s);
if (c.has(title)) c.delete(title);
else c.add(title);
return c;
});
return (
<div ref={root} className="gu-trip" data-stuck={stuck}>
<div ref={bar} className="gu-trip__bar" aria-hidden="true" />
<div ref={scroller} className="gu-trip__scroll" onScroll={onScroll}>
<header ref={coverEl} className="gu-trip__cover">
<img src={cover} alt="" />
<div className="gu-trip__cover-text">
<p>{dates}</p>
<h2>
{city.split("").map((ch, i) => (
<span key={i} style={{ "--i": i } as CSSProperties}>
{ch}
</span>
))}
</h2>
</div>
</header>
<nav className="gu-trip__days" aria-label="Days">
{days.map((x, i) => (
<button
key={x.label}
type="button"
aria-current={i === day ? "true" : undefined}
onClick={() => pick(i)}
>
<strong>{x.label}</strong>
<span>{x.date}</span>
</button>
))}
</nav>
<div
ref={plan}
className="gu-trip__plan"
key={day}
data-dir={dir > 0 ? "left" : dir < 0 ? "right" : "none"}
>
<p className="gu-trip__summary">
{d.stops.length} stops ·{" "}
{d.stops.reduce((n, s) => n + (s.walk ?? 0), 0)} min walking
</p>
<ol className="gu-trip__list">
{d.stops.map((s, i) => (
<li
key={s.title}
className="gu-trip__stop"
data-state={i < here ? "done" : i === here ? "here" : "next"}
style={{ "--i": i } as CSSProperties}
>
<span className="gu-trip__time">{s.time}</span>
<span className="gu-trip__rail" aria-hidden="true">
<span className="gu-trip__dot" />
</span>
<div className="gu-trip__body">
{i === here && (
<span className="gu-trip__here">You are here</span>
)}
<button
type="button"
className="gu-trip__card"
aria-haspopup="dialog"
onClick={(e) => {
lastCard.current = e.currentTarget;
setOpen(s);
}}
>
<span className="gu-trip__thumb">
<img src={s.photo} alt="" />
</span>
<span className="gu-trip__card-text">
<strong>{s.title}</strong>
<span>{s.place}</span>
<span className="gu-trip__stay">{s.stay}</span>
</span>
{saved.has(s.title) && (
<span className="gu-trip__saved">
<span aria-hidden="true">♥</span>
<span className="gu-trip__sr">Saved</span>
</span>
)}
</button>
{s.walk && i < d.stops.length - 1 && (
<p className="gu-trip__walk">
<svg viewBox="0 0 24 24" aria-hidden="true">
<circle cx="13" cy="4" r="2" />
<path d="m9 21 2-6 3 3v3M7 12l3-4h4l2 4 2 1M11 15l1-5" />
</svg>
{s.walk} min walk
</p>
)}
</div>
</li>
))}
</ol>
</div>
</div>
{/* Stop sheet */}
<div
ref={backdrop}
className="gu-trip__backdrop"
data-leaving={leaving}
hidden={!open}
onClick={close}
aria-hidden="true"
/>
{open && (
<div
ref={sheet}
className="gu-trip__sheet"
data-leaving={leaving}
role="dialog"
aria-modal="true"
aria-label={open.title}
onPointerDown={sheetDown}
onPointerMove={sheetMove}
onPointerUp={sheetUp}
onPointerCancel={sheetUp}
>
<span className="gu-trip__grab" aria-hidden="true" />
<img
ref={sheetPhoto}
src={open.photo}
alt=""
className="gu-trip__sheet-photo"
draggable={false}
/>
<div className="gu-trip__sheet-text">
<p className="gu-trip__sheet-meta">
{open.time} · {open.stay}
</p>
<h3>{open.title}</h3>
<p className="gu-trip__sheet-place">{open.place}</p>
<p className="gu-trip__note">{open.note}</p>
</div>
<div className="gu-trip__actions">
<button
type="button"
className="gu-trip__save"
aria-pressed={saved.has(open.title)}
onClick={() => toggleSave(open.title)}
>
<span
className="gu-trip__heart"
key={String(saved.has(open.title))}
aria-hidden="true"
>
{saved.has(open.title) ? "♥" : "♡"}
</span>
{saved.has(open.title) ? "Saved" : "Save"}
</button>
<button
ref={closeBtn}
type="button"
className="gu-trip__close"
onClick={close}
>
Close
</button>
</div>
</div>
)}
{/* The flying photo, shared by the card and the sheet. */}
<div ref={ghost} className="gu-trip__ghost" aria-hidden="true" hidden />
</div>
);
}
Paste this into ChatGPT, Claude, Cursor, v0, Lovable or Bolt. It describes the layout, motion, colors and accessibility and includes the code, so the AI can rebuild it in any framework.
# Build this UI piece: Trip planner app
You are a senior front-end engineer. Recreate the piece below in my project. If I don't say which framework I use, ask once, then build it in that framework (React, Vue, Svelte, Angular, Astro, plain HTML/CSS/JS or anything else). Keep the behavior, motion, colors, spacing and accessibility exactly as described. Keep the code clean and commented for beginners.
## What it is
A trip planner screen for phones: a city trip laid out day by day. A big cover photo, day tabs that stick to the top as you scroll, and a vertical timeline of stops with photos and the walking time between them. The line fills in blue up to where you are now. Tap a stop to open it in a bottom sheet.
## Layout and look
- Fills its parent and scrolls inside itself. Paper white #f7f6f2, white cards, ink #15171a, muted #6f7276, tile blue #1f4fd1 for "you are here". System font.
- Cover: 300px photo with a dark gradient top and bottom, the dates (14px) and the city name (64px, weight 800, -0.05em) at the bottom left in white.
- Day tabs: sticky just below the status bar, frosted (blur 18px). Each tab shows "Day 1" and "Thu 14"; the active one is filled ink.
- Behind the status bar: transparent over the cover, then a solid ink strip fades in once the cover has scrolled away, so the status text stays readable.
- Timeline rows: a 44px time column, a 22px rail with a dot, and the card. The rail is dotted grey; done stops and the part above "you are here" are solid blue. The current dot has a blue halo and a ring that pings outward.
- Cards: white, radius 20px, a 76px rounded photo, title (16px bold), place (13px muted, one line) and a small stay chip. Done stops have a faded photo.
- Between stops: a walking icon and "12 min walk".
- Sheet: slides up over a dim backdrop; grab handle, 4:3 photo with 22px corners, time and stay in blue, title (26px), place, a note, and two 52px pill buttons: Save (toggles a heart) and Close.
## Behavior and motion
1. Stops rise in one after another (70ms apart) when a day opens.
2. Choosing a day while scrolled down brings the plan back to the top of the list, under the tabs.
3. Tapping a card opens the sheet (0.5s, cubic-bezier(0.16, 1, 0.3, 1)); Close, the backdrop or Escape closes it and focus goes back to the card.
4. Saved stops show a small red heart on their card.
Extra motion that makes it feel finished:
- The cover settles from a slight zoom and dim on load; the city name rises in letter by letter with a blur. On scroll the cover moves at half speed and swells slightly, and the title fades and lifts.
- A new day slides in 36px from the side of the tab you picked; the dotted line draws itself downward stop by stop and each dot pops in.
- Shared photo: tapping a card makes its photo fly out of the card and grow into the sheet's photo (one floating copy animated from the card's box to the sheet's box over 0.56s; measure in the app's own pixels if the app is scaled). Closing flies it back into the card.
- The sheet can be dragged down: it follows the finger (pulling up resists), the backdrop fades with it, and letting go past 110px or with a quick flick closes it; otherwise it springs back.
- Sheet text rises in after the photo lands (staggered 50ms). Saving pops a heart with a ring that bursts outward.
## Accessibility
- Day tabs use aria-current. The sheet is role="dialog" aria-modal with the stop's title as its label, and focus moves to Close when it opens.
- Photos are decorative (alt="") because the title and place are next to them.
- prefers-reduced-motion: no rising stops, no sliding sheet, no pinging ring.
## Props
city, dates, cover, days: { label, date, stops: { time, title, place, photo, stay, walk?, note }[] }[], now?: { day, stop }
## Reference implementation
The original is written in React with one plain CSS file. Dependencies: none (plain React and CSS). Translate it faithfully; do not add new libraries unless my framework needs them.
### TripPlanner.tsx
```tsx
"use client";
import {
useEffect,
useLayoutEffect,
useRef,
useState,
type CSSProperties,
type PointerEvent,
} from "react";
import "./trip-planner.css";
export type Stop = {
time: string;
title: string;
place: string;
photo: string;
/** How long you stay, e.g. "1h 30m". */
stay: string;
/** Walking minutes to the next stop. */
walk?: number;
note: string;
};
export type Day = { label: string; date: string; stops: Stop[] };
type TripPlannerProps = {
city: string;
dates: string;
cover: string;
days: Day[];
/** Where you are right now: which day and which stop. */
now?: { day: number; stop: number };
};
type Box = { x: number; y: number; w: number; h: number; r: number };
const EASE = "cubic-bezier(0.2, 0.85, 0.2, 1)";
/**
* TripPlanner: a city trip, day by day.
* - A big cover that drifts slower than the page (parallax), then day tabs that stick under the status bar.
* - Each day is a timeline whose line draws itself down; the day slides in from the side you picked.
* - Tap a stop: its photo flies out of the card and grows into the sheet. Drag the sheet down (or tap outside) and the photo flies back.
*/
export function TripPlanner({
city,
dates,
cover,
days,
now,
}: TripPlannerProps) {
const [day, setDay] = useState(now?.day ?? 0);
const [dir, setDir] = useState(0);
const [open, setOpen] = useState<Stop | null>(null);
const [leaving, setLeaving] = useState(false);
const [saved, setSaved] = useState<Set<string>>(new Set());
const [stuck, setStuck] = useState(false);
const root = useRef<HTMLDivElement>(null);
const scroller = useRef<HTMLDivElement>(null);
const plan = useRef<HTMLDivElement>(null);
const coverEl = useRef<HTMLElement>(null);
const bar = useRef<HTMLDivElement>(null);
const sheet = useRef<HTMLDivElement>(null);
const sheetPhoto = useRef<HTMLImageElement>(null);
const backdrop = useRef<HTMLDivElement>(null);
const ghost = useRef<HTMLDivElement>(null);
const closeBtn = useRef<HTMLButtonElement>(null);
const lastCard = useRef<HTMLButtonElement | null>(null);
const drag = useRef<{ y: number; t: number; dy: number; v: number } | null>(
null,
);
const d = days[day];
const here =
now && now.day === day
? now.stop
: day < (now?.day ?? 0)
? d.stops.length
: -1;
const calm = () =>
window.matchMedia("(prefers-reduced-motion: reduce)").matches;
/** Where an element is, in the app's own pixels (the app may be scaled, e.g. inside a phone mockup). */
const boxOf = (el: Element, radius: number): Box => {
const host = root.current!;
const hb = host.getBoundingClientRect();
const k = hb.width / host.offsetWidth || 1;
const b = el.getBoundingClientRect();
return {
x: (b.left - hb.left) / k,
y: (b.top - hb.top) / k,
w: b.width / k,
h: b.height / k,
r: radius,
};
};
/** The shared photo: one image flies between the card and the sheet. */
const fly = (
src: string,
from: Box,
to: Box,
hide: (HTMLElement | null)[],
done?: () => void,
) => {
const g = ghost.current;
if (!g || calm()) return done?.();
hide.forEach((el) => el && (el.style.visibility = "hidden"));
g.style.backgroundImage = `url("${src}")`;
g.hidden = false;
const px = (b: Box) => ({
left: `${b.x}px`,
top: `${b.y}px`,
width: `${b.w}px`,
height: `${b.h}px`,
borderRadius: `${b.r}px`,
});
const anim = g.animate([px(from), px(to)], {
duration: 560,
easing: EASE,
fill: "forwards",
});
anim.onfinish = () => {
hide.forEach((el) => el && (el.style.visibility = ""));
g.hidden = true;
anim.cancel();
done?.();
};
};
// Opening: the card's photo grows into the sheet's photo while the sheet rises.
useLayoutEffect(() => {
if (!open || leaving) return;
const img = lastCard.current?.querySelector("img");
const s = sheet.current;
const p = sheetPhoto.current;
if (!img || !s || !p) return;
// Measured without transforms: where the photo will be once the sheet has risen.
const to: Box = {
x: s.offsetLeft + p.offsetLeft,
y: s.offsetTop + p.offsetTop,
w: p.offsetWidth,
h: p.offsetHeight,
r: 22,
};
fly(open.photo, boxOf(img, 14), to, [img, p]);
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [open]);
const close = () => {
if (!open || leaving) return;
const img = lastCard.current?.querySelector("img");
const p = sheetPhoto.current;
setLeaving(true);
const finish = () => {
setOpen(null);
setLeaving(false);
lastCard.current?.focus();
};
if (img && p)
fly(open.photo, boxOf(p, 22), boxOf(img, 14), [img, p], finish);
else finish();
};
useEffect(() => {
if (!open) return;
closeBtn.current?.focus({ preventScroll: true });
const onKey = (e: KeyboardEvent) => e.key === "Escape" && close();
window.addEventListener("keydown", onKey);
return () => window.removeEventListener("keydown", onKey);
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [open]);
// Drag the sheet down to close it. A quick flick closes it too.
const sheetDown = (e: PointerEvent<HTMLDivElement>) => {
if ((e.target as HTMLElement).closest("button") || leaving) return;
e.currentTarget.setPointerCapture(e.pointerId);
drag.current = { y: e.clientY, t: performance.now(), dy: 0, v: 0 };
e.currentTarget.dataset.dragging = "true";
};
const sheetMove = (e: PointerEvent<HTMLDivElement>) => {
const g = drag.current;
if (!g) return;
const raw = e.clientY - g.y;
const dy = raw < 0 ? raw * 0.15 : raw; // pulling up resists
const t = performance.now();
g.v = (dy - g.dy) / Math.max(1, t - g.t);
g.dy = dy;
g.t = t;
e.currentTarget.style.transform = `translateY(${dy}px)`;
backdrop.current?.style.setProperty(
"opacity",
`${Math.max(0, 1 - dy / 400)}`,
);
};
const sheetUp = (e: PointerEvent<HTMLDivElement>) => {
const g = drag.current;
if (!g) return;
drag.current = null;
const el = e.currentTarget;
el.dataset.dragging = "false";
backdrop.current?.style.removeProperty("opacity");
if (g.dy > 110 || g.v > 0.6) close();
else el.style.transform = "";
};
const pick = (i: number) => {
if (i === day) return;
setDir(i - day);
setDay(i);
// Bring the plan back to the top of the new day, under the sticky tabs.
const sc = scroller.current;
const p = plan.current;
if (sc && p && sc.scrollTop > p.offsetTop - 140)
sc.scrollTo({
top: p.offsetTop - 140,
behavior: calm() ? "auto" : "smooth",
});
};
const onScroll = () => {
const sc = scroller.current;
if (!sc || !coverEl.current || !bar.current) return;
// Parallax for the cover, kept on the cover so nothing else restyles while scrolling.
coverEl.current.style.setProperty("--sy", `${Math.min(sc.scrollTop, 400)}`);
// Once the cover has scrolled away, the area behind the status bar turns solid.
setStuck(
sc.scrollTop + bar.current.offsetHeight >= coverEl.current.offsetHeight,
);
};
const toggleSave = (title: string) =>
setSaved((s) => {
const c = new Set(s);
if (c.has(title)) c.delete(title);
else c.add(title);
return c;
});
return (
<div ref={root} className="gu-trip" data-stuck={stuck}>
<div ref={bar} className="gu-trip__bar" aria-hidden="true" />
<div ref={scroller} className="gu-trip__scroll" onScroll={onScroll}>
<header ref={coverEl} className="gu-trip__cover">
<img src={cover} alt="" />
<div className="gu-trip__cover-text">
<p>{dates}</p>
<h2>
{city.split("").map((ch, i) => (
<span key={i} style={{ "--i": i } as CSSProperties}>
{ch}
</span>
))}
</h2>
</div>
</header>
<nav className="gu-trip__days" aria-label="Days">
{days.map((x, i) => (
<button
key={x.label}
type="button"
aria-current={i === day ? "true" : undefined}
onClick={() => pick(i)}
>
<strong>{x.label}</strong>
<span>{x.date}</span>
</button>
))}
</nav>
<div
ref={plan}
className="gu-trip__plan"
key={day}
data-dir={dir > 0 ? "left" : dir < 0 ? "right" : "none"}
>
<p className="gu-trip__summary">
{d.stops.length} stops ·{" "}
{d.stops.reduce((n, s) => n + (s.walk ?? 0), 0)} min walking
</p>
<ol className="gu-trip__list">
{d.stops.map((s, i) => (
<li
key={s.title}
className="gu-trip__stop"
data-state={i < here ? "done" : i === here ? "here" : "next"}
style={{ "--i": i } as CSSProperties}
>
<span className="gu-trip__time">{s.time}</span>
<span className="gu-trip__rail" aria-hidden="true">
<span className="gu-trip__dot" />
</span>
<div className="gu-trip__body">
{i === here && (
<span className="gu-trip__here">You are here</span>
)}
<button
type="button"
className="gu-trip__card"
aria-haspopup="dialog"
onClick={(e) => {
lastCard.current = e.currentTarget;
setOpen(s);
}}
>
<span className="gu-trip__thumb">
<img src={s.photo} alt="" />
</span>
<span className="gu-trip__card-text">
<strong>{s.title}</strong>
<span>{s.place}</span>
<span className="gu-trip__stay">{s.stay}</span>
</span>
{saved.has(s.title) && (
<span className="gu-trip__saved">
<span aria-hidden="true">♥</span>
<span className="gu-trip__sr">Saved</span>
</span>
)}
</button>
{s.walk && i < d.stops.length - 1 && (
<p className="gu-trip__walk">
<svg viewBox="0 0 24 24" aria-hidden="true">
<circle cx="13" cy="4" r="2" />
<path d="m9 21 2-6 3 3v3M7 12l3-4h4l2 4 2 1M11 15l1-5" />
</svg>
{s.walk} min walk
</p>
)}
</div>
</li>
))}
</ol>
</div>
</div>
{/* Stop sheet */}
<div
ref={backdrop}
className="gu-trip__backdrop"
data-leaving={leaving}
hidden={!open}
onClick={close}
aria-hidden="true"
/>
{open && (
<div
ref={sheet}
className="gu-trip__sheet"
data-leaving={leaving}
role="dialog"
aria-modal="true"
aria-label={open.title}
onPointerDown={sheetDown}
onPointerMove={sheetMove}
onPointerUp={sheetUp}
onPointerCancel={sheetUp}
>
<span className="gu-trip__grab" aria-hidden="true" />
<img
ref={sheetPhoto}
src={open.photo}
alt=""
className="gu-trip__sheet-photo"
draggable={false}
/>
<div className="gu-trip__sheet-text">
<p className="gu-trip__sheet-meta">
{open.time} · {open.stay}
</p>
<h3>{open.title}</h3>
<p className="gu-trip__sheet-place">{open.place}</p>
<p className="gu-trip__note">{open.note}</p>
</div>
<div className="gu-trip__actions">
<button
type="button"
className="gu-trip__save"
aria-pressed={saved.has(open.title)}
onClick={() => toggleSave(open.title)}
>
<span
className="gu-trip__heart"
key={String(saved.has(open.title))}
aria-hidden="true"
>
{saved.has(open.title) ? "♥" : "♡"}
</span>
{saved.has(open.title) ? "Saved" : "Save"}
</button>
<button
ref={closeBtn}
type="button"
className="gu-trip__close"
onClick={close}
>
Close
</button>
</div>
</div>
)}
{/* The flying photo, shared by the card and the sheet. */}
<div ref={ghost} className="gu-trip__ghost" aria-hidden="true" hidden />
</div>
);
}
```
### trip-planner.css
```css
/* TripPlanner: paper white, ink, and tile blue for where you are. */
.gu-trip {
--bg: #f7f6f2;
--card: #ffffff;
--ink: #15171a;
--muted: #6f7276;
--line: rgb(21 23 26 / 0.1);
--accent: #1f4fd1;
--focus: #1f4fd1;
--ease: cubic-bezier(0.16, 1, 0.3, 1);
--spring: cubic-bezier(0.34, 1.4, 0.5, 1);
position: relative;
height: 100%;
min-height: 640px;
overflow: hidden;
background: var(--bg);
color: var(--ink);
font-family: -apple-system, "SF Pro Text", system-ui, sans-serif;
-webkit-font-smoothing: antialiased;
}
.gu-trip button {
font: inherit;
color: inherit;
border: 0;
background: none;
cursor: pointer;
text-align: left;
-webkit-tap-highlight-color: transparent;
}
.gu-trip :focus-visible {
outline: 2px solid var(--focus);
outline-offset: 2px;
}
.gu-trip img {
display: block;
object-fit: cover;
background: #d9d4c8;
}
.gu-trip__sr {
position: absolute;
width: 1px;
height: 1px;
overflow: hidden;
clip-path: inset(50%);
white-space: nowrap;
}
.gu-trip__scroll {
height: 100%;
overflow-y: auto;
overscroll-behavior: contain;
scrollbar-width: none;
}
/* Cover */
.gu-trip__cover {
--sy: 0;
position: relative;
height: 300px;
overflow: hidden;
}
/* The cover drifts at half speed and swells a little as you scroll: depth without a 3D library. */
.gu-trip__cover img {
width: 100%;
height: 100%;
transform: translateY(calc(var(--sy) * 0.45px))
scale(calc(1.02 + var(--sy) * 0.0005));
transform-origin: 50% 100%;
will-change: transform;
animation: gu-trip-cover 1.4s var(--ease) both;
}
@keyframes gu-trip-cover {
from {
scale: 1.12;
filter: brightness(0.6);
}
}
.gu-trip__cover::after {
content: "";
position: absolute;
inset: 0;
background: linear-gradient(
rgb(0 0 0 / 0.3),
transparent 35%,
transparent 55%,
rgb(0 0 0 / 0.55)
);
}
.gu-trip__cover-text {
position: absolute;
left: 20px;
right: 20px;
bottom: 18px;
z-index: 1;
color: #fff;
opacity: calc(1 - var(--sy) / 230);
translate: 0 calc(var(--sy) * -0.25px);
}
.gu-trip__cover-text p {
animation: gu-trip-rise 0.8s 0.5s var(--ease) both;
}
.gu-trip__cover-text h2 span {
display: inline-block;
animation: gu-trip-letter 0.9s var(--ease) both;
animation-delay: calc(var(--i) * 45ms + 150ms);
}
@keyframes gu-trip-letter {
from {
opacity: 0;
translate: 0 0.5em;
filter: blur(6px);
}
}
@keyframes gu-trip-rise {
from {
opacity: 0;
translate: 0 8px;
}
}
.gu-trip__cover-text p {
margin: 0;
font-size: 14px;
font-weight: 600;
opacity: 0.9;
}
.gu-trip__cover-text h2 {
margin: 0;
font-size: 64px;
font-weight: 800;
letter-spacing: -0.05em;
line-height: 0.95;
}
/* Day tabs stick under the status bar while the plan scrolls. */
/* Behind the status bar: clear over the cover, solid ink once the plan scrolls under it. */
.gu-trip__bar {
position: absolute;
inset: 0 0 auto;
z-index: 6;
height: var(--gu-safe-top, env(safe-area-inset-top, 0px));
background: rgb(21 23 26 / 0.92);
opacity: 0;
transition: opacity 0.3s;
pointer-events: none;
}
.gu-trip[data-stuck="true"] .gu-trip__bar {
opacity: 1;
}
.gu-trip__days {
position: sticky;
top: var(--gu-safe-top, env(safe-area-inset-top, 0px));
z-index: 5;
display: flex;
gap: 6px;
padding: 12px 16px;
overflow-x: auto;
scrollbar-width: none;
background: rgb(247 246 242 / 0.82);
-webkit-backdrop-filter: blur(18px) saturate(1.4);
backdrop-filter: blur(18px) saturate(1.4);
box-shadow: 0 1px 0 var(--line);
}
.gu-trip__days button {
display: grid;
flex-shrink: 0;
min-width: 76px;
min-height: 52px;
padding: 7px 14px !important;
border-radius: 16px;
transition:
background-color 0.3s,
color 0.3s;
}
.gu-trip__days strong {
font-size: 15px;
font-weight: 700;
}
.gu-trip__days span {
font-size: 12px;
color: var(--muted);
}
.gu-trip__days button[aria-current="true"] {
background: var(--ink) !important;
color: var(--bg) !important;
}
.gu-trip__days button[aria-current="true"] span {
color: rgb(247 246 242 / 0.65);
}
/* Timeline */
.gu-trip__plan {
/* Always tall enough that the cover can scroll away, even on a short day. */
min-height: calc(
100% - 76px - var(--gu-safe-top, env(safe-area-inset-top, 0px))
);
box-sizing: border-box;
padding: 16px 16px
calc(var(--gu-safe-bottom, env(safe-area-inset-bottom, 0px)) + 24px);
}
.gu-trip__summary {
margin: 0 0 14px 4px;
font-size: 13px;
font-weight: 600;
color: var(--muted);
}
.gu-trip__list {
margin: 0;
padding: 0;
list-style: none;
}
.gu-trip__stop {
display: grid;
grid-template-columns: 44px 22px 1fr;
animation: gu-trip-in 0.6s var(--ease) both;
animation-delay: calc(var(--i) * 80ms);
}
/* A new day slides in from the side of the tab you picked. */
.gu-trip__plan[data-dir="left"] {
animation: gu-trip-from-right 0.5s var(--ease) both;
}
.gu-trip__plan[data-dir="right"] {
animation: gu-trip-from-left 0.5s var(--ease) both;
}
@keyframes gu-trip-from-right {
from {
opacity: 0;
translate: 36px 0;
}
}
@keyframes gu-trip-from-left {
from {
opacity: 0;
translate: -36px 0;
}
}
@keyframes gu-trip-in {
from {
opacity: 0;
translate: 0 14px;
}
}
.gu-trip__time {
padding-top: 26px;
font-size: 13px;
font-weight: 650;
font-variant-numeric: tabular-nums;
color: var(--muted);
}
.gu-trip__stop[data-state="here"] .gu-trip__time {
color: var(--accent);
}
/* The line: solid blue up to you, dotted after. */
.gu-trip__rail {
position: relative;
display: flex;
justify-content: center;
}
.gu-trip__rail::before {
content: "";
position: absolute;
top: 0;
bottom: 0;
width: 2px;
background: repeating-linear-gradient(var(--line) 0 5px, transparent 5px 9px);
}
/* The line draws itself downward, stop by stop. */
.gu-trip__rail::before {
transform-origin: top;
animation: gu-trip-draw 0.5s var(--ease) backwards;
animation-delay: calc(var(--i) * 80ms + 120ms);
}
@keyframes gu-trip-draw {
from {
transform: scaleY(0);
}
}
.gu-trip__dot {
animation: gu-trip-beat 0.5s var(--spring) backwards;
animation-delay: calc(var(--i) * 80ms + 160ms);
}
.gu-trip__stop:first-child .gu-trip__rail::before {
top: 30px;
}
.gu-trip__stop:last-child .gu-trip__rail::before {
bottom: auto;
height: 30px;
}
.gu-trip__stop[data-state="done"] .gu-trip__rail::before {
background: var(--accent);
}
.gu-trip__stop[data-state="here"] .gu-trip__rail::before {
background:
linear-gradient(var(--accent) 30px, transparent 30px),
repeating-linear-gradient(var(--line) 0 5px, transparent 5px 9px);
}
.gu-trip__dot {
position: relative;
width: 12px;
height: 12px;
margin-top: 25px;
border-radius: 50%;
background: var(--bg);
box-shadow: inset 0 0 0 2px rgb(21 23 26 / 0.25);
}
.gu-trip__stop[data-state="done"] .gu-trip__dot {
background: var(--accent);
box-shadow: none;
}
.gu-trip__stop[data-state="here"] .gu-trip__dot {
background: var(--accent);
box-shadow: 0 0 0 4px rgb(31 79 209 / 0.2);
}
.gu-trip__stop[data-state="here"] .gu-trip__dot::after {
content: "";
position: absolute;
inset: -4px;
border-radius: 50%;
border: 2px solid var(--accent);
animation: gu-trip-ping 1.8s ease-out infinite;
}
@keyframes gu-trip-ping {
to {
scale: 2.2;
opacity: 0;
}
}
.gu-trip__body {
padding: 8px 0 8px 6px;
min-width: 0;
}
.gu-trip__here {
display: inline-block;
margin: 0 0 6px;
padding: 3px 9px;
border-radius: 999px;
background: var(--accent);
color: #fff;
font-size: 11px;
font-weight: 700;
}
.gu-trip__card {
position: relative;
display: flex !important;
gap: 12px;
width: 100%;
padding: 8px !important;
border-radius: 20px;
background: var(--card) !important;
box-shadow:
0 1px 0 var(--line),
0 14px 24px -20px rgb(21 23 26 / 0.4);
transition: scale 0.25s var(--ease);
}
.gu-trip__card:active {
scale: 0.97;
}
.gu-trip__thumb {
width: 76px;
height: 76px;
flex-shrink: 0;
overflow: hidden;
border-radius: 14px;
}
.gu-trip__card img {
width: 100%;
height: 100%;
transition: scale 0.6s var(--ease);
}
@media (hover: hover) {
.gu-trip__card:hover img {
scale: 1.08;
}
}
.gu-trip__stop[data-state="done"] .gu-trip__card img {
filter: saturate(0.4);
opacity: 0.75;
}
.gu-trip__card-text {
display: grid;
align-content: center;
gap: 2px;
min-width: 0;
}
.gu-trip__card-text strong {
font-size: 16px;
font-weight: 700;
letter-spacing: -0.01em;
}
.gu-trip__card-text > span {
font-size: 13px;
color: var(--muted);
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
}
.gu-trip__card-text .gu-trip__stay {
justify-self: start;
margin-top: 4px;
padding: 2px 8px;
border-radius: 999px;
background: rgb(21 23 26 / 0.06);
font-size: 12px;
font-weight: 600;
color: var(--ink);
}
.gu-trip__saved {
position: absolute;
top: 10px;
right: 12px;
color: #e2412f;
font-size: 15px;
}
.gu-trip__walk {
display: flex;
align-items: center;
gap: 6px;
margin: 10px 0 2px 4px;
font-size: 12px;
font-weight: 600;
color: var(--muted);
}
.gu-trip__walk svg {
width: 16px;
height: 16px;
fill: none;
stroke: currentColor;
stroke-width: 1.8;
stroke-linecap: round;
stroke-linejoin: round;
}
/* Sheet */
.gu-trip__backdrop {
position: absolute;
inset: 0;
z-index: 20;
background: rgb(10 12 16 / 0.45);
-webkit-backdrop-filter: blur(3px);
backdrop-filter: blur(3px);
animation: gu-trip-fade 0.35s ease both;
transition: opacity 0.3s;
}
.gu-trip__backdrop[data-leaving="true"] {
animation: gu-trip-fade-out 0.45s ease both;
}
@keyframes gu-trip-fade-out {
to {
opacity: 0;
}
}
.gu-trip__backdrop[hidden] {
display: none;
}
@keyframes gu-trip-fade {
from {
opacity: 0;
}
}
.gu-trip__sheet {
position: absolute;
inset: auto 0 0;
z-index: 21;
padding: 10px 18px
calc(var(--gu-safe-bottom, env(safe-area-inset-bottom, 0px)) + 14px);
border-radius: 30px 30px 0 0;
background: var(--bg);
box-shadow: 0 -20px 50px rgb(0 0 0 / 0.25);
animation: gu-trip-up 0.56s cubic-bezier(0.2, 0.85, 0.2, 1) both;
transition: transform 0.5s var(--spring);
touch-action: none;
cursor: grab;
}
.gu-trip__sheet[data-dragging="true"] {
transition: none;
cursor: grabbing;
}
.gu-trip__sheet[data-leaving="true"] {
animation: gu-trip-down 0.5s cubic-bezier(0.4, 0, 0.6, 1) both;
}
@keyframes gu-trip-down {
to {
translate: 0 105%;
}
}
/* Text in the sheet arrives just after the photo lands. */
.gu-trip__sheet-text > *,
.gu-trip__actions {
animation: gu-trip-rise 0.6s var(--ease) both;
}
.gu-trip__sheet-text > :nth-child(1) {
animation-delay: 0.22s;
}
.gu-trip__sheet-text > :nth-child(2) {
animation-delay: 0.27s;
}
.gu-trip__sheet-text > :nth-child(3) {
animation-delay: 0.32s;
}
.gu-trip__sheet-text > :nth-child(4) {
animation-delay: 0.37s;
}
.gu-trip__actions {
animation-delay: 0.42s;
}
/* The photo that flies between card and sheet. */
.gu-trip__ghost {
position: absolute;
z-index: 40;
background: #d9d4c8 center / cover no-repeat;
box-shadow: 0 18px 40px -12px rgb(0 0 0 / 0.45);
pointer-events: none;
}
.gu-trip__ghost[hidden] {
display: none;
}
@keyframes gu-trip-up {
from {
translate: 0 100%;
}
}
.gu-trip__grab {
display: block;
width: 38px;
height: 5px;
margin: 0 auto 12px;
border-radius: 3px;
background: rgb(21 23 26 / 0.2);
}
.gu-trip__sheet-photo {
pointer-events: none;
-webkit-user-drag: none;
width: 100%;
aspect-ratio: 4 / 3;
border-radius: 22px;
}
.gu-trip__sheet-meta {
margin: 14px 0 0;
font-size: 13px;
font-weight: 650;
color: var(--accent);
}
.gu-trip__sheet h3 {
margin: 2px 0 0;
font-size: 26px;
font-weight: 750;
letter-spacing: -0.03em;
}
.gu-trip__sheet-place {
margin: 2px 0 0;
font-size: 14px;
color: var(--muted);
}
.gu-trip__note {
margin: 12px 0 0;
font-size: 15px;
line-height: 1.45;
}
.gu-trip__actions {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 10px;
margin-top: 16px;
}
.gu-trip__actions button {
min-height: 52px;
border-radius: 999px;
text-align: center;
font-size: 16px !important;
font-weight: 700 !important;
}
.gu-trip__save {
background: rgb(21 23 26 / 0.07) !important;
}
.gu-trip__save {
display: inline-flex !important;
align-items: center;
justify-content: center;
gap: 8px;
transition:
background-color 0.3s,
scale 0.2s var(--ease);
}
.gu-trip__save:active,
.gu-trip__close:active {
scale: 0.96;
}
.gu-trip__save[aria-pressed="true"] {
color: #e2412f !important;
background: rgb(226 65 47 / 0.1) !important;
}
.gu-trip__heart {
position: relative;
display: inline-block;
animation: gu-trip-beat 0.5s var(--spring);
}
.gu-trip__save[aria-pressed="true"] .gu-trip__heart::after {
content: "";
position: absolute;
inset: -8px;
border-radius: 50%;
border: 2px solid #e2412f;
animation: gu-trip-ring 0.6s ease-out forwards;
}
@keyframes gu-trip-beat {
0% {
scale: 0.4;
}
}
@keyframes gu-trip-ring {
from {
scale: 0.3;
opacity: 1;
}
to {
scale: 1.6;
opacity: 0;
}
}
.gu-trip__saved {
animation: gu-trip-beat 0.6s var(--spring);
}
.gu-trip__close {
background: var(--ink) !important;
color: var(--bg) !important;
}
@media (prefers-reduced-motion: reduce) {
.gu-trip *,
.gu-trip *::before,
.gu-trip *::after {
animation-duration: 0.01ms !important;
animation-delay: 0ms !important;
animation-iteration-count: 1 !important;
transition-duration: 0.01ms !important;
}
.gu-trip__cover img {
transform: none;
}
.gu-trip__stop,
.gu-trip__backdrop,
.gu-trip__sheet,
.gu-trip__stop[data-state="here"] .gu-trip__dot::after {
animation: none;
}
.gu-trip__bar {
transition: none;
}
}
```
You might also want
Next piece: Voice particle cloud 3D heroLiquid glass tab bar app
Apps, advanced
Split bills app
Apps, intermediate
Boarding pass app
Apps, intermediate
