From d1bff0adf7fd37de226d6954daa69f36bcd02f78 Mon Sep 17 00:00:00 2001 From: Mike Lynch Date: Sun, 5 Jan 2025 17:17:52 +1100 Subject: [PATCH] Toggle switches on and off the second grid --- src/index.md | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/index.md b/src/index.md index a3a984e..c957590 100644 --- a/src/index.md +++ b/src/index.md @@ -18,10 +18,19 @@ const m1 = view(Inputs.range([1, 5], {value: 2, step: 1, label:"m1"})); const n1 = view(Inputs.range([1, 5], {value: 2, step: 1, label:"n1"})); -const fg2 = view(Inputs.color({label: "fg2", value: d3.color("blue").formatHex()})) +const v2 = view(Inputs.toggle({label: "Second grid", value:true})); -const m2 = view(Inputs.range([1, 5], {value: 2, step: 1, label:"m2"})); -const n2 = view(Inputs.range([1, 5], {value: 2, step: 1, label:"n2"})); +``` + +```js + +const fg2 = view(Inputs.color({ + label: "fg2", value: d3.color("blue").formatHex(), + disabled: !v2 +})) + +const m2 = view(Inputs.range([1, 5], {value: 2, step: 1, label:"m2", disabled: !v2})); +const n2 = view(Inputs.range([1, 5], {value: 2, step: 1, label:"n2", disabled: !v2})); ``` @@ -29,7 +38,7 @@ const n2 = view(Inputs.range([1, 5], {value: 2, step: 1, label:"n2"})); ```js const dots1 = make_dots(1 / m1, n1, CELL, WIDTH) -const dots2 = make_dots(1 / m2, n2, CELL, WIDTH) +const dots2 = v2 ? make_dots(1 / m2, n2, CELL, WIDTH) : [] ```