Skip to content

Commit 1b644f2

Browse files
committed
feat: add hidden option
closes #8
1 parent 22872d2 commit 1b644f2

File tree

3 files changed

+14
-9
lines changed

3 files changed

+14
-9
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,8 @@ Options can all have the following properties,
6868
* `string` - `desc`
6969
* `string` - `preview` - A preview image. Represents the extension of the image, example "png". If this is used, the image must be placed in a `previews` folder where `options.html` is, and named the name as this option's key, which is its name prepended by tab name if any.
7070
* `Object` - `default` - Default value.
71-
* `boolean` - `disabled` - The field can be disabled, for whatever reason...
71+
* `boolean` - `disabled` - The field can be disabled.
72+
* `boolean` - `hidden` - A hidden field, default options will still be saved.
7273
* `boolean` - `singleline` - If you'd like to position the label and the field on the same line, instead of the default multiline layout.
7374
* `Function` - `validate` - Called with the new value of field, will only save if it returns `true`.
7475

src/css/chrome-options.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,10 @@ body.show-tab-title .frame .mainview header {
310310
display: inline-block;
311311
}
312312

313+
.chrome-bootstrap .hidden {
314+
display: none;
315+
}
316+
313317
.chrome-bootstrap .preview-container {
314318
position: relative;
315319
padding: 0 1em;

src/js/base.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -63,17 +63,17 @@ chrome.options.addOption = (key, value, save, option) => {
6363
}
6464
}
6565

66-
// `key` is passed down from parent options to be used here.
67-
if (option.preview) {
68-
const $label = $option.querySelector('label');
69-
$label.append(h('span.preview-container', h('span.preview')),
70-
h('img.preview-image', { src: 'previews/' + key + '.' + option.preview }));
71-
}
72-
73-
if (option.disabled) {
66+
if (option.hidden) {
67+
$option.classList.add('hidden');
68+
} else if (option.disabled) {
7469
$option.querySelectorAll('input, select, textarea').forEach(($f) => {
7570
$f.setAttribute('disabled', true);
7671
});
72+
} else if (option.preview) {
73+
// `key` is passed down from parent options to be used here.
74+
const $label = $option.querySelector('label');
75+
$label.append(h('span.preview-container', h('span.preview')),
76+
h('img.preview-image', { src: 'previews/' + key + '.' + option.preview }));
7777
}
7878

7979
return $option;

0 commit comments

Comments
 (0)