mirror of
https://github.com/flarum/core.git
synced 2025-10-13 07:54:25 +02:00
26 lines
755 B
JavaScript
26 lines
755 B
JavaScript
import SelectDropdown from 'flarum/components/SelectDropdown';
|
|
import Button from 'flarum/components/Button';
|
|
import saveConfig from 'flarum/utils/saveConfig';
|
|
|
|
export default class ConfigDropdown extends SelectDropdown {
|
|
static initProps(props) {
|
|
super.initProps(props);
|
|
|
|
props.className = 'ConfigDropdown';
|
|
props.buttonClassName = 'Button Button--text';
|
|
props.caretIcon = 'caret-down';
|
|
props.defaultLabel = 'Custom';
|
|
|
|
props.children = props.options.map(({value, label}) => {
|
|
const active = app.config[props.key] === value;
|
|
|
|
return Button.component({
|
|
children: label,
|
|
icon: active ? 'check' : true,
|
|
onclick: saveConfig.bind(this, {[props.key]: value}),
|
|
active
|
|
});
|
|
});
|
|
}
|
|
}
|