@jjlmoya/utils-books 1.15.0 → 1.17.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. package/package.json +2 -2
  2. package/scripts/validate-icons.mjs +57 -0
  3. package/src/category/index.ts +2 -1
  4. package/src/entries.ts +4 -1
  5. package/src/tests/locale_completeness.test.ts +1 -1
  6. package/src/tests/mfe_assets_contract.test.ts +51 -0
  7. package/src/tests/tool_validation.test.ts +1 -1
  8. package/src/tool/book-cover-bleed-calculator/bibliography.astro +16 -0
  9. package/src/tool/book-cover-bleed-calculator/bibliography.ts +15 -0
  10. package/src/tool/book-cover-bleed-calculator/book-cover-bleed-calculator.css +362 -0
  11. package/src/tool/book-cover-bleed-calculator/component.astro +80 -0
  12. package/src/tool/book-cover-bleed-calculator/controller.ts +91 -0
  13. package/src/tool/book-cover-bleed-calculator/dom-views.ts +41 -0
  14. package/src/tool/book-cover-bleed-calculator/entry.ts +27 -0
  15. package/src/tool/book-cover-bleed-calculator/evaluator.ts +18 -0
  16. package/src/tool/book-cover-bleed-calculator/i18n/de.ts +22 -0
  17. package/src/tool/book-cover-bleed-calculator/i18n/en.ts +75 -0
  18. package/src/tool/book-cover-bleed-calculator/i18n/es.ts +22 -0
  19. package/src/tool/book-cover-bleed-calculator/i18n/fr.ts +22 -0
  20. package/src/tool/book-cover-bleed-calculator/i18n/id.ts +22 -0
  21. package/src/tool/book-cover-bleed-calculator/i18n/it.ts +22 -0
  22. package/src/tool/book-cover-bleed-calculator/i18n/ja.ts +22 -0
  23. package/src/tool/book-cover-bleed-calculator/i18n/ko.ts +22 -0
  24. package/src/tool/book-cover-bleed-calculator/i18n/nl.ts +22 -0
  25. package/src/tool/book-cover-bleed-calculator/i18n/pl.ts +22 -0
  26. package/src/tool/book-cover-bleed-calculator/i18n/pt.ts +22 -0
  27. package/src/tool/book-cover-bleed-calculator/i18n/ru.ts +22 -0
  28. package/src/tool/book-cover-bleed-calculator/i18n/sv.ts +22 -0
  29. package/src/tool/book-cover-bleed-calculator/i18n/tr.ts +22 -0
  30. package/src/tool/book-cover-bleed-calculator/i18n/zh.ts +22 -0
  31. package/src/tool/book-cover-bleed-calculator/index.ts +11 -0
  32. package/src/tool/book-cover-bleed-calculator/logic.test.ts +28 -0
  33. package/src/tool/book-cover-bleed-calculator/logic.ts +65 -0
  34. package/src/tool/book-cover-bleed-calculator/seo.astro +15 -0
  35. package/src/tool/book-cover-bleed-calculator/storage.ts +31 -0
  36. package/src/tool/book-cover-bleed-calculator/ui.ts +32 -0
  37. package/src/tools.ts +2 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jjlmoya/utils-books",
3
- "version": "1.15.0",
3
+ "version": "1.17.0",
4
4
  "type": "module",
5
5
  "main": "./src/index.ts",
6
6
  "types": "./src/index.ts",
@@ -46,7 +46,7 @@
46
46
  "postinstall": "node scripts/postinstall.mjs",
47
47
  "predev": "node scripts/postinstall.mjs",
48
48
  "prestart": "node scripts/postinstall.mjs",
49
- "prebuild": "node scripts/postinstall.mjs",
49
+ "prebuild": "node scripts/postinstall.mjs && node scripts/validate-icons.mjs",
50
50
  "qa": "npm run lint && npm run test && npm run build",
51
51
  "cf:dry-run": "npm run build && wrangler deploy --dry-run",
52
52
  "cf:preview": "npm run build && wrangler deploy --config wrangler.staging.jsonc",
