DEV: Add option to only show icons to header widget (#9935)

This commit is contained in:
Mark VanLandingham 2020-06-01 12:26:59 -05:00 committed by GitHub
parent 3106f85983
commit b6709f0dda
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 13 deletions

View File

@ -20,7 +20,10 @@ export default Component.extend({
this._removeClass();
let classes = [];
if (slug) classes.push(`category-${slug}`);
if (slug) {
classes.push("category");
classes.push(`category-${slug}`);
}
if (tags) tags.forEach(t => classes.push(`tag-${t}`));
if (classes.length > 0) $("body").addClass(classes.join(" "));
},
@ -32,7 +35,7 @@ export default Component.extend({
_removeClass() {
$("body").removeClass((_, css) =>
(css.match(/\b(?:category|tag)-\S+/g) || []).join(" ")
(css.match(/\b(?:category|tag)-\S+|( category )/g) || []).join(" ")
);
},

View File

@ -299,17 +299,20 @@ export default createWidget("header", {
html(attrs, state) {
let contents = () => {
const panels = [
this.attach("header-buttons", attrs),
this.attach("header-icons", {
hamburgerVisible: state.hamburgerVisible,
userVisible: state.userVisible,
searchVisible: state.searchVisible,
ringBackdrop: state.ringBackdrop,
flagCount: attrs.flagCount,
user: this.currentUser
})
];
const headerIcons = this.attach("header-icons", {
hamburgerVisible: state.hamburgerVisible,
userVisible: state.userVisible,
searchVisible: state.searchVisible,
ringBackdrop: state.ringBackdrop,
flagCount: attrs.flagCount,
user: this.currentUser
});
if (attrs.onlyIcons) {
return headerIcons;
}
const panels = [this.attach("header-buttons", attrs), headerIcons];
if (state.searchVisible) {
const contextType = this.searchContextType();