diff --git a/edit.html b/edit.html index 4cc9ce66..22471cbb 100644 --- a/edit.html +++ b/edit.html @@ -453,15 +453,22 @@ - + - - - - - - + + + + + + + + + + + + + diff --git a/edit/settings.css b/edit/settings.css index 9b338329..883c8a48 100644 --- a/edit/settings.css +++ b/edit/settings.css @@ -28,4 +28,19 @@ grid-gap: .3em; margin: .3em 0; } - +.radio-group .form-label { + display: block; +} +.radio-item { + display: flex; + margin: 0.3em 0 .3em; + padding: 0; + align-items: center; + width: max-content; +} +.radio-item input { + margin: 0 0.6em 0 0; +} +[disabled] .radio-label { + opacity: 0.4; +} diff --git a/edit/settings.js b/edit/settings.js index cfb9f2c3..89f34300 100644 --- a/edit/settings.js +++ b/edit/settings.js @@ -8,7 +8,7 @@ function StyleSettings(editor) { const inputs = [ createInput('.style-update-url input', () => style.updateUrl || '', e => API.styles.config(style.id, 'updateUrl', e.target.value)), - createInput('.style-prefer-scheme select', () => style.preferScheme || 'none', + createRadio('.style-prefer-scheme input', () => style.preferScheme || 'none', e => API.styles.config(style.id, 'preferScheme', e.target.value)), createInput('.style-priority input', () => style.priority || 0, e => API.styles.config(style.id, 'priority', e.target.valueAsNumber)), @@ -28,6 +28,26 @@ function StyleSettings(editor) { inputs.forEach(i => i.update()); } + function createRadio(selector, getter, setter) { + const els = document.querySelectorAll(selector); + for (const el of els) { + el.addEventListener('change', e => { + if (el.checked) { + setter(e); + } + }); + } + return { + update() { + for (const el of els) { + if (el.value === getter()) { + el.checked = true; + } + } + }, + }; + } + function createInput(selector, getter, setter) { const el = document.querySelector(selector); el.addEventListener('change', setter);