@@ -0,0 +1,57 @@
1
+ #!/usr/bin/env node
2
+
3
+ import { createRequire } from 'node:module';
4
+ import { readFileSync, readdirSync } from 'node:fs';
5
+ import { dirname, join, relative, resolve } from 'node:path';
6
+ import { fileURLToPath } from 'node:url';
7
+
8
+ const require = createRequire(import.meta.url);
9
+ const packageJsonPath = require.resolve('@iconify-json/mdi/package.json');
10
+ const packageRoot = dirname(packageJsonPath);
11
+ const iconSet = JSON.parse(readFileSync(join(packageRoot, 'icons.json'), 'utf8'));
12
+ const availableIcons = new Set([
13
+ ...Object.keys(iconSet.icons ?? {}),
14
+ ...Object.keys(iconSet.aliases ?? {}),
15
+ ]);
16
+
17
+ const repoRoot = resolve(dirname(fileURLToPath(import.meta.url)), '..');
18
+ const sourceRoot = resolve(repoRoot, 'src');
19
+ const extensions = new Set(['.astro', '.js', '.mjs', '.ts', '.tsx']);
20
+ const iconPattern = /\bmdi:([a-z0-9-]+)\b/g;
21
+ const failures = [];
22
+ let references = 0;
23
+
24
+ function walk(directory) {
25
+ const entries = readdirSync(directory, { withFileTypes: true });
26
+ for (const entry of entries) {
27
+ const path = join(directory, entry.name);
28
+ if (entry.isDirectory()) {
29
+ if (entry.name !== 'node_modules' && entry.name !== 'dist' && entry.name !== 'tests') {
30
+ walk(path);
31
+ }
32
+ continue;
33
+ }
34
+ if (!extensions.has(path.slice(path.lastIndexOf('.')))) continue;
35
+
36
+ const source = readFileSync(path, 'utf8');
37
+ for (const match of source.matchAll(iconPattern)) {
38
+ references += 1;
39
+ const iconName = match[1];
40
+ if (availableIcons.has(iconName)) continue;
41
+
42
+ const line = source.slice(0, match.index).split('\n').length;
43
+ failures.push(`${relative(repoRoot, path)}:${line} — mdi:${iconName}`);
44
+ }
45
+ }
46
+ }
47
+
48
+ walk(sourceRoot);
49
+
50
+ if (failures.length > 0) {
51
+ console.error('Invalid MDI icons found:');
52
+ for (const failure of failures) console.error(`- ${failure}`);
53
+ console.error(`Checked ${references} MDI icon references against @iconify-json/mdi.`);
54
+ process.exitCode = 1;
55
+ } else {
56
+ console.log(`MDI icon validation passed: ${references} references checked.`);
57
+ }
@@ -3,11 +3,12 @@ import { bookInteriorMarginAndGutterPlanner } from '../tool/book-interior-margin
3
3
  import { bookIndexPageBudgetCalculator } from '../tool/book-index-page-budget-calculator/entry';
4
4
  import { bookRoyaltyBreakEvenCalculator } from '../tool/book-royalty-break-even-calculator/entry';
5
5
  import { bookPrintSignatureCalculator } from '../tool/book-print-signature-calculator/entry';
6
+ import { bookCoverBleedCalculator } from '../tool/book-cover-bleed-calculator/entry';
6
7
  import type { CategoryLocaleContent, KnownLocale } from '../types';
7
8
 
