Airline — Trip Itinerary
A multi-leg airline trip itinerary built with vanilla HTML, CSS and JavaScript. It shows a vertical timeline of flight segments with layovers, expandable leg cards exposing terminal, gate, cabin, seat and aircraft details, connection times with tight-layover warnings, large status pills for on-time, boarding and delayed flights, outbound and return tabs, and a manage sheet for changing flights, picking seats, adding bags or cancelling — with toast feedback throughout.
MCP
Code
:root {
--sky: #0a66c2;
--sky-d: #084e95;
--sky-50: #e9f2fb;
--cloud: #f5f8fc;
--sunrise: #ff7a33;
--sunrise-50: #fff0e7;
--ink: #13233b;
--ink-2: #3a4d68;
--muted: #6b7c93;
--bg: #f5f8fc;
--surface: #ffffff;
--line: rgba(19, 35, 59, 0.1);
--line-2: rgba(19, 35, 59, 0.18);
--ok: #1f9d62;
--warn: #e0962a;
--danger: #d4493e;
--boarding: #1f9d62;
--r-sm: 8px;
--r-md: 14px;
--r-lg: 20px;
--sh-sm: 0 1px 2px rgba(19, 35, 59, 0.06), 0 1px 3px rgba(19, 35, 59, 0.08);
--sh-md: 0 6px 18px rgba(19, 35, 59, 0.1);
--sh-lg: 0 18px 48px rgba(19, 35, 59, 0.18);
}
* {
box-sizing: border-box;
}
html {
-webkit-text-size-adjust: 100%;
}
body {
margin: 0;
background: var(--bg);
color: var(--ink);
font-family: "Inter", system-ui, -apple-system, sans-serif;
line-height: 1.5;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
padding: 28px 18px 56px;
}
.mono {
font-variant-numeric: tabular-nums;
font-feature-settings: "tnum" 1;
letter-spacing: 0.01em;
}
/* ---------- Shell ---------- */
.trip {
max-width: 760px;
margin: 0 auto;
}
/* ---------- Header ---------- */
.trip__head {
display: flex;
justify-content: space-between;
align-items: flex-start;
gap: 20px;
background: linear-gradient(135deg, var(--sky) 0%, var(--sky-d) 100%);
color: #fff;
border-radius: var(--r-lg);
padding: 22px 24px;
box-shadow: var(--sh-md);
position: relative;
overflow: hidden;
}
.trip__head::after {
content: "";
position: absolute;
right: -40px;
top: -60px;
width: 220px;
height: 220px;
background: radial-gradient(circle, rgba(255, 122, 51, 0.32), transparent 70%);
pointer-events: none;
}
.trip__kicker {
display: inline-block;
font-size: 12px;
font-weight: 600;
letter-spacing: 0.04em;
text-transform: uppercase;
color: rgba(255, 255, 255, 0.82);
margin-bottom: 6px;
}
.trip__kicker .mono {
color: #fff;
}
#trip-title {
margin: 0 0 12px;
font-size: clamp(20px, 3.4vw, 26px);
font-weight: 800;
letter-spacing: -0.01em;
}
.trip__meta {
display: flex;
flex-wrap: wrap;
gap: 8px;
}
.trip__chip {
display: inline-flex;
align-items: center;
gap: 6px;
font-size: 12.5px;
font-weight: 500;
background: rgba(255, 255, 255, 0.16);
border: 1px solid rgba(255, 255, 255, 0.22);
padding: 5px 10px;
border-radius: 999px;
}
.trip__chip svg {
width: 14px;
height: 14px;
fill: none;
stroke: #fff;
stroke-width: 2;
stroke-linejoin: round;
}
.trip__head-status {
text-align: right;
flex-shrink: 0;
}
.trip__price {
margin: 12px 0 0;
font-size: 13px;
color: rgba(255, 255, 255, 0.82);
}
.trip__price strong {
display: block;
font-size: 20px;
font-weight: 800;
color: #fff;
}
/* ---------- Status pills ---------- */
.status {
display: inline-flex;
align-items: center;
gap: 6px;
font-size: 12px;
font-weight: 700;
letter-spacing: 0.02em;
text-transform: uppercase;
padding: 6px 11px;
border-radius: 999px;
white-space: nowrap;
}
.status::before {
content: "";
width: 7px;
height: 7px;
border-radius: 50%;
background: currentColor;
}
.status--ok {
background: rgba(255, 255, 255, 0.18);
color: #fff;
}
.status--ontime {
background: rgba(31, 157, 98, 0.12);
color: var(--ok);
}
.status--boarding {
background: rgba(31, 157, 98, 0.14);
color: var(--boarding);
}
.status--delayed {
background: rgba(224, 150, 42, 0.14);
color: var(--warn);
}
.status--departed {
background: var(--sky-50);
color: var(--sky-d);
}
.status--cancelled {
background: rgba(212, 73, 62, 0.12);
color: var(--danger);
}
.status--boarding::before {
animation: pulse 1.4s ease-in-out infinite;
}
@keyframes pulse {
0%, 100% { opacity: 1; transform: scale(1); }
50% { opacity: 0.4; transform: scale(0.7); }
}
/* ---------- Direction tabs ---------- */
.legtabs {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 10px;
margin: 18px 0 8px;
}
.legtab {
display: flex;
flex-direction: column;
align-items: flex-start;
gap: 2px;
background: var(--surface);
border: 1px solid var(--line);
border-radius: var(--r-md);
padding: 12px 16px;
cursor: pointer;
text-align: left;
transition: border-color 0.15s, box-shadow 0.15s, transform 0.1s;
}
.legtab:hover {
border-color: var(--line-2);
}
.legtab:active {
transform: translateY(1px);
}
.legtab.is-active {
border-color: var(--sky);
box-shadow: 0 0 0 1px var(--sky), var(--sh-sm);
}
.legtab__route {
font-size: 16px;
font-weight: 800;
color: var(--ink);
}
.legtab__day {
font-size: 12.5px;
color: var(--muted);
font-weight: 500;
}
.legtab.is-active .legtab__day {
color: var(--sky);
}
/* ---------- Timeline ---------- */
.timeline {
position: relative;
margin-top: 14px;
}
.leg {
background: var(--surface);
border: 1px solid var(--line);
border-radius: var(--r-md);
box-shadow: var(--sh-sm);
overflow: hidden;
margin-bottom: 6px;
}
.leg__summary {
display: grid;
grid-template-columns: auto 1fr auto;
gap: 14px;
align-items: center;
width: 100%;
background: none;
border: 0;
text-align: left;
padding: 16px 18px;
cursor: pointer;
font: inherit;
color: inherit;
}
.leg__summary:hover {
background: var(--cloud);
}
.leg__airline {
display: flex;
flex-direction: column;
align-items: center;
gap: 6px;
min-width: 52px;
}
.leg__logo {
width: 38px;
height: 38px;
border-radius: 11px;
display: grid;
place-items: center;
color: #fff;
font-weight: 800;
font-size: 14px;
letter-spacing: -0.02em;
box-shadow: var(--sh-sm);
}
.leg__flightno {
font-size: 11px;
font-weight: 600;
color: var(--muted);
}
.leg__route {
display: grid;
grid-template-columns: 1fr auto 1fr;
align-items: center;
gap: 12px;
}
.leg__end {
min-width: 0;
}
.leg__end--arr {
text-align: right;
}
.leg__time {
font-size: 19px;
font-weight: 800;
color: var(--ink);
line-height: 1.1;
}
.leg__code {
font-size: 13px;
font-weight: 600;
color: var(--ink-2);
}
.leg__city {
font-size: 11.5px;
color: var(--muted);
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.leg__path {
display: flex;
flex-direction: column;
align-items: center;
gap: 3px;
color: var(--muted);
}
.leg__dur {
font-size: 11px;
font-weight: 600;
}
.leg__line {
position: relative;
width: 78px;
height: 2px;
background: var(--line-2);
border-radius: 2px;
}
.leg__line svg {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
width: 18px;
height: 18px;
fill: var(--sky);
background: var(--surface);
padding: 0 2px;
}
.leg__stops {
font-size: 10.5px;
color: var(--muted);
}
.leg__aside {
display: flex;
flex-direction: column;
align-items: flex-end;
gap: 8px;
}
.leg__chev {
width: 18px;
height: 18px;
stroke: var(--muted);
stroke-width: 2.4;
fill: none;
stroke-linecap: round;
stroke-linejoin: round;
transition: transform 0.22s ease;
}
.leg.is-open .leg__chev {
transform: rotate(180deg);
}
/* ---------- Leg details ---------- */
.leg__details {
display: grid;
grid-template-rows: 0fr;
transition: grid-template-rows 0.26s ease;
}
.leg.is-open .leg__details {
grid-template-rows: 1fr;
}
.leg__details-inner {
overflow: hidden;
}
.leg__grid {
display: grid;
grid-template-columns: repeat(4, 1fr);
gap: 1px;
background: var(--line);
border-top: 1px solid var(--line);
}
.fact {
background: var(--surface);
padding: 12px 16px;
}
.fact__label {
display: block;
font-size: 10.5px;
font-weight: 600;
letter-spacing: 0.04em;
text-transform: uppercase;
color: var(--muted);
margin-bottom: 3px;
}
.fact__value {
font-size: 14px;
font-weight: 700;
color: var(--ink);
}
.fact__value small {
display: block;
font-size: 11px;
font-weight: 500;
color: var(--muted);
margin-top: 1px;
}
.leg__bar {
display: flex;
flex-wrap: wrap;
align-items: center;
gap: 10px;
padding: 14px 18px;
border-top: 1px solid var(--line);
background: var(--cloud);
}
.leg__pax {
font-size: 12.5px;
color: var(--ink-2);
font-weight: 500;
margin-right: auto;
}
.leg__pax strong {
color: var(--ink);
}
/* ---------- Layover ---------- */
.layover {
display: flex;
align-items: center;
gap: 10px;
margin: 6px 0 6px 30px;
padding: 10px 14px;
border-left: 2px dashed var(--line-2);
position: relative;
font-size: 13px;
color: var(--ink-2);
}
.layover::before {
content: "";
position: absolute;
left: -7px;
top: 50%;
transform: translateY(-50%);
width: 12px;
height: 12px;
border-radius: 50%;
background: var(--surface);
border: 2px solid var(--line-2);
}
.layover svg {
width: 16px;
height: 16px;
flex-shrink: 0;
fill: none;
stroke: var(--muted);
stroke-width: 2;
stroke-linecap: round;
stroke-linejoin: round;
}
.layover strong {
color: var(--ink);
}
.layover--warn {
color: #8a5b14;
background: var(--sunrise-50);
border-radius: var(--r-sm);
border-left-color: var(--warn);
}
.layover--warn::before {
border-color: var(--warn);
}
.layover--warn svg {
stroke: var(--warn);
}
.layover--warn .layover__tag {
margin-left: auto;
font-size: 11px;
font-weight: 700;
text-transform: uppercase;
letter-spacing: 0.03em;
color: var(--warn);
}
/* ---------- Buttons ---------- */
.btn {
font: inherit;
font-weight: 600;
font-size: 13.5px;
border-radius: var(--r-sm);
padding: 9px 16px;
cursor: pointer;
border: 1px solid transparent;
transition: background 0.15s, border-color 0.15s, transform 0.1s, box-shadow 0.15s;
}
.btn:active {
transform: translateY(1px);
}
.btn:focus-visible {
outline: 2px solid var(--sky);
outline-offset: 2px;
}
.btn--primary {
background: var(--sky);
color: #fff;
box-shadow: var(--sh-sm);
}
.btn--primary:hover {
background: var(--sky-d);
}
.btn--ghost {
background: var(--surface);
color: var(--ink-2);
border-color: var(--line-2);
}
.btn--ghost:hover {
background: var(--cloud);
color: var(--ink);
}
.btn--sm {
padding: 7px 13px;
font-size: 12.5px;
}
.btn--accent {
background: var(--sunrise);
color: #fff;
}
.btn--accent:hover {
background: #ef6a22;
}
/* ---------- Footer ---------- */
.trip__foot {
display: flex;
gap: 10px;
margin-top: 18px;
justify-content: flex-end;
}
/* ---------- Toast ---------- */
.toast-wrap {
position: fixed;
left: 50%;
bottom: 22px;
transform: translateX(-50%);
display: flex;
flex-direction: column;
gap: 8px;
z-index: 90;
width: max-content;
max-width: 92vw;
}
.toast {
display: flex;
align-items: center;
gap: 9px;
background: var(--ink);
color: #fff;
font-size: 13.5px;
font-weight: 500;
padding: 11px 16px;
border-radius: var(--r-sm);
box-shadow: var(--sh-lg);
animation: toast-in 0.25s ease;
}
.toast.is-out {
animation: toast-out 0.25s ease forwards;
}
.toast::before {
content: "";
width: 8px;
height: 8px;
border-radius: 50%;
background: var(--sunrise);
}
.toast--ok::before { background: var(--ok); }
.toast--danger::before { background: var(--danger); }
@keyframes toast-in {
from { opacity: 0; transform: translateY(14px); }
to { opacity: 1; transform: translateY(0); }
}
@keyframes toast-out {
to { opacity: 0; transform: translateY(10px); }
}
/* ---------- Manage sheet ---------- */
.sheet {
position: fixed;
inset: 0;
z-index: 100;
display: grid;
place-items: end center;
}
.sheet[hidden] {
display: none;
}
.sheet__backdrop {
position: absolute;
inset: 0;
background: rgba(19, 35, 59, 0.42);
backdrop-filter: blur(2px);
animation: fade 0.2s ease;
}
.sheet__panel {
position: relative;
width: min(440px, 100%);
background: var(--surface);
border-radius: var(--r-lg) var(--r-lg) 0 0;
padding: 22px 22px 20px;
box-shadow: var(--sh-lg);
animation: sheet-up 0.26s cubic-bezier(0.16, 1, 0.3, 1);
}
@media (min-width: 560px) {
.sheet { place-items: center; }
.sheet__panel { border-radius: var(--r-lg); }
}
.sheet__title {
margin: 0;
font-size: 18px;
font-weight: 800;
}
.sheet__sub {
margin: 4px 0 16px;
font-size: 13px;
color: var(--muted);
}
.sheet__actions {
list-style: none;
margin: 0 0 14px;
padding: 0;
display: flex;
flex-direction: column;
gap: 8px;
}
.sheet__act {
width: 100%;
text-align: left;
background: var(--cloud);
border: 1px solid var(--line);
border-radius: var(--r-md);
padding: 12px 15px;
cursor: pointer;
font: inherit;
transition: background 0.14s, border-color 0.14s;
}
.sheet__act:hover {
background: var(--sky-50);
border-color: var(--sky);
}
.sheet__act span {
display: block;
font-size: 14px;
font-weight: 700;
color: var(--ink);
}
.sheet__act small {
font-size: 12px;
color: var(--muted);
}
.sheet__act--danger:hover {
background: rgba(212, 73, 62, 0.08);
border-color: var(--danger);
}
.sheet__act--danger span {
color: var(--danger);
}
.sheet__close {
width: 100%;
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes sheet-up {
from { transform: translateY(20px); opacity: 0; }
to { transform: translateY(0); opacity: 1; }
}
/* ---------- Responsive ---------- */
@media (max-width: 520px) {
body { padding: 18px 12px 48px; }
.trip__head {
flex-direction: column;
gap: 14px;
padding: 18px;
}
.trip__head-status {
text-align: left;
display: flex;
align-items: center;
justify-content: space-between;
width: 100%;
}
.trip__price { margin-top: 0; }
.trip__price strong { font-size: 18px; }
.legtabs { grid-template-columns: 1fr; }
.leg__summary {
grid-template-columns: auto 1fr;
gap: 12px;
}
.leg__aside {
grid-column: 1 / -1;
flex-direction: row;
align-items: center;
justify-content: space-between;
}
.leg__line { width: 48px; }
.leg__time { font-size: 17px; }
.leg__grid { grid-template-columns: repeat(2, 1fr); }
.trip__foot { flex-direction: column-reverse; }
.trip__foot .btn { width: 100%; }
}
@media (prefers-reduced-motion: reduce) {
*, *::before, *::after {
animation-duration: 0.01ms !important;
transition-duration: 0.01ms !important;
}
}(function () {
"use strict";
// --- Trip data (fictional) ---
var TRIP = {
out: [
{
id: "SY412",
carrier: "Skyfare Air",
code: "SY",
color: "#0a66c2",
flight: "SY 412",
dep: { code: "JFK", city: "New York (Kennedy)", time: "10:25", date: "Jul 18" },
arr: { code: "LAX", city: "Los Angeles", time: "13:48", date: "Jul 18" },
dur: "6h 23m",
cabin: "Economy",
aircraft: "Airbus A321neo",
terminal: "T4 · Gate B22",
arrTerminal: "T6 · Gate 60B",
seats: "14A · 14B",
status: { label: "On time", cls: "ontime" }
},
{
id: "AZ7",
carrier: "Azure Pacific",
code: "AP",
color: "#0e9488",
flight: "AP 7",
dep: { code: "LAX", city: "Los Angeles", time: "16:40", date: "Jul 18" },
arr: { code: "HND", city: "Tokyo (Haneda)", time: "20:55", date: "Jul 19" },
dur: "11h 15m",
cabin: "Premium Economy",
aircraft: "Boeing 787-9",
terminal: "Tom Bradley Intl · Gate 148",
arrTerminal: "T3 · Gate 142",
seats: "21H · 21J",
status: { label: "Boarding", cls: "boarding" }
}
],
ret: [
{
id: "AZ8",
carrier: "Azure Pacific",
code: "AP",
color: "#0e9488",
flight: "AP 8",
dep: { code: "HND", city: "Tokyo (Haneda)", time: "11:10", date: "Jul 31" },
arr: { code: "SFO", city: "San Francisco", time: "04:35", date: "Jul 31" },
dur: "9h 25m",
cabin: "Premium Economy",
aircraft: "Boeing 787-9",
terminal: "T3 · Gate 110",
arrTerminal: "Intl Term G · Gate G8",
seats: "19D · 19E",
status: { label: "Delayed 35m", cls: "delayed" }
},
{
id: "SY889",
carrier: "Skyfare Air",
code: "SY",
color: "#0a66c2",
flight: "SY 889",
dep: { code: "SFO", city: "San Francisco", time: "07:05", date: "Jul 31" },
arr: { code: "JFK", city: "New York (Kennedy)", time: "15:42", date: "Jul 31" },
dur: "5h 37m",
cabin: "Economy",
aircraft: "Airbus A321neo",
terminal: "Term 2 · Gate D14",
arrTerminal: "T4 · Gate A8",
seats: "27C · 27D",
status: { label: "On time", cls: "ontime" }
}
]
};
// layovers between consecutive legs (index = gap after leg i)
var LAYOVERS = {
out: [{ airport: "LAX · Los Angeles", time: "2h 52m", changeTerminal: true, warn: false }],
ret: [{ airport: "SFO · San Francisco", time: "2h 30m", changeTerminal: false, warn: true, note: "Short connection — minimum is 1h 30m, but terminal change required" }]
};
var PAX = "G. Innovo · M. Tan";
var timeline = document.getElementById("timeline");
var sheet = document.getElementById("manageSheet");
var sheetSub = document.getElementById("sheetSub");
var currentDir = "out";
var activeLeg = null;
// --- icons ---
var planeIcon = '<svg viewBox="0 0 24 24" aria-hidden="true"><path d="M2 16l20-7-9 13-2-5z"/></svg>';
var clockIcon = '<svg viewBox="0 0 24 24" aria-hidden="true"><circle cx="12" cy="12" r="9"/><path d="M12 7v5l3 2"/></svg>';
var chev = '<svg class="leg__chev" viewBox="0 0 24 24" aria-hidden="true"><path d="M6 9l6 6 6-6"/></svg>';
function esc(s) {
return String(s).replace(/[&<>"]/g, function (c) {
return { "&": "&", "<": "<", ">": ">", '"': """ }[c];
});
}
function legHtml(leg) {
return (
'<article class="leg" data-id="' + leg.id + '">' +
'<button class="leg__summary" aria-expanded="false">' +
'<span class="leg__airline">' +
'<span class="leg__logo" style="background:' + leg.color + '">' + esc(leg.code) + '</span>' +
'<span class="leg__flightno mono">' + esc(leg.flight) + '</span>' +
'</span>' +
'<span class="leg__route">' +
'<span class="leg__end leg__end--dep">' +
'<span class="leg__time mono">' + esc(leg.dep.time) + '</span>' +
'<span class="leg__code mono">' + esc(leg.dep.code) + '</span>' +
'<span class="leg__city">' + esc(leg.dep.city) + '</span>' +
'</span>' +
'<span class="leg__path">' +
'<span class="leg__dur mono">' + esc(leg.dur) + '</span>' +
'<span class="leg__line">' + planeIcon + '</span>' +
'<span class="leg__stops">Nonstop</span>' +
'</span>' +
'<span class="leg__end leg__end--arr">' +
'<span class="leg__time mono">' + esc(leg.arr.time) + '</span>' +
'<span class="leg__code mono">' + esc(leg.arr.code) + '</span>' +
'<span class="leg__city">' + esc(leg.arr.city) + '</span>' +
'</span>' +
'</span>' +
'<span class="leg__aside">' +
'<span class="status status--' + leg.status.cls + '">' + esc(leg.status.label) + '</span>' +
chev +
'</span>' +
'</button>' +
'<div class="leg__details">' +
'<div class="leg__details-inner">' +
'<div class="leg__grid">' +
fact("Departs", leg.terminal, leg.dep.date + " · " + leg.dep.time) +
fact("Arrives", leg.arrTerminal, leg.arr.date + " · " + leg.arr.time) +
fact("Cabin · seats", leg.cabin, leg.seats) +
fact("Aircraft", leg.aircraft, "Operated by " + leg.carrier) +
'</div>' +
'<div class="leg__bar">' +
'<span class="leg__pax">Passengers <strong>' + esc(PAX) + '</strong></span>' +
'<button class="btn btn--ghost btn--sm" data-act="boardingpass" data-id="' + leg.id + '">Boarding pass</button>' +
'<button class="btn btn--accent btn--sm" data-act="manage" data-id="' + leg.id + '">Manage</button>' +
'</div>' +
'</div>' +
'</div>' +
'</article>'
);
}
function fact(label, value, sub) {
return (
'<div class="fact">' +
'<span class="fact__label">' + esc(label) + '</span>' +
'<span class="fact__value">' + esc(value) +
(sub ? '<small class="mono">' + esc(sub) + "</small>" : "") +
"</span>" +
"</div>"
);
}
function layoverHtml(lo) {
var cls = lo.warn ? "layover layover--warn" : "layover";
var inner =
clockIcon +
"<span>Layover in <strong>" + esc(lo.airport) + "</strong> · <strong class=\"mono\">" + esc(lo.time) + "</strong>" +
(lo.changeTerminal ? " · terminal change" : "") +
(lo.note ? "<br>" + esc(lo.note) : "") +
"</span>";
if (lo.warn) inner += '<span class="layover__tag">Tight</span>';
return '<div class="' + cls + '">' + inner + "</div>";
}
function render(dir) {
currentDir = dir;
var legs = TRIP[dir];
var los = LAYOVERS[dir] || [];
var html = "";
for (var i = 0; i < legs.length; i++) {
html += legHtml(legs[i]);
if (los[i]) html += layoverHtml(los[i]);
}
timeline.innerHTML = html;
}
function findLeg(id) {
var all = TRIP.out.concat(TRIP.ret);
for (var i = 0; i < all.length; i++) if (all[i].id === id) return all[i];
return null;
}
// --- Toast ---
var toastWrap = document.getElementById("toastWrap");
function toast(msg, kind) {
var el = document.createElement("div");
el.className = "toast" + (kind ? " toast--" + kind : "");
el.textContent = msg;
toastWrap.appendChild(el);
setTimeout(function () {
el.classList.add("is-out");
setTimeout(function () {
if (el.parentNode) el.parentNode.removeChild(el);
}, 250);
}, 2600);
}
// --- Expand / collapse ---
timeline.addEventListener("click", function (e) {
var actBtn = e.target.closest("[data-act]");
if (actBtn) {
e.stopPropagation();
handleAction(actBtn.getAttribute("data-act"), actBtn.getAttribute("data-id"));
return;
}
var summary = e.target.closest(".leg__summary");
if (!summary) return;
var leg = summary.closest(".leg");
var open = leg.classList.toggle("is-open");
summary.setAttribute("aria-expanded", open ? "true" : "false");
});
function handleAction(act, id) {
if (act === "boardingpass") {
var leg = findLeg(id);
toast("Boarding pass for " + (leg ? leg.flight : id) + " sent to mobile wallet", "ok");
return;
}
if (act === "manage") {
openSheet(id);
return;
}
}
// --- Direction tabs ---
var tabs = document.querySelectorAll(".legtab");
tabs.forEach(function (tab) {
tab.addEventListener("click", function () {
tabs.forEach(function (t) {
t.classList.remove("is-active");
t.setAttribute("aria-pressed", "false");
});
tab.classList.add("is-active");
tab.setAttribute("aria-pressed", "true");
render(tab.getAttribute("data-dir"));
});
});
// --- Manage sheet ---
function openSheet(id) {
activeLeg = findLeg(id);
sheetSub.textContent = activeLeg
? activeLeg.flight + " · " + activeLeg.dep.code + " → " + activeLeg.arr.code + " · " + activeLeg.dep.date
: "";
sheet.hidden = false;
document.body.style.overflow = "hidden";
var firstAct = sheet.querySelector(".sheet__act");
if (firstAct) firstAct.focus();
}
function closeSheet() {
sheet.hidden = true;
document.body.style.overflow = "";
activeLeg = null;
}
sheet.addEventListener("click", function (e) {
if (e.target.closest("[data-close]")) {
closeSheet();
return;
}
var act = e.target.closest("[data-act]");
if (!act) return;
var label = activeLeg ? activeLeg.flight : "segment";
switch (act.getAttribute("data-act")) {
case "change":
toast("Searching alternative flights for " + label + "…");
break;
case "seat":
toast("Opening seat map for " + label, "ok");
break;
case "bag":
toast("Checked bag added to " + label + " · $45", "ok");
break;
case "cancel":
toast("Cancellation request submitted for " + label, "danger");
break;
}
closeSheet();
});
document.addEventListener("keydown", function (e) {
if (e.key === "Escape" && !sheet.hidden) closeSheet();
});
// --- Footer buttons ---
document.getElementById("addBag").addEventListener("click", function () {
toast("Extra baggage added to trip · 2 × 23kg", "ok");
});
document.getElementById("checkin").addEventListener("click", function () {
toast("Online check-in opens 24h before departure", "ok");
});
// init
render("out");
})();<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Skyfare — Trip Itinerary</title>
<link rel="preconnect" href="https://fonts.googleapis.com" />
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap" rel="stylesheet" />
<link rel="stylesheet" href="style.css" />
</head>
<body>
<main class="trip" aria-labelledby="trip-title">
<header class="trip__head">
<div class="trip__head-main">
<span class="trip__kicker">Skyfare Air · Trip ID <span class="mono">SKY-7QF2L9</span></span>
<h1 id="trip-title">Round trip · New York → Tokyo</h1>
<div class="trip__meta">
<span class="trip__chip"><svg viewBox="0 0 24 24" aria-hidden="true"><path d="M2 16l20-7-9 13-2-5z"/></svg>2 passengers</span>
<span class="trip__chip"><svg viewBox="0 0 24 24" aria-hidden="true"><rect x="6" y="3" width="12" height="18" rx="2"/></svg>4 segments</span>
<span class="trip__chip"><svg viewBox="0 0 24 24" aria-hidden="true"><path d="M12 2a7 7 0 017 7c0 5-7 13-7 13S5 14 5 9a7 7 0 017-7z"/></svg>Jul 18 — Jul 31, 2026</span>
</div>
</div>
<div class="trip__head-status">
<span class="status status--ok">Confirmed</span>
<p class="trip__price">Total <strong class="mono">$3,842.60</strong></p>
</div>
</header>
<section class="legtabs" aria-label="Trip directions">
<button class="legtab is-active" data-dir="out" aria-pressed="true">
<span class="legtab__route mono">JFK → HND</span>
<span class="legtab__day">Outbound · Jul 18</span>
</button>
<button class="legtab" data-dir="ret" aria-pressed="false">
<span class="legtab__route mono">HND → JFK</span>
<span class="legtab__day">Return · Jul 31</span>
</button>
</section>
<section class="timeline" id="timeline" aria-label="Flight segments"></section>
<footer class="trip__foot">
<button class="btn btn--ghost" id="addBag">Add checked bag</button>
<button class="btn btn--primary" id="checkin">Online check-in</button>
</footer>
</main>
<div class="toast-wrap" id="toastWrap" aria-live="polite" aria-atomic="true"></div>
<div class="sheet" id="manageSheet" role="dialog" aria-modal="true" aria-labelledby="sheetTitle" hidden>
<div class="sheet__backdrop" data-close></div>
<div class="sheet__panel" role="document">
<h2 id="sheetTitle" class="sheet__title">Manage segment</h2>
<p class="sheet__sub" id="sheetSub"></p>
<ul class="sheet__actions">
<li><button class="sheet__act" data-act="change"><span>Change flight</span><small>Search alternatives for this leg</small></button></li>
<li><button class="sheet__act" data-act="seat"><span>Select seat</span><small>Choose or upgrade your seat</small></button></li>
<li><button class="sheet__act" data-act="bag"><span>Add bag</span><small>+1 checked bag · $45</small></button></li>
<li><button class="sheet__act sheet__act--danger" data-act="cancel"><span>Cancel segment</span><small>Subject to fare rules</small></button></li>
</ul>
<button class="btn btn--ghost sheet__close" data-close>Close</button>
</div>
</div>
<script src="script.js"></script>
</body>
</html>Trip Itinerary
A status-forward itinerary view for a multi-leg round trip. A gradient header summarizes the trip — passengers, segment count, dates and total fare — while two route tabs switch between the outbound and return directions. Each direction renders as a vertical timeline of flight segments separated by layover markers, so a four-flight journey reads as a single connected path.
Every leg is an expandable card: collapsed it shows the airline badge, flight number, departure and arrival times in tabular figures, airport codes, duration and a live status pill (On time, Boarding, Delayed). Expanding a card reveals a fact grid with departure and arrival terminals and gates, cabin and seat assignments, and the operating aircraft. Layover chips display connection time and flag tight connections that require a terminal change, using the sunrise accent for the warning state.
Interactions are pure vanilla JavaScript: smooth grid-row expand/collapse, accessible direction tabs, a Boarding pass action that confirms via toast, and a bottom-sheet Manage menu (change flight, select seat, add bag, cancel segment) that traps focus, closes on Escape or backdrop click, and reports each choice through a small toast helper. The layout is mobile-first and reflows cleanly down to 360px.
Illustrative UI only — fictional airline, not a real booking or flight system.