From 164330a4ef23214d8c354799be0f5d2596c3e547 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADctor=20Losada=20Hern=C3=A1ndez?= Date: Sun, 9 Nov 2025 12:28:38 +0100 Subject: [PATCH] second commit --- client/components/dialog.jsx | 3 +- client/components/newDocumentForm.jsx | 105 +++++++++++++++------ client/components/newDocumentForm.less | 34 +++++-- client/homebrew/navbar/newbrew.navitem.jsx | 9 +- 4 files changed, 108 insertions(+), 43 deletions(-) diff --git a/client/components/dialog.jsx b/client/components/dialog.jsx index e88d06c99..d26076d34 100644 --- a/client/components/dialog.jsx +++ b/client/components/dialog.jsx @@ -2,7 +2,7 @@ import React from 'react'; const { useRef, useEffect } = React; -function Dialog({ dismisskeys = [], closeText = 'Close', blocking = false, ...rest }) { +function Dialog({ dismisskeys = [], closeText = 'Close', blocking = false, callbackFn = ()=>{}, ...rest }) { const dialogRef = useRef(null); useEffect(()=>{ @@ -15,6 +15,7 @@ function Dialog({ dismisskeys = [], closeText = 'Close', blocking = false, ...re localStorage.setItem(key, 'true'); } }); + callbackFn(); dialogRef.current?.close(); }; diff --git a/client/components/newDocumentForm.jsx b/client/components/newDocumentForm.jsx index cd437a68d..d0903e64f 100644 --- a/client/components/newDocumentForm.jsx +++ b/client/components/newDocumentForm.jsx @@ -1,35 +1,80 @@ -import React from "react"; +import React from 'react'; import './newDocumentForm.less'; +const sizes = [ + // ISO A-series (converted from mm) + { id: 'A3', width: 11.7, height: 16.5 }, // 297 × 420 mm + { id: 'A4', width: 8.27, height: 11.69 }, // 210 × 297 mm + { id: 'A5', width: 5.83, height: 8.27 }, // 148 × 210 mm + { id: 'A6', width: 4.13, height: 5.83 }, // 105 × 148 mm + + // US & common book trim sizes + { id: 'US_Letter', width: 8.5, height: 11 }, + { id: 'Trade_Paperback', width: 6, height: 9 }, + { id: 'Digest', width: 5.5, height: 8.5 }, + { id: 'Pocket_Book', width: 4, height: 6 }, + { id: 'Square_8_5', width: 8.5, height: 8.5 }, + { id: 'Large_Square', width: 10, height: 10 }, +]; +const cmPerInch = 2.54; +const pxPerInch = 96; + +const showAs = (val, unit)=>{ + switch (unit) { + case 'cm': + return Math.round(val*cmPerInch); + case 'px': + return Math.round(val*pxPerInch); + default: + return val; + } +}; + +const unit = 'cm'; + export function NewDocumentForm() { + return ( + <> + +
+
+ {sizes.map((size)=>( +
{}}> +
+ {showAs(size.width, unit)}{unit} by {showAs(size.height, unit)}{unit} +
+ {size.id.replaceAll('_', ' ')} +
+ ))} +
+
+
+ + {}} /> +
+
+ +