8
9
  export const booksCategory = {
9
10
  icon: 'mdi:book-open-page-variant-outline',
10
- tools: [bookPaginationAndSpineCalculator, bookInteriorMarginAndGutterPlanner, bookIndexPageBudgetCalculator, bookRoyaltyBreakEvenCalculator, bookPrintSignatureCalculator],
11
+ tools: [bookPaginationAndSpineCalculator, bookInteriorMarginAndGutterPlanner, bookIndexPageBudgetCalculator, bookRoyaltyBreakEvenCalculator, bookPrintSignatureCalculator, bookCoverBleedCalculator],
11
12
  i18n: {
12
13
  de: () => import('./i18n/de').then((module) => module.content),
13
14
  en: () => import('./i18n/en').then((module) => module.content),
package/src/entries.ts CHANGED
@@ -6,6 +6,8 @@ export { bookIndexPageBudgetCalculator } from './tool/book-index-page-budget-cal
6
6
  export type { BookIndexUI, BookIndexLocaleContent } from './tool/book-index-page-budget-calculator/entry';
7
7
  export { bookRoyaltyBreakEvenCalculator } from './tool/book-royalty-break-even-calculator/entry';
8
8
  export type { BookRoyaltyUI, BookRoyaltyLocaleContent } from './tool/book-royalty-break-even-calculator/entry';
9
+ export { bookCoverBleedCalculator } from './tool/book-cover-bleed-calculator/entry';
10
+ export type { BookCoverBleedUI, BookCoverBleedLocaleContent } from './tool/book-cover-bleed-calculator/entry';
9
11
 
10
12
  import { bookPaginationAndSpineCalculator } from './tool/book-pagination-and-spine-calculator/entry';
11
13
  import { bookInteriorMarginAndGutterPlanner } from './tool/book-interior-margin-and-gutter-planner/entry';
@@ -13,5 +15,6 @@ import { bookReadingTimeDeadlinePlanner } from './tool/book-reading-time-deadlin
13
15
  import { bookIndexPageBudgetCalculator } from './tool/book-index-page-budget-calculator/entry';
14
16
  import { bookRoyaltyBreakEvenCalculator } from './tool/book-royalty-break-even-calculator/entry';
15
17
  import { bookPrintSignatureCalculator } from './tool/book-print-signature-calculator/entry';
18
+ import { bookCoverBleedCalculator } from './tool/book-cover-bleed-calculator/entry';
16
19
 
17
- export const ALL_ENTRIES = [bookPaginationAndSpineCalculator, bookInteriorMarginAndGutterPlanner, bookReadingTimeDeadlinePlanner, bookIndexPageBudgetCalculator, bookRoyaltyBreakEvenCalculator, bookPrintSignatureCalculator];
20
+ export const ALL_ENTRIES = [bookPaginationAndSpineCalculator, bookInteriorMarginAndGutterPlanner, bookReadingTimeDeadlinePlanner, bookIndexPageBudgetCalculator, bookRoyaltyBreakEvenCalculator, bookPrintSignatureCalculator, bookCoverBleedCalculator];
@@ -18,6 +18,6 @@ describe('Locale Completeness Validation', () => {
18
18
  });
19
19
 
20
20
  it('all tools registered', () => {
21
- expect(ALL_TOOLS.length).toBe(6);
21
+ expect(ALL_TOOLS.length).toBe(7);
22
22
  });
23
23
  });
