UserCSS Number variable now accepts a range

This commit is contained in:
Rob Garrison 2018-09-07 08:47:14 -05:00
parent d9c748d92f
commit 2291197277
3 changed files with 6 additions and 5 deletions

View File

@ -217,6 +217,7 @@ var usercss = (() => {
break; break;
} }
case 'number':
case 'range': { case 'range': {
state.errorPrefix = 'Invalid JSON: '; state.errorPrefix = 'Invalid JSON: ';
parseJSONValue(state); parseJSONValue(state);

View File

@ -104,7 +104,7 @@
margin-right: 4px; margin-right: 4px;
} }
.config-range span { .config-number span, .config-range span {
line-height: 22px; line-height: 22px;
} }

View File

@ -267,7 +267,8 @@ function configDialog(style) {
onfocus: selectAllOnFocus, onfocus: selectAllOnFocus,
}; };
const dataset = {}; const dataset = {};
if (va.type === 'range') { if (va.type === 'range' || va.type === 'number') {
children = va.type === 'range' ? [$create('span.current-value', {textContent: va.value})] : [];
options.value = va.default; options.value = va.default;
if (typeof va.range[0] !== 'undefined') { if (typeof va.range[0] !== 'undefined') {
options.min = dataset.min = va.range[0]; options.min = dataset.min = va.range[0];
@ -278,12 +279,11 @@ function configDialog(style) {
if (va.range[2]) { if (va.range[2]) {
options.step = va.range[2]; options.step = va.range[2];
} }
children = [ children.push(
$create('span.current-value', {textContent: va.value}),
$create('span.current-range', {dataset}, [ $create('span.current-range', {dataset}, [
va.input = $create('input.config-value', options), va.input = $create('input.config-value', options),
]) ])
]; );
} else { } else {
children = [ children = [
va.input = $create('input.config-value', options), va.input = $create('input.config-value', options),