discourse/app/assets/javascripts/select-kit/addon/components/dropdown-select-box/dropdown-select-box-header.js
David Taylor d1cc60c435
DEV: Convert select-kit components to native class syntax (#28489)
Changes made using the ember-native-class-codemod, plus some manual tweaks
2024-08-23 12:17:07 +01:00

30 lines
1.2 KiB
JavaScript

import { computed } from "@ember/object";
import { readOnly } from "@ember/object/computed";
import { classNameBindings, classNames } from "@ember-decorators/component";
import SingleSelectHeaderComponent from "select-kit/components/select-kit/single-select-header";
@classNames("dropdown-select-box-header")
@classNameBindings("btnClassName", "btnStyleClass", "btnCustomClasses")
export default class DropdownSelectBoxHeader extends SingleSelectHeaderComponent {
@readOnly("selectKit.options.showFullTitle") showFullTitle;
@readOnly("selectKit.options.customStyle") customStyle;
@readOnly("selectKit.options.btnCustomClasses") btnCustomClasses;
@readOnly("selectKit.options.caretUpIcon") caretUpIcon;
@readOnly("selectKit.options.caretDownIcon") caretDownIcon;
@computed("showFullTitle")
get btnClassName() {
return `btn ${this.showFullTitle ? "btn-icon-text" : "no-text btn-icon"}`;
}
@computed("customStyle")
get btnStyleClass() {
return `${this.customStyle ? "" : "btn-default"}`;
}
@computed("selectKit.isExpanded", "caretUpIcon", "caretDownIcon")
get caretIcon() {
return this.selectKit.isExpanded ? this.caretUpIcon : this.caretDownIcon;
}
}