Skip to content

armgit / bento

Public Imported from GitHub
0

Bento, the office suite that fits in a file

convert page: native controls draw dark on the dark page (#728)

nyblnetc7cc5f3d002c
diff --git a/scripts/test-convert/convert-page.ts b/scripts/test-convert/convert-page.ts
index 7c9ab726..a597b5f9 100644
--- a/scripts/test-convert/convert-page.ts
+++ b/scripts/test-convert/convert-page.ts
@@ -82,6 +82,22 @@ ok(urls.every(u => u === 'https://bento.page/releases/slides/manifest.json'),
ok(!/\b(XMLHttpRequest|WebSocket|EventSource|sendBeacon|RTCPeerConnection)\b/.test(js), 'no second network API in the bundle')
ok(/nothing is uploaded|never leaves/i.test(markup), 'the page says so in words')
+console.log('no control in the browser\'s default look')
+{
+ // The page is dark. A native control draws in the page's color-scheme, and
+ // accent-color only tints the CHECKED state; with neither, an unchecked
+ // radio or checkbox renders the light UA default on the dark page.
+ const css = styles[0]?.[1] ?? ''
+ ok(/:root\{[^}]*color-scheme:\s*dark/.test(css), ':root declares color-scheme: dark, so native controls draw dark')
+ const page = fs.readFileSync(path.join(root, 'convert/page/convert-page.ts'), 'utf8') + markup
+ const kinds = [...new Set([...page.matchAll(/<input[^>]*type="(\w+)"/g)].map((m) => m[1]))]
+ ok(kinds.every((k) => k === 'file' || k === 'radio' || k === 'checkbox'), `the only inputs are file, radio and checkbox (${kinds.join(', ')}); no text field or select to style`)
+ ok(/#drop input\{[^}]*opacity:0/.test(css), 'the file input is never drawn (the drop zone stands in)')
+ ok(/\.option input\{[^}]*accent-color:var\(--peach\)/.test(css) && /\.flag input\{[^}]*accent-color:var\(--peach\)/.test(css),
+ 'radios and checkboxes are tinted with the bento accent')
+ ok(!/<(select|textarea)\b/.test(page), 'no select or textarea anywhere on the page')
+}
+
console.log('what the page offers')
ok(/id="sample"/.test(markup) && /A little more portable/.test(js), 'the sample deck is built in (nothing fetched for it)')
ok(/<a [^>]*href="\/slides\/"/.test(markup), 'the header links the editor, like the rest of bento.page')
diff --git a/site-src/convert.html b/site-src/convert.html
index 2307aa48..236133f6 100644
--- a/site-src/convert.html
+++ b/site-src/convert.html
@@ -24,6 +24,10 @@
--in:'Instrument Sans',-apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,sans-serif;
--fr:Fraunces,Georgia,'Times New Roman',serif;
}
+/* The page is dark, so native controls must be too: without this the
+ unchecked radio and checkbox draw the browser's light default (a white
+ box with a grey border). accent-color tints the checked state. */
+:root{color-scheme:dark}
*{margin:0;padding:0;box-sizing:border-box}
body{background:var(--ink);color:var(--text);font-family:var(--in);line-height:1.6;-webkit-font-smoothing:antialiased}
a{color:var(--peach)}