mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-11-21 03:26:07 +00:00
bdf5767a5f
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.
166 lines
5.9 KiB
TypeScript
166 lines
5.9 KiB
TypeScript
import type { BookPageNumbers, BookPageSetup } from '@trek/shared';
|
||
import { BOOK_THEME_PRESETS } from '@trek/shared';
|
||
import { MousePointerClick, Palette } from 'lucide-react';
|
||
|
||
import { useStudioStore } from '../../../store/studioStore';
|
||
import '../../../styles/studio-panels.css';
|
||
import { StudioBackgroundSection } from '../StudioBackgroundSection';
|
||
import { Choice, Line, NumField, Section, Switch } from '../StudioControls';
|
||
import { PanelHead } from '../StudioPanelHead';
|
||
import type { JourneySource, StudioT } from '../StudioSidebar';
|
||
import { Swatches } from '../StudioSwatches';
|
||
import { ThemeSheet } from '../theme/ThemeSheet';
|
||
|
||
/**
|
||
* The inspector with nothing selected: the page and the book.
|
||
*
|
||
* What the panel is for comes first, in a line at its top, since an empty
|
||
* inspector is the first thing a new book shows. Then the page that is open,
|
||
* its background; the book's theme, as the Theme panel draws it, with the way
|
||
* to that panel; and the page numbers, which are no property of any element,
|
||
* because the number a page carries depends on where its spread sits. The page
|
||
* size sits in the head.
|
||
*/
|
||
|
||
type Folio = BookPageNumbers['position'];
|
||
|
||
const FOLIO_POSITIONS: readonly Folio[] = ['outer', 'inner', 'centre'];
|
||
|
||
/** The book's theme as a little page and its name, and the button to the Theme panel. */
|
||
function ThemeSummary({ t, onOpenTheme }: { t: StudioT; onOpenTheme?: () => void }) {
|
||
const theme = useStudioStore((s) => s.doc?.theme);
|
||
const preset = theme?.id ? BOOK_THEME_PRESETS.find((p) => p.id === theme.id) : undefined;
|
||
return (
|
||
<Section label={t('studio.theme.panel')}>
|
||
{theme ? (
|
||
<div className="st-theme-sum">
|
||
<ThemeSheet palette={theme.palette} display={theme.fonts.display} />
|
||
{preset && <span className="st-theme-sum-name">{t(preset.labelKey)}</span>}
|
||
</div>
|
||
) : (
|
||
<p className="st-hint st-hint-before">{t('studio.theme.intro')}</p>
|
||
)}
|
||
{onOpenTheme && (
|
||
<button type="button" className="st-chip" onClick={onOpenTheme}>
|
||
<Palette size={13} aria-hidden />
|
||
{t(theme ? 'studio.theme.change' : 'studio.theme.choose')}
|
||
</button>
|
||
)}
|
||
</Section>
|
||
);
|
||
}
|
||
|
||
/** Whether the pages carry numbers, and where, from which number, how large, in what colour. */
|
||
function PageNumbersSection({
|
||
folios,
|
||
setPageNumbers,
|
||
t,
|
||
}: {
|
||
folios: BookPageNumbers;
|
||
setPageNumbers: (patch: Partial<BookPageNumbers>) => void;
|
||
t: StudioT;
|
||
}) {
|
||
return (
|
||
<Section label={t('journey.studio.pageNumbers')}>
|
||
<Switch
|
||
label={t('journey.studio.pageNumbers')}
|
||
on={folios.show}
|
||
onToggle={() => setPageNumbers({ show: !folios.show })}
|
||
/>
|
||
{folios.show && (
|
||
<>
|
||
<div className="st-section-gap">
|
||
<Line label={t('journey.studio.position')}>
|
||
<Choice
|
||
value={folios.position}
|
||
ariaLabel={t('journey.studio.position')}
|
||
options={FOLIO_POSITIONS.map((pos) => ({ value: pos, label: t(`journey.studio.folio.${pos}`) }))}
|
||
onPick={(position) => setPageNumbers({ position })}
|
||
/>
|
||
</Line>
|
||
</div>
|
||
<div className="st-grid2 st-section-gap">
|
||
<NumField
|
||
label={t('journey.studio.folioStart')}
|
||
value={folios.startAt}
|
||
min={0}
|
||
max={9999}
|
||
step={1}
|
||
onChange={(v) => setPageNumbers({ startAt: Math.round(v) })}
|
||
/>
|
||
<NumField
|
||
label={t('journey.studio.size')}
|
||
value={folios.size}
|
||
min={4}
|
||
max={48}
|
||
step={0.5}
|
||
unit="pt"
|
||
onChange={(v) => setPageNumbers({ size: v })}
|
||
/>
|
||
</div>
|
||
<div className="st-section-gap">
|
||
<NumField
|
||
label={t('journey.studio.folioMargin')}
|
||
value={folios.margin}
|
||
min={0}
|
||
max={60}
|
||
step={0.5}
|
||
unit="mm"
|
||
onChange={(v) => setPageNumbers({ margin: v })}
|
||
/>
|
||
</div>
|
||
<div className="st-section-gap">
|
||
<Switch
|
||
label={t('journey.studio.folioAuto')}
|
||
on={folios.autoColor}
|
||
onToggle={() => setPageNumbers({ autoColor: !folios.autoColor })}
|
||
/>
|
||
</div>
|
||
{/* Picking a colour is the other way to turn automatic off, so the row stays reachable and simply
|
||
reads as inactive. */}
|
||
<div className={`st-section-gap ${folios.autoColor ? 'is-quiet' : ''}`}>
|
||
<Line label={t('journey.studio.colour')} wide>
|
||
<Swatches value={folios.color} onPick={(c) => setPageNumbers({ color: c, autoColor: false })} />
|
||
</Line>
|
||
</div>
|
||
</>
|
||
)}
|
||
</Section>
|
||
);
|
||
}
|
||
|
||
export function StudioDocumentInspector({
|
||
spreadIndex,
|
||
page,
|
||
source,
|
||
setPageNumbers,
|
||
onOpenTheme,
|
||
t,
|
||
}: {
|
||
spreadIndex: number;
|
||
page: BookPageSetup;
|
||
source: JourneySource;
|
||
setPageNumbers: (patch: Partial<BookPageNumbers>) => void;
|
||
/** Opens the Theme panel in the rail; without it the summary offers no button. */
|
||
onOpenTheme?: () => void;
|
||
t: StudioT;
|
||
}) {
|
||
return (
|
||
<aside className="st-panel st-inspector">
|
||
<PanelHead
|
||
label={t('journey.studio.document')}
|
||
meta={`${t('journey.studio.pageHint')} ${page.pageWidth} × ${page.pageHeight} mm`}
|
||
/>
|
||
<div className="st-panel-scroll">
|
||
<p className="st-empty-note">
|
||
<MousePointerClick size={15} aria-hidden />
|
||
<span>{t('journey.studio.inspectorEmpty')}</span>
|
||
</p>
|
||
<StudioBackgroundSection spreadIndex={spreadIndex} page={page} source={source} t={t} />
|
||
<ThemeSummary t={t} onOpenTheme={onOpenTheme} />
|
||
<PageNumbersSection folios={page.pageNumbers} setPageNumbers={setPageNumbers} t={t} />
|
||
</div>
|
||
</aside>
|
||
);
|
||
}
|