mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-11-26 06:37:33 +00:00
fix(book): the designed book paces its bursts, lists and maps the way the design asks
A burst of four or more photos within a quarter of an hour becomes one grid, no beat runs three times in a row, and an entry's pros and cons go into the room under its words on the opener, the panorama or the quiet page, with a note when they find none. A chapter map is the map of the chapter's trip, and entries on no trip are named in the notes. The sorts compare by code unit, the summary metrics and the page lookups exist once, and a flag or country mark asked for by its own code is labelled with that country.
This commit is contained in:
@@ -15,6 +15,7 @@ import {
|
||||
} from './book-ops-core';
|
||||
import {
|
||||
bookBadgeValue,
|
||||
bookCountryName,
|
||||
bookEntryListItems,
|
||||
bookTravelBadge,
|
||||
bookTravelCountries,
|
||||
@@ -342,13 +343,31 @@ function newBadge(spec: Extract<TravelSpec, { kind: 'badge' }>, id: string, at:
|
||||
}
|
||||
const value = {
|
||||
text,
|
||||
sub: spec.sub ?? resolved?.sub ?? '',
|
||||
sub: spec.sub ?? badgeSub(spec, resolved?.sub, resolved?.code, travel) ?? '',
|
||||
code: spec.code ?? ownCode ?? resolved?.code ?? null,
|
||||
};
|
||||
const frame = at(bookTravelSize('badge', env.page, { variant: spec.variant }));
|
||||
return bookTravelBadge({ id, frame, variant: spec.variant, value });
|
||||
}
|
||||
|
||||
/** The marks whose code names a country. */
|
||||
const COUNTRY_MARKS: ReadonlySet<string> = new Set(['flag', 'country']);
|
||||
|
||||
/**
|
||||
* A flag or country mark asked for by its own code is labelled with that
|
||||
* country; the journey's value names its first country, the one a mark
|
||||
* without a code shows.
|
||||
*/
|
||||
function badgeSub(
|
||||
spec: Extract<TravelSpec, { kind: 'badge' }>,
|
||||
sub: string | undefined,
|
||||
code: string | null | undefined,
|
||||
travel: BookTravelContext | undefined,
|
||||
): string | undefined {
|
||||
if (!travel || !spec.code || !COUNTRY_MARKS.has(spec.variant)) return sub;
|
||||
return spec.code === code ? sub : bookCountryName(spec.code, travel.locale, travel.stats);
|
||||
}
|
||||
|
||||
function newList(spec: Extract<TravelSpec, { kind: 'list' }>, id: string, at: At, env: ElementOpEnv): BookElement {
|
||||
const travel = travelFor(spec.entryId, env);
|
||||
let items = spec.items ?? [];
|
||||
|
||||
Reference in New Issue
Block a user