mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-10-22 23:16:46 +00:00
eae8480728
* feat(studio): widen the document, and stop a save from losing it The schema gains what the elements coming after it need: an icon element, a badge that can be restyled rather than only placed, a date and a pair of coordinates on a text binding, and the map's route, pin and road settings. Widening it turned up two ways a book could fail to come back. The mood badge writes its code into the document, and the schema said that code was exactly two characters, from a first draft where it was a country. The real codes are words, so every save was rejected and the read that followed parsed to an empty document: seventeen spreads in, nothing out. Widened to what the badge actually writes, and normalizeBookDocument now drops the elements it cannot read rather than the whole book, so one bad element costs a picture frame instead of a year of work. The other was the body limit. The parser allowed 100kb for everything, and a book with a routed map measures past that, so the save came back 413 and the editor sat on "not saved" with no way forward. Book writes get their own parser at 8mb; everything else keeps the limit it had. * feat(studio): a date, a pair of coordinates and an icon library Three things that had to be drawn by hand before. A journal entry knows when it happened and where, and neither could be put on a page: you read the date off the entry and typed it into a text box, where it then stayed while the entry moved. Both are chips now, next to the title and the story, and both follow their entry the way the others do. The formatting lives in one place so the chip, the template and the resolver cannot drift by a character — coordinates in degrees or decimals, the date in the reader's language. The icons are the whole Lucide set, searchable, placed as a real element with its own colour and stroke rather than as a character in a font. The stroke is deliberately not called strokeWidth: three separate places rescale a field of that name by page width, and an icon whose line thins as the book grows is not what anyone asked for. And the badges finally have their settings. A mood or weather badge could be placed and then only moved: the icon's colour was fixed, the icon could not be turned off, and there was no way to keep the icon and drop the words. All three are switches now, with the colour following the badge unless you say otherwise. * fix(studio): let a placed entry field follow its journal entry again The inspector says a bound field follows the journal entry and that editing it here breaks the link. The first half was not true: nothing ever re-read the entry, so renaming a title in Journey left the old words on the page for good, and the same went for every other bound field. The resolver runs where the journey is loaded and re-reads the fields that still point at an entry. What it will not do is as important as what it does. A field somebody has typed over stays typed over, an entry that is gone leaves its element alone rather than blanking it, and an entry that answers with nothing never wipes what is already on the page. Formatted fields — the date, the coordinates — are only re-read when the format itself changed, which is what keeps this from quietly rewriting books that already exist: an entry whose date was placed as a heading and then set in capitals keeps its capitals. Checked against the real database before it shipped, where the first version overwrote three of them. * feat(studio): start a new book empty, with six layouts to choose from A new journey opened onto a book that had already been laid out, which is the wrong first move: it decides the shape of somebody's book before they have seen it, and undoing it means deleting pages one at a time. A new book starts empty now, and the auto layout runs when it is asked to. The layouts themselves went from two to six, so choosing one is a real choice: what was there covered a photo-heavy spread and a text-heavy one and nothing in between. * fix(studio): hyphenate the export the way the editor does, and set the bleed Two things the press sees and the editor did not. A paragraph broke in different places in the PDF than on screen. The print document is written from scratch and never carried a language, so the browser hyphenated the editor's German and the export's nothing-in- particular. It takes the page's own language now. The wait for the sheet to be ready also covers the images inside SVG, with a ceiling, so a map that is slow to draw does not print half-finished. And the bleed and the safe margin are typeable. Both were baked into every page preset at what a photo-book vendor usually asks for, 3mm and 5mm, with no control anywhere. That is fine until a printer asks for 5 and 10, at which point the book cannot be made here at all: the export carries the wrong bleed and the crop marks sit in the wrong place, which nobody finds until the guillotine has run. * feat(studio): rebuild the inspector The panel on the right had grown by accretion: every element type had added its own controls in whatever shape suited it that day, so the same idea — a colour, a size, a toggle — looked different depending on what you had selected, and long panels were a wall of unlabelled fields. It is one set of controls now, used by every element: foldable sections, a line that holds a label and its control, radio choices, checkboxes, the app's own toggle, and a number field that holds a draft so typing "500" is not read as "5", clamped and written back under the cursor. Duplicated controls were merged rather than deleted; nothing an element could do before it cannot do now. The head carries the element's identity and its actions, so what you have selected is readable without counting fields, and the sections have room to breathe: what was there was correct and unreadable. * feat(studio): a route map worth printing The map in a book was a straight grey line between grey dots on a tile that was chosen for a screen. At print size those tiles are read at roughly four times the resolution they were fetched for, which is why it looked soft next to everything around it. The imagery comes from sources that hold up on paper: NASA's shaded relief and EOX's cloudless Sentinel-2, both licensed for it, picked at a zoom that matches the printer rather than the screen. Tiles are fetched at twice the density where the source offers it, and the seam between them scales with the tile instead of sitting at a fixed fraction of a millimetre, which under editor zoom fell below one device pixel and showed as white threads. The route is drawn rather than plotted. A leg that was never recorded bows, by an amount that grows with its length and turns away from the pole, and it dashes, because an inferred line should not claim to be a track — a recorded track never bows. Both strokes are laid down in two passes, casing then core, so the line stays legible over dark sea and bright desert alike. Legs can follow roads instead, routed leg by leg with the geometry thinned before it is stored, which is the setting a road trip wants and the one a flight cannot have. Stops carry their own first photograph, cut to a circle by a stencil that exists — the first one was written into a defs block that only appears on a map clipped to a coastline, so on an ordinary map it clipped nothing and the photographs sat square on the page. A stop with no photograph of its own is numbered rather than handed one from elsewhere in the journey: a marker at one place showing a picture taken at another is a caption that lies. Whatever the frame, the whole route is inside it. The window takes the frame's aspect, so the fit and the imagery agree instead of one containing what the other covers, and a map dragged narrow no longer cuts off its end. Each linked trip can carry its own map, and a map notices a photograph added to a stop afterwards rather than having to be placed again. * i18n(journey): the new Studio strings, in all 23 locales * test(journey): pin the coverage the map work brought with it The journey domain measures higher than its floor after this round, so the floor follows it up. Only journey moved; the generator's suggestion would have taken memories' functions down a point, and a ratchet that can fall is not a ratchet. * test(studio): cover the thinning that keeps a road route saveable The one path in roadRoute nothing exercised, and the one that matters most: a router answers a long drive with thousands of points at a precision no press can resolve, and all of it goes into the document. Keeping a leg whole is what pushed a real book past the body limit. Both ends have to survive so the line still meets its stops, and the spacing has to stay even, because cutting a run out of the middle would straighten exactly the bends somebody wanted to see.
515 lines
21 KiB
TypeScript
515 lines
21 KiB
TypeScript
import type { BookElement, BookMetric, BookPageSetup, JourneyStats } from '@trek/shared'
|
|
import { BOOK_METRICS } from '@trek/shared'
|
|
import { useStudioStore } from '../../store/studioStore'
|
|
import { PanelHead } from './StudioPanelHead'
|
|
import { TravelPreview } from './TravelPreview'
|
|
import { formatBookCoords } from './entryText'
|
|
import { routeFor } from './travelRefresh'
|
|
import { useMapSources } from './mapSources'
|
|
import { fetchRoads } from './roadRoute'
|
|
|
|
/**
|
|
* The journey's own figures, as things you can put on a page.
|
|
*
|
|
* This is the panel that makes Studio a *travel* book designer rather than a
|
|
* layout tool that happens to be full of holiday photographs. The route, the
|
|
* distance, the countries and the dates are already in TREK; the work is
|
|
* offering them as objects rather than as numbers someone has to retype.
|
|
*
|
|
* ── Why every tile is a real preview ──────────────────────────────────────
|
|
*
|
|
* These elements differ from one another by what they *say*, not by their
|
|
* shape. Four map styles are four maps; three summary layouts are the same six
|
|
* numbers arranged three ways. A named row with the value beside it — which is
|
|
* what this panel was first — tells you none of that: you cannot tell the dark
|
|
* map from the paper one, or a row of figures from a grid of them, until you
|
|
* have placed one and undone it.
|
|
*
|
|
* So each tile builds the element it would place and renders it through the
|
|
* page's own renderer, with this journey's real numbers in it. You are picking
|
|
* from the things themselves.
|
|
*
|
|
* Every button resolves its values *now* and writes them into the element, so
|
|
* what lands on the page is finished rather than a placeholder that needs the
|
|
* server to mean anything. The reasoning is in TravelElements.tsx, and the
|
|
* short version is that the print renderer must never depend on a fetch.
|
|
*/
|
|
|
|
const uid = (p: string) => `${p}-${Math.random().toString(36).slice(2, 9)}`
|
|
|
|
/*
|
|
* How many cards share a row.
|
|
*
|
|
* A stats panel is the width of a spread; shown two-up its figures scale down
|
|
* past reading, so it gets the row to itself. Maps, country lists and marks are
|
|
* compact enough that two-up still tells them apart, and two-up is what makes
|
|
* the section scannable. The tile measures its own width — see TravelPreview.
|
|
*/
|
|
|
|
/** Kilometres, grouped for the reader's locale. */
|
|
function formatDistance(metres: number, locale: string): string {
|
|
return `${new Intl.NumberFormat(locale, { maximumFractionDigits: 0 }).format(metres / 1000)} km`
|
|
}
|
|
|
|
function Card({ label, onClick, children, recommended = false, title }: {
|
|
label: string
|
|
onClick: () => void
|
|
/**
|
|
* Marked as the one to reach for, with a ring rather than with words.
|
|
*
|
|
* The label sits in a grid cell about eighty pixels wide, where "Satellite ·
|
|
* recommended" is two lines of ellipsis. A ring says the same thing in no
|
|
* space at all, and the tooltip carries the word for anyone who wonders why
|
|
* this card looks different.
|
|
*/
|
|
recommended?: boolean
|
|
title?: string
|
|
children: React.ReactNode
|
|
}) {
|
|
return (
|
|
<button
|
|
className={`st-travel-card ${recommended ? 'is-recommended' : ''}`}
|
|
onClick={onClick}
|
|
title={title ? `${label} — ${title}` : label}
|
|
>
|
|
{children}
|
|
<span className="st-travel-card-label">{label}</span>
|
|
</button>
|
|
)
|
|
}
|
|
|
|
export function StudioTravelPanel({
|
|
page, stats, path, t, locale,
|
|
}: {
|
|
page: BookPageSetup
|
|
stats: JourneyStats | null
|
|
/** The travelled way, already thinned. Empty when the trip has no geometry. */
|
|
path: [number, number][][]
|
|
t: (k: string) => string
|
|
locale: string
|
|
}) {
|
|
const addElement = useStudioStore(s => s.addElement)
|
|
const updateElement = useStudioStore(s => s.updateElement)
|
|
const active = useStudioStore(s => s.activeSpread)
|
|
const doc = useStudioStore(s => s.doc)
|
|
const spread = doc?.spreads[active]
|
|
const single = !!spread && spread.role !== 'inner'
|
|
|
|
const centre = (w: number, h: number) => {
|
|
const W = single ? page.pageWidth : page.pageWidth * 2
|
|
return { x: (W - w) / 2, y: (page.pageHeight - h) / 2, w, h }
|
|
}
|
|
|
|
const mapSide = Math.min(page.pageWidth, page.pageHeight) * 0.72
|
|
|
|
/*
|
|
* The imagery this instance can reach, so the relief card below places a map
|
|
* that already has its template and its credit rather than an empty one the
|
|
* user then has to point at a source.
|
|
*
|
|
* Asked for above the empty-state return, and not beside the card that reads
|
|
* it: a journey whose figures are still loading renders this panel once with
|
|
* no stats at all, and a hook that only runs on the second render is a hook
|
|
* count that changes between them.
|
|
*/
|
|
const sources = useMapSources(
|
|
{ x: 0, y: 0, w: mapSide, h: mapSide * 0.78 },
|
|
(stats?.points ?? []).map(p => ({ lat: p.lat, lng: p.lng })),
|
|
)
|
|
|
|
if (!stats) {
|
|
return (
|
|
<>
|
|
<PanelHead label={t('journey.studio.travel')} />
|
|
<div className="st-panel-scroll">
|
|
<p className="st-hint">{t('journey.studio.travelEmpty')}</p>
|
|
</div>
|
|
</>
|
|
)
|
|
}
|
|
|
|
const base = {
|
|
rotation: 0, opacity: 1, locked: false,
|
|
font: 'sans' as const, color: '#1a1a1a', accent: '#111111', textScale: 1, weight: 700 as const,
|
|
stale: false,
|
|
}
|
|
|
|
/**
|
|
* Country names in the reader's language, not the server's.
|
|
*
|
|
* The API answers in English, because it has no idea who will read the book.
|
|
* `Intl.DisplayNames` is the same CLDR data Atlas already uses for regions, so
|
|
* a German book says "Island" and an English one says "Iceland" — from one set
|
|
* of codes, with no translation table to keep in step.
|
|
*/
|
|
const countryName = (code: string): string => {
|
|
try {
|
|
const display = new Intl.DisplayNames([locale], { type: 'region' })
|
|
return display.of(code.toUpperCase()) || code.toUpperCase()
|
|
} catch {
|
|
return stats.countries.find(c => c.code === code)?.name || code.toUpperCase()
|
|
}
|
|
}
|
|
|
|
const values: Record<string, number> = {
|
|
distance: stats.distance,
|
|
days: stats.days,
|
|
steps: stats.steps,
|
|
photos: stats.photos,
|
|
countries: stats.countries.length,
|
|
places: stats.places,
|
|
furthest: stats.furthest,
|
|
}
|
|
|
|
/*
|
|
* Each builder returns the finished element. The tile renders it and the
|
|
* click places it, so the preview and the result are the same object — there
|
|
* is no second description of what a card means.
|
|
*/
|
|
/** The linked trips that actually put stops on the route. */
|
|
const tripsWithRoute = (stats.trips ?? []).filter(t => t.points > 0)
|
|
|
|
/* Satellite first: the recommendation should not be the second thing read. */
|
|
const imagery = sources
|
|
.filter(s => s.id === 'relief' || s.id === 'satellite')
|
|
.sort((a, b) => (a.id === 'satellite' ? -1 : b.id === 'satellite' ? 1 : 0))
|
|
|
|
/**
|
|
* One country, as the entry a list would have made of it.
|
|
*
|
|
* The list and the grid are gone: they were compositions somebody else made,
|
|
* deciding the order, the spacing and the type size, and the only way to
|
|
* change any of that was to not use them. What is left is the same entry —
|
|
* name over silhouette, set the same way — as an element you place one at a
|
|
* time. Three of them down a page is the list, with the spacing yours; one of
|
|
* them at 80mm is a chapter opener, which the list could never be.
|
|
*
|
|
* The name is editable afterwards, so numbering them "1. Germany",
|
|
* "2. Netherlands" is typing rather than a feature.
|
|
*/
|
|
const countryEl = (code: string): BookElement => ({
|
|
...base, id: uid('co'), kind: 'countries',
|
|
frame: centre(page.pageWidth * 0.34, 34),
|
|
codes: [code], names: [countryName(code)],
|
|
layout: 'list', showOutline: true, showFlag: false, showName: true, align: 'center',
|
|
} as BookElement)
|
|
|
|
const mapEl = (
|
|
style: 'minimal' | 'outline' | 'dark' | 'paper',
|
|
source: 'vector' | 'tiles' | 'static' = 'vector',
|
|
url = '',
|
|
attribution = '',
|
|
clip: 'rect' | 'country' = 'rect',
|
|
/** Null is the whole journey; a trip id is a map of that trip alone. */
|
|
tripId: number | null = null,
|
|
): BookElement => {
|
|
const route = routeFor(stats, tripId)
|
|
return {
|
|
...base, id: uid('mp'), kind: 'map',
|
|
frame: centre(mapSide, mapSide * 0.78),
|
|
style, source, tileUrl: url, attribution, zoom: null, clip, tripId,
|
|
/*
|
|
* White over a photograph, ink on paper. The accent IS the line, so this is
|
|
* how a satellite map arrives drawn the way the reference draws it, while
|
|
* the colour stays something the user can change afterwards.
|
|
*/
|
|
accent: source === 'tiles' || source === 'static' ? '#ffffff' : base.accent,
|
|
showLand: true, showRoute: true, showPins: true, showLabels: false,
|
|
/*
|
|
* A map placed today gets the drawn treatment; the contract defaults to the
|
|
* plain line so that every book made before this existed opens unchanged.
|
|
* Set explicitly rather than inherited because this object is cast, not
|
|
* parsed.
|
|
*/
|
|
routeStyle: 'drawn', routeArc: 'bow', routeDash: 'arcs', pinStyle: 'photo',
|
|
countries: tripId == null
|
|
? stats.countries.map(c => c.code)
|
|
: [...new Set(route.map(p => p.country).filter((c): c is string => !!c))],
|
|
points: route.map(p => ({ lat: p.lat, lng: p.lng, label: p.label, photoId: p.photoId ?? null })),
|
|
/*
|
|
* Frozen into the element, like every other travel figure: a page that
|
|
* fetches its own route at print time is a page that changes when someone
|
|
* edits the trip, and prints empty when the export runs signed out.
|
|
*/
|
|
path,
|
|
// Empty until somebody asks for the roads; see roadRoute.ts.
|
|
roads: [],
|
|
fitPadding: 0.5,
|
|
fitToCountries: true,
|
|
} as BookElement
|
|
}
|
|
|
|
/*
|
|
* A mark is placed at the size that suits what it holds.
|
|
*
|
|
* One size for all six put a flag and a country name into a box built for a
|
|
* line of coordinates, which is how a small mark ends up floating inside a
|
|
* large selection rectangle. Fractions of the page, so the proportions hold
|
|
* on any format.
|
|
*/
|
|
const MARK_SIZE: Record<string, [number, number]> = {
|
|
flag: [0.25, 0.062],
|
|
date: [0.16, 0.14],
|
|
day: [0.17, 0.062],
|
|
coords: [0.36, 0.05],
|
|
country: [0.22, 0.078],
|
|
distance: [0.26, 0.066],
|
|
}
|
|
|
|
const badgeEl = (
|
|
variant: 'flag' | 'date' | 'day' | 'coords' | 'country' | 'distance',
|
|
text: string,
|
|
sub: string,
|
|
code: string | null,
|
|
style: 'plain' | 'chip' | 'outline' | 'stacked' = 'plain',
|
|
): BookElement => {
|
|
const [fw, fh] = MARK_SIZE[variant] ?? [0.24, 0.08]
|
|
return {
|
|
...base, id: uid('bd'), kind: 'badge', autoColor: true,
|
|
showIcon: true, showLabel: true, autoIconColor: true, iconColor: '#111111',
|
|
frame: centre(page.pageWidth * fw, page.pageHeight * fh),
|
|
variant, text, sub, code, style,
|
|
} as BookElement
|
|
}
|
|
|
|
/**
|
|
* One figure on its own.
|
|
*
|
|
* A summary panel is a composition; a single figure is a mark you drop next
|
|
* to a photograph. Both are the same element with a different metric list,
|
|
* and offering only the composition meant anyone wanting "14 DAYS" beside a
|
|
* picture had to place all four and delete three.
|
|
*/
|
|
const singleEl = (metric: BookMetric): BookElement => ({
|
|
...base, id: uid('st'), kind: 'stats',
|
|
frame: centre(page.pageWidth * 0.22, page.pageHeight * 0.13),
|
|
metrics: [metric], layout: 'grid', showIcons: true, units: 'metric', values,
|
|
} as BookElement)
|
|
|
|
/** Place a copy — the previewed element keeps its own id for React. */
|
|
const place = (el: BookElement) => {
|
|
const placed = { ...el, id: uid(el.kind[0]) } as BookElement
|
|
addElement(active, placed)
|
|
|
|
/*
|
|
* A map arrives following the roads.
|
|
*
|
|
* Asked for after the element is on the page rather than before, so the map
|
|
* appears at once and the line firms up a moment later: a panel that sat
|
|
* there for fifteen seconds after a click would read as broken, and the
|
|
* straight line it starts with is the one it would have had anyway.
|
|
*
|
|
* Legs long enough to have been flights are never sent (see roadRoute.ts),
|
|
* the router's own cache answers a second placement of the same journey for
|
|
* free, and a failure leaves the leg exactly as it was.
|
|
*/
|
|
if (placed.kind === 'map' && placed.points.length > 1) {
|
|
void fetchRoads(placed.points.map(pt => ({ lat: pt.lat, lng: pt.lng })))
|
|
.then(roads => {
|
|
if (roads.some(r => r && r.length > 1)) {
|
|
updateElement(active, placed.id, { roads } as Partial<BookElement>)
|
|
}
|
|
})
|
|
.catch(() => { /* No roads is a state the map already draws. */ })
|
|
}
|
|
}
|
|
|
|
const first = stats.points[0] ?? null
|
|
const firstCountry = stats.countries[0] ?? null
|
|
const startDay = stats.start ? new Date(`${stats.start}T00:00:00`) : null
|
|
|
|
const marks: { el: BookElement; label: string }[] = []
|
|
if (startDay) {
|
|
marks.push({
|
|
el: badgeEl('date', String(startDay.getDate()),
|
|
startDay.toLocaleDateString(locale, { month: 'long' }).toUpperCase(), null, 'stacked'),
|
|
label: t('journey.studio.dateMark'),
|
|
})
|
|
}
|
|
marks.push({
|
|
el: badgeEl('day', `${t('journey.studio.dayWord')} 1`, '', null, 'chip'),
|
|
label: t('journey.studio.dayMark'),
|
|
})
|
|
if (first) {
|
|
marks.push({
|
|
el: badgeEl('coords', formatBookCoords(first.lat, first.lng), first.label, null),
|
|
label: t('journey.studio.coordsMark'),
|
|
})
|
|
}
|
|
if (firstCountry) {
|
|
marks.push({
|
|
el: badgeEl('flag', '', countryName(firstCountry.code), firstCountry.code),
|
|
label: t('journey.studio.flagMark'),
|
|
})
|
|
}
|
|
marks.push({
|
|
el: badgeEl('distance', formatDistance(stats.distance, locale), t('journey.studio.metric.distance'), null, 'outline'),
|
|
label: t('journey.studio.distanceMark'),
|
|
})
|
|
|
|
return (
|
|
<>
|
|
<PanelHead label={t('journey.studio.travel')} />
|
|
<div className="st-panel-scroll">
|
|
<div className="st-section">
|
|
<div className="st-section-label">{t('journey.studio.singleFigures')}</div>
|
|
<div className="st-travel-grid">
|
|
{BOOK_METRICS.map(metric => {
|
|
const el = singleEl(metric)
|
|
return (
|
|
<Card key={metric} label={t(`journey.studio.metric.${metric}`)} onClick={() => place(el)}>
|
|
<TravelPreview el={el} minHeight={44} maxHeight={62} />
|
|
</Card>
|
|
)
|
|
})}
|
|
</div>
|
|
</div>
|
|
|
|
<div className="st-section">
|
|
<div className="st-section-label">{t('journey.studio.routeMap')}</div>
|
|
{stats.points.length ? (
|
|
<>
|
|
<div className="st-travel-grid">
|
|
{(['minimal', 'outline', 'paper', 'dark'] as const).map(style => {
|
|
const el = mapEl(style)
|
|
return (
|
|
<Card key={style} label={t(`journey.studio.mapStyle.${style}`)} onClick={() => place(el)}>
|
|
<TravelPreview el={el} minHeight={62} maxHeight={80} />
|
|
</Card>
|
|
)
|
|
})}
|
|
{/*
|
|
The two imagery maps, as cards rather than as settings.
|
|
|
|
They were reachable only by placing an outline map and then
|
|
changing its source in the inspector, which is a thing nobody
|
|
finds. They are different pictures, not variants of one: relief
|
|
is land shaded in its own colours against a dark sea, drawn at
|
|
a scale that suits a continent, and satellite is the ground
|
|
itself, which is what a page about one country wants.
|
|
*/}
|
|
{imagery.map(src => (
|
|
<Card
|
|
key={src.id}
|
|
/*
|
|
* Satellite is marked rather than merely listed. The three
|
|
* imagery options are not equals: relief stops at about six
|
|
* hundred metres to the pixel, which is a continent's worth
|
|
* of detail and a smudge at country size, and the outlines
|
|
* are a diagram. For the page most people are making —
|
|
* a route across one or two countries — this is the one
|
|
* that prints, and saying so beats letting them find out
|
|
* after the book is bound.
|
|
*/
|
|
label={t(src.labelKey)}
|
|
recommended={src.id === 'satellite'}
|
|
title={src.id === 'satellite' ? t('journey.studio.recommended') : undefined}
|
|
onClick={() => place(mapEl('minimal', 'tiles', src.url, src.attribution))}
|
|
>
|
|
<TravelPreview
|
|
el={mapEl('minimal', 'tiles', src.url, src.attribution)}
|
|
minHeight={62}
|
|
maxHeight={80}
|
|
/>
|
|
</Card>
|
|
))}
|
|
</div>
|
|
|
|
{/*
|
|
A map per trip, for a journey made of more than one.
|
|
|
|
Two trips printed as a single route draw a line from the last
|
|
stop of the first to the first stop of the second, which is
|
|
usually the longest leg on the page and one nobody travelled.
|
|
Offered rather than imposed: some journeys really are one route
|
|
across several trips, and those still get the map above.
|
|
|
|
Only trips that have stops on the route are listed — a linked
|
|
trip nobody wrote about would place an empty frame.
|
|
*/}
|
|
{tripsWithRoute.length > 1 && (
|
|
<div style={{ marginTop: 12 }}>
|
|
<div className="st-section-label">{t('journey.studio.mapPerTrip')}</div>
|
|
<div className="st-travel-grid">
|
|
{tripsWithRoute.map(trip => {
|
|
const el = mapEl('minimal', 'vector', '', '', 'rect', trip.id)
|
|
return (
|
|
<Card
|
|
key={trip.id}
|
|
label={trip.title || t('journey.studio.untitled')}
|
|
onClick={() => place(el)}
|
|
>
|
|
<TravelPreview el={el} minHeight={62} maxHeight={80} />
|
|
</Card>
|
|
)
|
|
})}
|
|
</div>
|
|
</div>
|
|
)}
|
|
</>
|
|
) : (
|
|
<p className="st-hint">{t('journey.studio.noRoute')}</p>
|
|
)}
|
|
</div>
|
|
|
|
<div className="st-section">
|
|
<div className="st-section-label">{t('journey.studio.countries')}</div>
|
|
{stats.countries.length ? (
|
|
<>
|
|
{/*
|
|
One country per element, rather than a block listing them all.
|
|
|
|
A list of countries is a composition somebody else made: it
|
|
decides the order, the spacing and the type size, and the only
|
|
way to change any of it is to not use it. Placed one at a time
|
|
they are ordinary elements — numbered, moved, set at different
|
|
sizes, put on different pages — which is what a book of a trip
|
|
through several countries actually wants.
|
|
*/}
|
|
<div className="st-travel-grid">
|
|
{stats.countries.slice(0, 12).map(c => {
|
|
const el = countryEl(c.code)
|
|
return (
|
|
<Card key={c.code} label={countryName(c.code)} onClick={() => place(el)}>
|
|
<TravelPreview el={el} minHeight={44} maxHeight={64} />
|
|
</Card>
|
|
)
|
|
})}
|
|
</div>
|
|
|
|
{/*
|
|
And the same country as a mark: the outline beside the name
|
|
rather than under it, at the size of a line of type. It belongs
|
|
next to a date or a coordinate, not on a page of its own.
|
|
*/}
|
|
<div className="st-travel-grid" style={{ marginTop: 6 }}>
|
|
{stats.countries.slice(0, 12).map(c => {
|
|
const el = badgeEl('country', countryName(c.code), '', c.code)
|
|
return (
|
|
<Card key={`mark-${c.code}`} label={countryName(c.code)} onClick={() => place(el)}>
|
|
<TravelPreview el={el} minHeight={30} maxHeight={44} />
|
|
</Card>
|
|
)
|
|
})}
|
|
</div>
|
|
</>
|
|
) : (
|
|
<p className="st-hint">{t('journey.studio.noCountries')}</p>
|
|
)}
|
|
</div>
|
|
|
|
<div className="st-section">
|
|
<div className="st-section-label">{t('journey.studio.marks')}</div>
|
|
<div className="st-travel-grid">
|
|
{marks.map(({ el, label }) => (
|
|
<Card key={el.id} label={label} onClick={() => place(el)}>
|
|
<TravelPreview el={el} minHeight={34} maxHeight={52} />
|
|
</Card>
|
|
))}
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</>
|
|
)
|
|
}
|