1
0
mirror of https://github.com/flarum/core.git synced 2025-08-08 09:26:34 +02:00

update: admin/components/SettingDropdown

This commit is contained in:
Alexander Skvortsov
2020-08-10 19:56:08 -04:00
committed by Franz Liedke
parent 911f1fd5c9
commit f611a44a08

View File

@@ -3,23 +3,29 @@ import Button from '../../common/components/Button';
import saveSettings from '../utils/saveSettings';
export default class SettingDropdown extends SelectDropdown {
static initProps(props) {
super.initProps(props);
initAttrs(attrs) {
super.initAttrs(attrs);
props.className = 'SettingDropdown';
props.buttonClassName = 'Button Button--text';
props.caretIcon = 'fas fa-caret-down';
props.defaultLabel = 'Custom';
attrs.className = 'SettingDropdown';
attrs.buttonClassName = 'Button Button--text';
attrs.caretIcon = 'fas fa-caret-down';
attrs.defaultLabel = 'Custom';
}
props.children = props.options.map(({ value, label }) => {
const active = app.data.settings[props.key] === value;
view(vnode) {
vnode.children = this.attrs.options.map(({ value, label }) => {
const active = app.data.settings[this.attrs.key] === value;
return Button.component({
children: label,
icon: active ? 'fas fa-check' : true,
onclick: saveSettings.bind(this, { [props.key]: value }),
active,
});
return Button.component(
{
icon: active ? 'fas fa-check' : true,
onclick: saveSettings.bind(this, { [this.attrs.key]: value }),
active,
},
label
);
});
return super.view(vnode);
}
}