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

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

diff --git a/app/assets/javascripts/discourse/app/components/add-category-tag-classes.js b/app/assets/javascripts/discourse/app/components/add-category-tag-classes.js
index 50d93f3..54421ea 100644
--- a/app/assets/javascripts/discourse/app/components/add-category-tag-classes.js
+++ b/app/assets/javascripts/discourse/app/components/add-category-tag-classes.js
@@ -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(" ")
     );
   },
 
diff --git a/app/assets/javascripts/discourse/app/widgets/header.js b/app/assets/javascripts/discourse/app/widgets/header.js
index 8e27a15..2580fff 100644
--- a/app/assets/javascripts/discourse/app/widgets/header.js
+++ b/app/assets/javascripts/discourse/app/widgets/header.js
@@ -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();

GitHub sha: b6709f0d

2 Likes

This commit appears in #9935 which was approved by eviltrout. It was merged by markvanlan.