mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-12-01 08:53:13 +00:00
feat(studio): a sticker library of 148 hand-drawn illustrations, placed, recoloured and searched by people and the assistant
A new element kind, sticker, draws layered vector illustrations from a library in twelve themes, behind its own entry point @trek/shared/stickers. Studio gets a Stickers rail section (themes, localized search, recently used, click or drag to place) and an inspector for colour slots, mirroring, turning and opacity. The assistant gets list_book_assets, add and style of stickers in edit_book_page, stickers in describe_book_page and an overlap warning for a sticker over words. BOOK_SCHEMA_REV goes to 2.
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import { BOOK_FONTS_IDS, BOOK_WEIGHTS, type BookFontFamily } from './book-fonts.data';
|
||||
import { bookPaintFieldSchema } from './book-paint.schema';
|
||||
import { MAX_STICKER_SLOTS } from './stickers/sticker-types';
|
||||
|
||||
import { z } from 'zod';
|
||||
|
||||
@@ -744,6 +745,27 @@ export const bookIconElementSchema = z.object({
|
||||
lineWidth: z.number().min(0.25).max(4).default(2),
|
||||
});
|
||||
|
||||
/**
|
||||
* An illustration from the Studio's sticker library (stickers/, book-sticker.ts).
|
||||
*
|
||||
* The drawing is not in the document, only its id: the library is code that
|
||||
* ships with the app, so a book stays small and every copy of a sticker draws
|
||||
* the same. Like an icon, an id this build does not know draws nothing and
|
||||
* costs the page nothing else. `colors` repaints the sticker's slots in order,
|
||||
* empty for its own colours; `flipX` mirrors it, for a bird facing the other
|
||||
* way or an arrow pointing back.
|
||||
*/
|
||||
export const bookStickerElementSchema = z.object({
|
||||
...elementBase,
|
||||
kind: z.literal('sticker'),
|
||||
stickerId: z
|
||||
.string()
|
||||
.regex(/^[a-z][A-Za-z0-9]*$/, 'expected a sticker id')
|
||||
.max(48),
|
||||
colors: z.array(hex).max(MAX_STICKER_SLOTS).default([]),
|
||||
flipX: z.boolean().default(false),
|
||||
});
|
||||
|
||||
/**
|
||||
* A journal entry's pros and cons, set as a page.
|
||||
*
|
||||
@@ -803,9 +825,11 @@ export const bookElementSchema = z.discriminatedUnion('kind', [
|
||||
bookBadgeElementSchema,
|
||||
bookListElementSchema,
|
||||
bookIconElementSchema,
|
||||
bookStickerElementSchema,
|
||||
]);
|
||||
export type BookElement = z.infer<typeof bookElementSchema>;
|
||||
export type BookIconElement = z.infer<typeof bookIconElementSchema>;
|
||||
export type BookStickerElement = z.infer<typeof bookStickerElementSchema>;
|
||||
export type BookPhotoElement = z.infer<typeof bookPhotoElementSchema>;
|
||||
export type BookTextElement = z.infer<typeof bookTextElementSchema>;
|
||||
export type BookShapeElement = z.infer<typeof bookShapeElementSchema>;
|
||||
|
||||
Reference in New Issue
Block a user