Files
TREK/client/src/components/Studio/pagePresets.ts
T
Maurice bdf5767a5f feat(studio): rebuild both side panels around one head, one row and one order
The rail lists its sections in the order a book is made: Pages, Content,
Layouts, Elements and Travel, then Theme and Layers set apart below a rule.
Stickers are a tab of Elements beside the icons instead of a rail section of
their own, and Elements has six tabs (text, shapes, lines, frames with the
grids, icons, stickers). The quotation mark moved to the text styles, the
outline rectangle to the basic shapes and the plain rule to the lines. The rail
and every tab row are tab lists the arrow keys walk through, and a long name
wraps instead of being cut. The icon and sticker searches say in the field how
many match, which the sticker library's own head used to.

Every panel on both sides opens on the same head, and every labelled control
uses one row that moves the control under its label when the two do not fit,
so no label sits in a fixed column any more. Number fields, chips, sliders,
tab labels, theme names and travel cards wrap the same way, a country beside
a stop wraps under itself, and an upload cell holds its words to two lines
with the whole label in its tooltip. The heads, shelves and groups are real
headings, so a screen reader can walk the panels by them.

The inspector shows every kind in one order: what the element is and says,
its position and size, its look, its effects, then Arrange. Align and the
stacking buttons are one Arrange group with a button that opens the page in
Layers; its rows sit under their labels, each in two sets that move to a
second line whole. Rarely used groups start folded and open on an element
that already uses them (a turned element, a map held at a zoom, a summary set
in another face), and every group mounts afresh for the next selection. A
sticker's duplicate angle and opacity are gone in favour of the shared
position group, which now has the turn buttons for every kind. With several
elements selected it keeps their angle, opacity and turn, and the mirror when
all of them are stickers, and leaves the frame's numbers to one element. A
photo's fill page and fill spread sit under its crop. With nothing selected
the inspector shows the page background, the book's theme with the way to the
Theme panel, and the page numbers.

Seventeen translation keys nothing has used since before the rebuild (the old
inspector title, the empty spread note, the summary and country list names,
the roads buttons and others) are gone from every language. The broad key
template the old panels used had counted them as reached; the format names,
the empty photo grid messages and the map source hints are now named where the
key check can read them.

Also fixed on the way: the travel stops list shared its class with the
gradient stops and was laid out as sixteen pixel handles; the alignment
buttons were named in raw English; the map's print resolution note joined its
two halves with a dash.
2026-10-24 03:08:27 +00:00

97 lines
3.3 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/**
* Book formats, in millimetres, because that is the language a print shop
* speaks.
*
* These are photo-book sizes, not paper sizes. A4 is a stationery standard and
* only some vendors print books in it; what CEWE, Saal and Polarsteps actually
* bind is mostly square — Polarsteps' own book is 21 × 21, which is why that is
* the default here. A5 landscape is the small, cheap format, 30 × 30 the big
* coffee-table one.
*
* Trim is the finished page; bleed is what the guillotine takes; safe is the
* margin nothing important may cross. A spread is two pages side by side, so its
* drawing width is twice the page width.
*/
export interface PagePreset {
id: PagePresetId
/** One page, millimetres. */
pageWidthMm: number
pageHeightMm: number
/** What gets drawn — a spread is two pages wide. */
widthMm: number
heightMm: number
bleedMm: number
safeMm: number
labelKey: string
}
export type PagePresetId =
| 'square-210'
| 'square-300'
| 'a4-landscape'
| 'a4-portrait'
| 'a5-landscape'
/**
* Any width and height at all.
*
* The five presets are what CEWE, Saal and Polarsteps actually bind, which
* covers almost everyone — but "almost" is doing real work there. A local
* printer with a 24 x 18 press, a book meant to sit in a particular shelf,
* a format a vendor lists that nobody else does: the picker either has a way
* to say that or those books cannot be made here at all.
*/
| 'custom'
/**
* A format from its page size. Its name is given as `labelKey` where the format
* is listed, where the check of the client's translation keys can read it.
*/
function preset(id: PagePresetId, w: number, h: number, { labelKey }: { labelKey: string }): PagePreset {
return {
id,
pageWidthMm: w,
pageHeightMm: h,
widthMm: w * 2,
heightMm: h,
bleedMm: 3,
safeMm: 5,
labelKey,
}
}
export const PAGE_PRESETS: Record<PagePresetId, PagePreset> = {
'square-210': preset('square-210', 210, 210, { labelKey: 'journey.studio.formatSquare21' }),
'square-300': preset('square-300', 300, 300, { labelKey: 'journey.studio.formatSquare30' }),
'a4-landscape': preset('a4-landscape', 297, 210, { labelKey: 'journey.studio.formatA4Landscape' }),
'a4-portrait': preset('a4-portrait', 210, 297, { labelKey: 'journey.studio.formatA4Portrait' }),
'a5-landscape': preset('a5-landscape', 210, 148, { labelKey: 'journey.studio.formatA5Landscape' }),
// The dimensions here are only the starting point the fields open on; the
// document keeps whatever the user types.
custom: preset('custom', 210, 210, { labelKey: 'journey.studio.formatCustom' }),
}
/**
* What a page may measure, in millimetres.
*
* The floor is a passport-sized book; the ceiling is what a large-format press
* takes, and also what keeps a spread inside the schema two-decimal
* millimetre field without the editor scaling to a smear.
*/
export const PAGE_MIN_MM = 60
export const PAGE_MAX_MM = 500
export function clampPageSize(value: number): number {
if (!Number.isFinite(value)) return PAGE_MIN_MM
return Math.min(PAGE_MAX_MM, Math.max(PAGE_MIN_MM, Math.round(value * 10) / 10))
}
/** Square first: it is what a photo book usually is. Custom last, as a way out. */
export const PAGE_PRESET_ORDER: PagePresetId[] = [
'square-210',
'square-300',
'a4-landscape',
'a4-portrait',
'a5-landscape',
'custom',
]