From e66f784344049f8ebf10d7cca8d8606d218e63c9 Mon Sep 17 00:00:00 2001 From: arne Date: Fri, 19 Jul 2024 00:31:33 +0200 Subject: [PATCH] Set minimum cell size --- src/main.ts | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/main.ts b/src/main.ts index 06354a2..2a671af 100644 --- a/src/main.ts +++ b/src/main.ts @@ -12,7 +12,10 @@ const parsePattern = (pattern: string) => pattern.split('').map(x => Number.pars const xs = reactive(xs_).map((pattern) => parsePattern(pattern)) const ys = reactive(ys_).map((pattern) => parsePattern(pattern)) -const cellSize = reactive(cellSize_).map(num => Number.parseInt(num, 10)) +const cellSize = reactive(cellSize_).map(num => { + const next = Number.parseInt(num, 10) + return Number.isNaN(next)|| next < 5 ? 5 : next +}) // available size for a2: 420 * 594 const width = 420 @@ -91,8 +94,9 @@ $compile( ["h2", {}, "Settings"], ["div", {}, ["label", {}, "Grid size: ", ["input", { - type: "text", - value: cellSize_, + type: "number", + min: "5", + value: cellSize.deref()!, oninput: $input(cellSize) }]]], ["div", {}, ["label", {}, "X Pattern: ",