@@ -0,0 +1,51 @@
1
+ import { existsSync, readdirSync, statSync } from 'node:fs';
2
+ import { basename, join } from 'node:path';
3
+ import { describe, expect, it } from 'vitest';
4
+ import { ALL_TOOLS } from '../tools';
5
+ import { CATEGORY_OG_IMAGE, getUtilityOgImage } from '../mfe/assets';
6
+
7
+ const categoryImageMatch = CATEGORY_OG_IMAGE.match(
8
+ /^(\/_utilities\/[^/]+\/images)\/([^/]+\.webp)\?version=(.+)$/,
9
+ );
10
+
11
+ if (!categoryImageMatch) {
12
+ throw new Error(`Unexpected CATEGORY_OG_IMAGE format: ${CATEGORY_OG_IMAGE}`);
13
+ }
14
+
15
+ const [, imageUrlRoot, categoryImage, assetVersion] = categoryImageMatch;
16
+ if (!imageUrlRoot || !categoryImage || !assetVersion) {
17
+ throw new Error(`Unexpected CATEGORY_OG_IMAGE captures: ${CATEGORY_OG_IMAGE}`);
18
+ }
19
+ const assetRoot = join(process.cwd(), 'public', imageUrlRoot.slice(1));
20
+ const categorySlug = basename(categoryImage, '.webp');
21
+
22
+ describe('MFE asset contract', () => {
23
+ it('has one non-empty English-slug OG image per category and registered tool', async () => {
24
+ const expectedSlugs = new Set([categorySlug]);
25
+
26
+ for (const { entry } of ALL_TOOLS) {
27
+ const englishLoader = entry.i18n.en;
28
+ if (!englishLoader) throw new Error(`Missing English locale for ${entry.id}`);
29
+
30
+ const englishContent = await englishLoader();
31
+ expectedSlugs.add(englishContent.slug);
32
+ }
33
+
34
+ const actualSlugs = new Set(
35
+ readdirSync(assetRoot)
36
+ .filter((filename) => filename.endsWith('.webp'))
37
+ .map((filename) => filename.slice(0, -'.webp'.length)),
38
+ );
39
+
40
+ expect(actualSlugs).toEqual(expectedSlugs);
41
+
42
+ for (const slug of expectedSlugs) {
43
+ const imagePath = join(assetRoot, `${slug}.webp`);
44
+ expect(existsSync(imagePath), `${imagePath} should exist`).toBe(true);
45
+ expect(statSync(imagePath).size, `${imagePath} should not be empty`).toBeGreaterThan(0);
46
+ expect(getUtilityOgImage(slug)).toBe(
47
+ `${imageUrlRoot}/${slug}.webp?version=${assetVersion}`,
48
+ );
49
+ }
50
+ }, 30000);
51
+ });
@@ -5,7 +5,7 @@ import { booksCategory } from '../data';
5
5
  describe('Tool Validation Suite', () => {
6
6
  describe('Library Registration', () => {
7
7
  it('should have tools in ALL_TOOLS', () => {
8
- expect(ALL_TOOLS.length).toBe(6);
8
+ expect(ALL_TOOLS.length).toBe(7);
9
9
  });
10
10
 
11
11
  it('booksCategory should be defined', () => {
@@ -0,0 +1,16 @@
1
+ ---
2
+ import { Bibliography as SharedBibliography } from '@jjlmoya/utils-shared';
3
+ import type { KnownLocale } from '../../types';
4
+ import { bibliography } from './bibliography';
5
+ import { bookCoverBleedCalculator } from './entry';
6
+
7
+ interface Props {
8
+ locale: KnownLocale;
9
+ }
10
+
11
+ const { locale } = Astro.props;
12
+ const loader = bookCoverBleedCalculator.i18n[locale] ?? bookCoverBleedCalculator.i18n.en;
13
+ const content = loader ? await loader() : null;
14
+ ---
15
+
16
+ <SharedBibliography links={content?.bibliography ?? bibliography} />
@@ -0,0 +1,15 @@
1
+ import type { BibliographyEntry } from '../../types';
2
+
3
+ export const bibliography: BibliographyEntry[] = [
4
+ { name: 'Amazon KDP. Create a Paperback Cover', url: 'https://kdp.amazon.com/en_US/help/topic/G201953020' },
5
+ { name: 'Pixartprinting. Cómo preparar correctamente la cubierta de un libro', url: 'https://support.pixartprinting.com/hc/es/articles/27577189469586-C%C3%B3mo-preparar-correctamente-la-cubierta-de-un-libro' },
6
+ { name: 'IngramSpark. File Creation Guide', url: 'https://www.ingramspark.com/hubfs/downloads/file-creation-guide.pdf?t=1540849595582' },
7
+ ];
8
+
9
+ const [kdp, pixartprinting, ingramspark] = bibliography;
10
+
11
+ export const bibliographyTraceability = [
12
+ { url: kdp!.url, region: 'United States', language: 'English', supports: 'The unfolded cover equation and the 0.125 inch bleed example.' },
13
+ { url: pixartprinting!.url, region: 'Spain', language: 'Spanish', supports: 'The distinction between bleed, trim, and fold lines in a printer cover template.' },
14
+ { url: ingramspark!.url, region: 'International printing', language: 'English', supports: 'Spine safety and bleed handling for a perfect bound cover file.' },
15
+ ];
@@ -0,0 +1,362 @@
1
+ :root {
2
+ --n-global-paper: #fffdf8;
3
+ --n-global-surface: #f2ede2;
4
+ --n-global-ink: #24231f;
5
+ --n-global-muted: #746f63;
6
+ --n-global-line: #d4cabb;
7
+ --n-global-accent: #bb4f32;
8
+ --n-global-accent-soft: #f1d4c9;
9
+ --n-global-blue: #4e7182;
10
+ --n-global-green: #58745e;
11
+ --n-global-warning: #a86828;
12
+ }
13
+
14
+ .theme-dark {
15
+ --n-global-paper: #17191b;
16
+ --n-global-surface: #232629;
17
+ --n-global-ink: #f4efe4;
18
+ --n-global-muted: #b9b1a3;
19
+ --n-global-line: #4b4e4d;
20
+ --n-global-accent: #ef8566;
21
+ --n-global-accent-soft: #653629;
22
+ --n-global-blue: #82aab8;
23
+ --n-global-green: #98bc9c;
24
+ --n-global-warning: #e4a45e;
25
+ }
26
+
27
+ .book-cover-bleed-tool {
28
+ --n-paper: var(--n-global-paper);
29
+ --n-surface: var(--n-global-surface);
30
+ --n-ink: var(--n-global-ink);
31
+ --n-muted: var(--n-global-muted);
32
+ --n-line: var(--n-global-line);
33
+ --n-accent: var(--n-global-accent);
34
+ --n-accent-soft: var(--n-global-accent-soft);
35
+ --n-blue: var(--n-global-blue);
36
+ --n-green: var(--n-global-green);
37
+ --n-warning: var(--n-global-warning);
38
+
39
+ color: var(--n-ink);
40
+ }
41
+
42
+ .n-cover-workbench {
43
+ display: grid;
44
+ grid-template-columns: minmax(16rem, 0.78fr) minmax(24rem, 1.5fr);
45
+ min-height: 35rem;
46
+ overflow: hidden;
47
+ border: 1px solid var(--n-line);
48
+ background: var(--n-paper);
49
+ }
50
+
51
+ .n-cover-controls {
52
+ display: flex;
53
+ flex-direction: column;
54
+ gap: 1.6rem;
55
+ padding: 1.5rem;
56
+ border-right: 1px solid var(--n-line);
57
+ background: var(--n-surface);
58
+ }
59
+
60
+ .n-control-line {
61
+ display: grid;
62
+ gap: 0.7rem;
63
+ }
64
+
65
+ .n-preset-strip,
66
+ .n-unit-switch {
67
+ display: flex;
68
+ flex-wrap: wrap;
69
+ gap: 0.45rem;
70
+ }
71
+
72
+ .n-overline {
73
+ color: var(--n-muted);
74
+ font-size: 0.68rem;
75
+ font-weight: 800;
76
+ letter-spacing: 0.12em;
77
+ text-transform: uppercase;
78
+ }
79
+
80
+ .n-preset,
81
+ .n-unit-switch button,
82
+ .n-copy {
83
+ min-height: 2.5rem;
84
+ padding: 0.6rem 0.8rem;
85
+ border: 1px solid var(--n-line);
86
+ border-radius: 0.35rem;
87
+ background: var(--n-paper);
88
+ color: var(--n-ink);
89
+ font: inherit;
90
+ font-size: 0.8rem;
91
+ font-weight: 700;
92
+ cursor: pointer;
93
+ }
94
+
95
+ .n-preset:hover,
96
+ .n-unit-switch button:hover,
97
+ .n-copy:hover,
98
+ .n-preset:focus-visible,
99
+ .n-unit-switch button:focus-visible,
100
+ .n-copy:focus-visible {
101
+ border-color: var(--n-accent);
102
+ }
103
+
104
+ .n-unit-switch button[aria-pressed="true"],
105
+ .n-preset[aria-pressed="true"] {
106
+ border-color: var(--n-accent);
107
+ background: var(--n-accent-soft);
108
+ color: var(--n-accent);
109
+ }
110
+
111
+ .n-field-grid {
112
+ display: grid;
113
+ gap: 1rem;
114
+ }
115
+
116
+ .n-field {
117
+ display: grid;
118
+ gap: 0.4rem;
119
+ color: var(--n-muted);
120
+ font-size: 0.78rem;
121
+ font-weight: 700;
122
+ }
123
+
124
+ .n-input-wrap {
125
+ display: flex;
126
+ align-items: center;
127
+ min-height: 3rem;
128
+ border: 1px solid var(--n-line);
129
+ border-radius: 0.25rem;
130
+ background: var(--n-paper);
131
+ }
132
+
133
+ .n-input-wrap:focus-within {
134
+ border-color: var(--n-accent);
135
+ outline: 2px solid var(--n-accent-soft);
136
+ outline-offset: 2px;
137
+ }
138
+
139
+ .n-input-wrap input {
140
+ width: 100%;
141
+ min-width: 0;
142
+ padding: 0.7rem 0.75rem;
143
+ border: 0;
144
+ outline: 0;
145
+ background: transparent;
146
+ color: var(--n-ink);
147
+ font: inherit;
148
+ font-size: 1.05rem;
149
+ font-variant-numeric: tabular-nums;
150
+ }
151
+
152
+ .n-input-wrap b {
153
+ padding: 0 0.75rem 0 0.2rem;
154
+ color: var(--n-muted);
155
+ font-size: 0.76rem;
156
+ white-space: nowrap;
157
+ }
158
+
159
+ .n-assumption {
160
+ display: flex;
161
+ justify-content: space-between;
162
+ gap: 1rem;
163
+ margin: auto 0 0;
164
+ padding-top: 1rem;
165
+ border-top: 1px solid var(--n-line);
166
+ color: var(--n-muted);
167
+ font-size: 0.75rem;
168
+ }
169
+
170
+ .n-assumption strong {
171
+ color: var(--n-ink);
172
+ font-variant-numeric: tabular-nums;
173
+ white-space: nowrap;
174
+ }
175
+
176
+ .n-cover-proof {
177
+ display: flex;
178
+ flex-direction: column;
179
+ min-width: 0;
180
+ padding: 1.5rem;
181
+ }
182
+
183
+ .n-proof-heading,
184
+ .n-measure-row {
185
+ display: flex;
186
+ align-items: flex-start;
187
+ justify-content: space-between;
188
+ gap: 1rem;
189
+ }
190
+
191
+ .n-proof-heading > div {
192
+ display: grid;
193
+ gap: 0.25rem;
194
+ }
195
+
196
+ .n-proof-heading strong {
197
+ color: var(--n-accent);
198
+ font-size: clamp(1.6rem, 4vw, 2.65rem);
199
+ font-variant-numeric: tabular-nums;
200
+ line-height: 1;
201
+ }
202
+
203
+ .n-copy {
204
+ border-color: var(--n-accent);
205
+ color: var(--n-accent);
206
+ }
207
+
208
+ .n-proof-stage {
209
+ display: flex;
210
+ align-items: center;
211
+ flex: 1;
212
+ min-height: 20rem;
213
+ padding: 1rem 0;
214
+ }
215
+
216
+ .n-proof-svg {
217
+ display: block;
218
+ width: 100%;
219
+ height: auto;
220
+ overflow: visible;
221
+ }
222
+
223
+ .n-proof-bleed {
224
+ fill: var(--n-accent-soft);
225
+ }
226
+
227
+ .n-proof-back,
228
+ .n-proof-front {
229
+ fill: var(--n-paper);
230
+ stroke: var(--n-line);
231
+ stroke-width: 1;
232
+ }
233
+
234
+ .n-proof-spine {
235
+ fill: var(--n-blue);
236
+ }
237
+
238
+ .n-proof-safe {
239
+ fill: none;
240
+ stroke: var(--n-green);
241
+ stroke-dasharray: 5 5;
242
+ stroke-width: 2;
243
+ }
244
+
245
+ .n-proof-trim-line,
246
+ .n-proof-fold-line,
247
+ .n-proof-measure-line {
248
+ stroke: var(--n-ink);
249
+ stroke-width: 1;
250
+ }
251
+
252
+ .n-proof-fold-line {
253
+ stroke: var(--n-blue);
254
+ stroke-dasharray: 4 4;
255
+ }
256
+
257
+ .n-proof-label,
258
+ .n-proof-spine-label,
259
+ .n-proof-caption,
260
+ .n-proof-measure {
261
+ fill: var(--n-ink);
262
+ font-size: 14px;
263
+ font-weight: 800;
264
+ letter-spacing: 0.05em;
265
+ text-transform: uppercase;
266
+ }
267
+
268
+ .n-proof-spine-label {
269
+ fill: var(--n-paper);
270
+ font-size: 11px;
271
+ }
272
+
273
+ .n-proof-caption {
274
+ fill: var(--n-muted);
275
+ font-size: 10px;
276
+ font-weight: 600;
277
+ }
278
+
279
+ .n-proof-measure {
280
+ font-size: 16px;
281
+ font-variant-numeric: tabular-nums;
282
+ text-transform: none;
283
+ }
284
+
285
+ .n-measure-row {
286
+ border-top: 1px solid var(--n-line);
287
+ border-bottom: 1px solid var(--n-line);
288
+ }
289
+
290
+ .n-measure-row > div {
291
+ display: grid;
292
+ flex: 1;
293
+ gap: 0.4rem;
294
+ padding: 0.85rem 0.75rem;
295
+ }
296
+
297
+ .n-measure-row > div + div {
298
+ border-left: 1px solid var(--n-line);
299
+ }
300
+
301
+ .n-measure-row span {
302
+ color: var(--n-muted);
303
+ font-size: 0.68rem;
304
+ font-weight: 800;
305
+ letter-spacing: 0.08em;
306
+ text-transform: uppercase;
307
+ }
308
+
309
+ .n-measure-row strong {
310
+ color: var(--n-ink);
311
+ font-size: 1.1rem;
312
+ font-variant-numeric: tabular-nums;
313
+ }
314
+
315
+ .n-proof-status {
316
+ display: flex;
317
+ flex-wrap: wrap;
318
+ gap: 0.5rem;
319
+ align-items: baseline;
320
+ padding-top: 0.85rem;
321
+ color: var(--n-muted);
322
+ font-size: 0.78rem;
323
+ }
324
+
325
+ .n-proof-status strong {
326
+ color: var(--n-green);
327
+ }
328
+
329
+ .n-proof-status[data-tone="attention"] strong {
330
+ color: var(--n-warning);
331
+ }
332
+
333
+ .n-copy-status {
334
+ min-height: 1.1rem;
335
+ color: var(--n-accent);
336
+ font-size: 0.75rem;
337
+ text-align: right;
338
+ }
339
+
340
+ @media (max-width: 760px) {
341
+ .n-cover-workbench {
342
+ grid-template-columns: 1fr;
343
+ }
344
+
345
+ .n-cover-controls {
346
+ border-right: 0;
347
+ border-bottom: 1px solid var(--n-line);
348
+ }
349
+
350
+ .n-proof-stage {
351
+ min-height: 14rem;
352
+ }
353
+
354
+ .n-measure-row {
355
+ flex-direction: column;
356
+ }
357
+
358
+ .n-measure-row > div + div {
359
+ border-top: 1px solid var(--n-line);
360
+ border-left: 0;
361
+ }
362
+ }
@@ -0,0 +1,80 @@
1
+ ---
2
+ import type { BookCoverBleedUI } from './ui';
3
+
4
+ interface Props {
5
+ ui: BookCoverBleedUI;
6
+ }
7
+
8
+ const { ui } = Astro.props;
9
+ ---
10
+
11
+ <div class="book-cover-bleed-tool" data-book-cover-tool>
12
+ <div class="n-cover-workbench">
13
+ <section class="n-cover-controls" aria-label={ui.presetLabel}>
14
+ <div class="n-control-line n-preset-line">
15
+ <span class="n-overline">{ui.presetLabel}</span>
16
+ <div class="n-preset-strip" role="group" aria-label={ui.presetLabel}>
17
+ <button type="button" class="n-preset" data-preset="trade" aria-pressed="true">{ui.tradePreset}</button>
18
+ <button type="button" class="n-preset" data-preset="a5" aria-pressed="false">{ui.a5Preset}</button>
19
+ <button type="button" class="n-preset" data-preset="digest" aria-pressed="false">{ui.digestPreset}</button>
20
+ </div>
21
+ </div>
22
+ <div class="n-control-line n-unit-line">
23
+ <span class="n-overline">{ui.unitLabel}</span>
24
+ <div class="n-unit-switch" role="group" aria-label={ui.unitLabel}>
25
+ <button type="button" data-unit="metric" aria-pressed="true">{ui.metricLabel}</button>
26
+ <button type="button" data-unit="imperial" aria-pressed="false">{ui.imperialLabel}</button>
27
+ </div>
28
+ </div>
29
+ <div class="n-field-grid">
30
+ <label class="n-field">
31
+ <span>{ui.trimWidthLabel}</span>
32
+ <span class="n-input-wrap"><input data-input="trim-width" type="number" min="1" step="0.1" inputmode="decimal" /><b data-unit-suffix>mm</b></span>
33
+ </label>
34
+ <label class="n-field">
35
+ <span>{ui.trimHeightLabel}</span>
36
+ <span class="n-input-wrap"><input data-input="trim-height" type="number" min="1" step="0.1" inputmode="decimal" /><b data-unit-suffix>mm</b></span>
37
+ </label>
38
+ <label class="n-field">
39
+ <span>{ui.pageCountLabel}</span>
40
+ <span class="n-input-wrap"><input data-input="page-count" type="number" min="1" step="1" inputmode="numeric" /><b>pages</b></span>
41
+ </label>
42
+ <label class="n-field">
43
+ <span>{ui.pageThicknessLabel}</span>
44
+ <span class="n-input-wrap"><input data-input="page-thickness" type="number" min="0.0001" step="0.0001" inputmode="decimal" /><b data-unit-suffix>mm</b></span>
45
+ </label>
46
+ <label class="n-field n-field-wide">
47
+ <span>{ui.bleedLabel}</span>
48
+ <span class="n-input-wrap"><input data-input="bleed" type="number" min="0" step="0.1" inputmode="decimal" /><b data-unit-suffix>mm</b></span>
49
+ </label>
50
+ </div>
51
+ <p class="n-assumption"><span>{ui.spineSafetyLabel}</span><strong>1.6 <span data-unit-suffix>mm</span></strong></p>
52
+ </section>
53
+ <section class="n-cover-proof" aria-live="polite">
54
+ <div class="n-proof-heading">
55
+ <div>
56
+ <span class="n-overline">{ui.spineAreaLabel}</span>
57
+ <strong data-result="spine">0 mm</strong>
58
+ </div>
59
+ <button class="n-copy" type="button" data-copy>{ui.copyLabel}</button>
60
+ </div>
61
+ <div class="n-proof-stage" data-cover-proof></div>
62
+ <div class="n-measure-row">
63
+ <div><span>{ui.fullWidthLabel}</span><strong data-result="width">0 mm</strong></div>
64
+ <div><span>{ui.fullHeightLabel}</span><strong data-result="height">0 mm</strong></div>
65
+ <div><span>{ui.safeSpineLabel}</span><strong data-result="safe">0 mm</strong></div>
66
+ </div>
67
+ <div class="n-proof-status" data-status data-tone="ready"><strong data-status-label>{ui.readyLabel}</strong><span data-status-detail>{ui.readyDetail}</span></div>
68
+ <span class="n-copy-status" data-copy-status role="status"></span>
69
+ </section>
70
+ </div>
71
+ </div>
72
+
73
+ <script is:inline type="application/json" data-book-cover-config set:html={JSON.stringify(ui)}></script>
74
+ <script>
75
+ import { mountBookCoverCalculator } from './controller';
76
+
77
+ const config = document.querySelector<HTMLScriptElement>('[data-book-cover-config]');
78
+ const root = document.querySelector<HTMLElement>('[data-book-cover-tool]');
79
+ if (config && root) mountBookCoverCalculator(root, JSON.parse(config.textContent ?? '{}'));
80
+ </script>