1
0
mirror of https://github.com/BookStackApp/BookStack.git synced 2025-06-11 13:48:13 +03:00

Updated another set of components

This commit is contained in:
Dan Brown
2022-11-15 12:44:57 +00:00
parent 4310d34135
commit b37e84dc10
17 changed files with 119 additions and 143 deletions

View File

@ -1,18 +1,20 @@
import {Component} from "./component";
class SettingColorPicker {
export class SettingColorPicker extends Component {
constructor(elem) {
this.elem = elem;
this.colorInput = elem.querySelector('input[type=color]');
this.resetButton = elem.querySelector('[setting-color-picker-reset]');
this.defaultButton = elem.querySelector('[setting-color-picker-default]');
this.resetButton.addEventListener('click', event => {
this.colorInput.value = this.colorInput.dataset.current;
});
this.defaultButton.addEventListener('click', event => {
this.colorInput.value = this.colorInput.dataset.default;
});
setup() {
this.colorInput = this.$refs.input;
this.resetButton = this.$refs.resetButton;
this.defaultButton = this.$refs.defaultButton;
this.currentColor = this.$opts.current;
this.defaultColor = this.$opts.default;
this.resetButton.addEventListener('click', () => this.setValue(this.currentColor));
this.defaultButton.addEventListener('click', () => this.setValue(this.defaultColor));
}
}
export default SettingColorPicker;
setValue(value) {
this.colorInput.value = value;
this.colorInput.dispatchEvent(new Event('change'));
}
}