Add an example site that calls every route, served at /examples/
A reader learns the API fastest from working calls: one page per area (circuit browser, track images, GPS traces on a map, grand prix lookup, posters, Kometa) shows the exact request URL next to its answer. Pages call their own origin when the app serves them, and the public service when opened from disk or given ?api=. Posters render only on a button press, since each one fetches map tiles on the server. A body that does not match the asked format is said in red, never shown as success. The image copies examples/ so the deployed app serves the same pages. Claude-Session: https://claude.ai/code/session_01NcbgfJAa38xFpzy69BWrqh
This commit is contained in:
@@ -0,0 +1,299 @@
|
||||
/* Shared styles for the F1 Circuits API examples: one file, light and dark. */
|
||||
|
||||
:root {
|
||||
color-scheme: light dark;
|
||||
--bg: #f4f4f7;
|
||||
--card: #ffffff;
|
||||
--text: #15151e;
|
||||
--muted: #5d5d6c;
|
||||
--line: #dcdce4;
|
||||
--accent: #e10600;
|
||||
--accent-text: #ffffff;
|
||||
--code-bg: #f0f0f4;
|
||||
--ok: #1a7f37;
|
||||
--warn: #9a6700;
|
||||
--error: #c62828;
|
||||
--tile: #ffffff;
|
||||
--json-key: #0b5cad;
|
||||
--json-string: #1a7f37;
|
||||
--json-number: #a3480b;
|
||||
--json-literal: #8250df;
|
||||
--radius: 10px;
|
||||
--mono: ui-monospace, SFMono-Regular, "JetBrains Mono", Menlo, Consolas, monospace;
|
||||
}
|
||||
|
||||
@media (prefers-color-scheme: dark) {
|
||||
:root {
|
||||
--bg: #111116;
|
||||
--card: #1b1b23;
|
||||
--text: #e9e9ef;
|
||||
--muted: #a3a3b3;
|
||||
--line: #2e2e3a;
|
||||
--accent: #ff3b30;
|
||||
--code-bg: #24242e;
|
||||
--ok: #4ac26b;
|
||||
--warn: #d29922;
|
||||
--error: #ff6b6b;
|
||||
--tile: #1b1b23;
|
||||
--json-key: #79b8ff;
|
||||
--json-string: #85e89d;
|
||||
--json-number: #ffab70;
|
||||
--json-literal: #d2a8ff;
|
||||
}
|
||||
}
|
||||
|
||||
* { box-sizing: border-box; }
|
||||
|
||||
body {
|
||||
margin: 0;
|
||||
background: var(--bg);
|
||||
color: var(--text);
|
||||
font: 16px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
|
||||
}
|
||||
|
||||
a { color: var(--accent); }
|
||||
|
||||
code, pre, kbd { font-family: var(--mono); font-size: 0.9em; }
|
||||
:not(pre) > code { background: var(--code-bg); padding: 0.1em 0.35em; border-radius: 4px; }
|
||||
|
||||
/* ---- header and navigation ---- */
|
||||
|
||||
header.site {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
gap: 0.5rem 1.25rem;
|
||||
padding: 0.75rem 1.5rem;
|
||||
background: var(--card);
|
||||
border-bottom: 3px solid var(--accent);
|
||||
}
|
||||
|
||||
header.site .brand {
|
||||
font-weight: 800;
|
||||
color: var(--text);
|
||||
text-decoration: none;
|
||||
letter-spacing: 0.02em;
|
||||
}
|
||||
header.site .brand span { color: var(--accent); }
|
||||
|
||||
header.site nav { display: flex; flex-wrap: wrap; gap: 0.25rem; flex: 1; }
|
||||
header.site nav a {
|
||||
color: var(--muted);
|
||||
text-decoration: none;
|
||||
padding: 0.3rem 0.6rem;
|
||||
border-radius: 6px;
|
||||
}
|
||||
header.site nav a:hover { color: var(--text); background: var(--code-bg); }
|
||||
header.site nav a[aria-current="page"] { color: var(--accent-text); background: var(--accent); }
|
||||
|
||||
.api-switch { font-size: 0.85rem; color: var(--muted); }
|
||||
.api-switch summary { cursor: pointer; }
|
||||
.api-switch summary code { color: var(--text); }
|
||||
.api-switch form { display: flex; gap: 0.4rem; margin-top: 0.4rem; }
|
||||
.api-switch input { width: 18rem; }
|
||||
|
||||
main { max-width: 1200px; margin: 0 auto; padding: 1.5rem; }
|
||||
|
||||
h1 { margin: 0.25rem 0 0.5rem; font-size: 1.9rem; }
|
||||
h2 { margin: 2rem 0 0.5rem; font-size: 1.35rem; }
|
||||
h3 { margin: 1.25rem 0 0.4rem; font-size: 1.1rem; }
|
||||
.lead { color: var(--muted); font-size: 1.08rem; max-width: 60rem; }
|
||||
|
||||
footer.pager {
|
||||
max-width: 1200px;
|
||||
margin: 2rem auto 0;
|
||||
padding: 1rem 1.5rem 2.5rem;
|
||||
display: grid;
|
||||
grid-template-columns: 1fr auto 1fr;
|
||||
gap: 1rem;
|
||||
border-top: 1px solid var(--line);
|
||||
}
|
||||
footer.pager a { text-decoration: none; font-weight: 600; }
|
||||
footer.pager [rel="next"] { justify-self: end; }
|
||||
footer.pager .home { justify-self: center; }
|
||||
|
||||
/* ---- cards, calls and results ---- */
|
||||
|
||||
.card {
|
||||
background: var(--card);
|
||||
border: 1px solid var(--line);
|
||||
border-radius: var(--radius);
|
||||
padding: 1rem 1.1rem;
|
||||
margin: 1rem 0;
|
||||
}
|
||||
.card > h2:first-child, .card > h3:first-child { margin-top: 0; }
|
||||
|
||||
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 1rem; }
|
||||
.grid-2 > .card { margin: 0; }
|
||||
|
||||
/* The request bar: the exact URL a call sends, with Copy and Open. */
|
||||
.request {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.5rem;
|
||||
background: var(--code-bg);
|
||||
border: 1px solid var(--line);
|
||||
border-radius: 8px;
|
||||
padding: 0.4rem 0.5rem;
|
||||
min-height: 2.4rem;
|
||||
}
|
||||
.request .verb {
|
||||
font: 700 0.75rem var(--mono);
|
||||
color: var(--accent-text);
|
||||
background: var(--ok);
|
||||
border-radius: 4px;
|
||||
padding: 0.15rem 0.4rem;
|
||||
}
|
||||
.request .url {
|
||||
flex: 1;
|
||||
overflow-x: auto;
|
||||
white-space: nowrap;
|
||||
font-size: 0.85rem;
|
||||
scrollbar-width: thin;
|
||||
}
|
||||
.request .label { font-size: 0.75rem; color: var(--muted); white-space: nowrap; }
|
||||
.request:empty { display: none; }
|
||||
/* In a narrow card: the buttons on the first row, the whole URL wrapped below them. */
|
||||
.request.compact { flex-wrap: wrap; }
|
||||
.request.compact .url { order: 9; flex-basis: 100%; white-space: normal; overflow-wrap: anywhere; font-size: 0.75rem; }
|
||||
.request button, .request a.open { font-size: 0.8rem; padding: 0.2rem 0.55rem; }
|
||||
.request a.open {
|
||||
border: 1px solid var(--line);
|
||||
border-radius: 6px;
|
||||
text-decoration: none;
|
||||
color: var(--text);
|
||||
background: var(--card);
|
||||
}
|
||||
|
||||
.status { font-size: 0.85rem; margin: 0.4rem 0 0.6rem; color: var(--muted); min-height: 1.3em; }
|
||||
.status.ok::before { content: "● "; color: var(--ok); }
|
||||
.status.pending::before { content: "◌ "; color: var(--warn); }
|
||||
.status.error { color: var(--error); }
|
||||
.status.error::before { content: "✕ "; }
|
||||
.status.idle::before { content: "○ "; }
|
||||
|
||||
.result:empty { display: none; }
|
||||
|
||||
.hint { font-size: 0.85rem; color: var(--muted); margin: 0 0 0.6rem; }
|
||||
.hint.error { color: var(--error); }
|
||||
|
||||
pre.code {
|
||||
margin: 0;
|
||||
background: var(--code-bg);
|
||||
border: 1px solid var(--line);
|
||||
border-radius: 8px;
|
||||
padding: 0.75rem;
|
||||
overflow: auto;
|
||||
max-height: 32rem;
|
||||
font-size: 0.82rem;
|
||||
line-height: 1.45;
|
||||
white-space: pre-wrap;
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
pre.code.tall { max-height: 70vh; }
|
||||
.j-key { color: var(--json-key); }
|
||||
.j-str { color: var(--json-string); }
|
||||
.j-num { color: var(--json-number); }
|
||||
.j-lit { color: var(--json-literal); }
|
||||
|
||||
.notice {
|
||||
border-left: 4px solid var(--warn);
|
||||
background: var(--code-bg);
|
||||
padding: 0.6rem 0.8rem;
|
||||
border-radius: 0 8px 8px 0;
|
||||
margin: 0.6rem 0;
|
||||
}
|
||||
.notice.error { border-left-color: var(--error); }
|
||||
.notice.info { border-left-color: var(--json-key); }
|
||||
|
||||
/* ---- forms ---- */
|
||||
|
||||
.controls { display: flex; flex-wrap: wrap; gap: 0.75rem 1rem; align-items: end; margin: 0.5rem 0 0.75rem; }
|
||||
.controls label { display: flex; flex-direction: column; gap: 0.2rem; font-size: 0.8rem; color: var(--muted); }
|
||||
.controls label.inline { flex-direction: row; align-items: center; gap: 0.35rem; color: var(--text); font-size: 0.9rem; }
|
||||
.controls fieldset { border: none; padding: 0; margin: 0; display: flex; gap: 0.75rem; align-items: center; }
|
||||
.controls legend { font-size: 0.8rem; color: var(--muted); padding: 0; margin-bottom: 0.2rem; }
|
||||
|
||||
select, input, button {
|
||||
font: inherit;
|
||||
font-size: 0.92rem;
|
||||
color: var(--text);
|
||||
background: var(--card);
|
||||
border: 1px solid var(--line);
|
||||
border-radius: 6px;
|
||||
padding: 0.35rem 0.5rem;
|
||||
}
|
||||
input[type="number"] { width: 6.5rem; }
|
||||
input.wide { min-width: 16rem; }
|
||||
select { max-width: 30rem; }
|
||||
button { cursor: pointer; }
|
||||
button.primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); font-weight: 600; }
|
||||
button:disabled { opacity: 0.55; cursor: progress; }
|
||||
|
||||
/* ---- lists of choices (circuit browser) ---- */
|
||||
|
||||
.choices { display: flex; flex-wrap: wrap; gap: 0.4rem; margin: 0.5rem 0; }
|
||||
.choices button { font-size: 0.88rem; }
|
||||
.choices button[aria-pressed="true"] { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
|
||||
.choices button small { color: inherit; opacity: 0.7; }
|
||||
|
||||
/* ---- images ---- */
|
||||
|
||||
.track-tile {
|
||||
background: var(--tile);
|
||||
border: 1px solid var(--line);
|
||||
border-radius: 8px;
|
||||
display: grid;
|
||||
place-items: center;
|
||||
padding: 0.75rem;
|
||||
min-height: 9rem;
|
||||
}
|
||||
.track-tile img { width: 100%; max-width: 480px; max-height: 320px; object-fit: contain; }
|
||||
@media (prefers-color-scheme: dark) {
|
||||
/* The service's track images are a black line on a transparent ground. */
|
||||
.track-tile img { filter: invert(1); }
|
||||
}
|
||||
|
||||
.layouts { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 1rem; }
|
||||
.layout-card { border: 1px solid var(--line); border-radius: var(--radius); padding: 0.75rem; display: flex; flex-direction: column; gap: 0.5rem; }
|
||||
.layout-card h3 { margin: 0; }
|
||||
.layout-card p { margin: 0; font-size: 0.88rem; color: var(--muted); }
|
||||
.layout-card .links { font-size: 0.85rem; display: flex; gap: 0.75rem; flex-wrap: wrap; }
|
||||
.layout-card .track-tile { min-height: 7rem; }
|
||||
.layout-card .track-tile img { max-height: 160px; }
|
||||
.layout-card code.small { font-size: 0.72rem; word-break: break-all; }
|
||||
|
||||
.poster { display: block; max-width: 100%; border-radius: 8px; border: 1px solid var(--line); }
|
||||
.poster.portrait { max-height: 640px; }
|
||||
.preview { margin-top: 0.75rem; }
|
||||
|
||||
/* ---- tables ---- */
|
||||
|
||||
table { border-collapse: collapse; width: 100%; font-size: 0.9rem; }
|
||||
th, td { text-align: left; padding: 0.4rem 0.6rem; border-bottom: 1px solid var(--line); vertical-align: top; }
|
||||
th { color: var(--muted); font-weight: 600; }
|
||||
td code { white-space: nowrap; }
|
||||
table.kv th { width: 12rem; }
|
||||
|
||||
/* ---- map ---- */
|
||||
|
||||
#map { height: 560px; border-radius: var(--radius); border: 1px solid var(--line); }
|
||||
.leaflet-container { font: inherit; }
|
||||
|
||||
/* ---- index ---- */
|
||||
|
||||
.pages { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 1rem; }
|
||||
.pages a.page {
|
||||
display: block;
|
||||
background: var(--card);
|
||||
border: 1px solid var(--line);
|
||||
border-radius: var(--radius);
|
||||
padding: 1rem;
|
||||
color: var(--text);
|
||||
text-decoration: none;
|
||||
}
|
||||
.pages a.page:hover { border-color: var(--accent); }
|
||||
.pages a.page h3 { margin: 0 0 0.3rem; color: var(--accent); }
|
||||
.pages a.page p { margin: 0 0 0.5rem; color: var(--muted); font-size: 0.92rem; }
|
||||
.pages a.page ul { margin: 0; padding-left: 1.1rem; font-size: 0.78rem; }
|
||||
.pages a.page li code { background: none; padding: 0; overflow-wrap: anywhere; }
|
||||
Reference in New Issue
Block a user