From c200238bdc241586bfe82b2d0fc1f600fec45b1f Mon Sep 17 00:00:00 2001 From: Mark VanLandingham Date: Wed, 3 Jun 2020 14:28:02 -0500 Subject: [PATCH] DEV: Reorder appending extra header icons (#9973) --- .../discourse/app/widgets/header.js | 43 ++++++++++++------- 1 file changed, 27 insertions(+), 16 deletions(-) diff --git a/app/assets/javascripts/discourse/app/widgets/header.js b/app/assets/javascripts/discourse/app/widgets/header.js index b6f2abe9b43..ca55984242d 100644 --- a/app/assets/javascripts/discourse/app/widgets/header.js +++ b/app/assets/javascripts/discourse/app/widgets/header.js @@ -21,9 +21,12 @@ export function addToHeaderIcons(icon) { const dropdown = { buildClasses(attrs) { + let classes = attrs.classNames || []; if (attrs.active) { - return "active"; + classes.push("active"); } + + return classes; }, click(e) { @@ -189,6 +192,26 @@ createWidget("header-icons", { return []; } + const icons = []; + + if (_extraHeaderIcons) { + _extraHeaderIcons.forEach(icon => { + icons.push(this.attach(icon)); + }); + } + + const search = this.attach("header-dropdown", { + title: "search.title", + icon: "search", + iconId: "search-button", + action: "toggleSearchMenu", + active: attrs.searchVisible, + href: getURL("/search"), + classNames: ["search-dropdown"] + }); + + icons.push(search); + const hamburger = this.attach("header-dropdown", { title: "hamburger_menu", icon: "bars", @@ -196,6 +219,8 @@ createWidget("header-icons", { active: attrs.hamburgerVisible, action: "toggleHamburger", href: "", + classNames: ["hamburger-dropdown"], + contents() { let { currentUser } = this; if (currentUser && currentUser.reviewable_count) { @@ -212,16 +237,8 @@ createWidget("header-icons", { } }); - const search = this.attach("header-dropdown", { - title: "search.title", - icon: "search", - iconId: "search-button", - action: "toggleSearchMenu", - active: attrs.searchVisible, - href: getURL("/search") - }); + icons.push(hamburger); - const icons = [search, hamburger]; if (attrs.user) { icons.push( this.attach("user-dropdown", { @@ -233,12 +250,6 @@ createWidget("header-icons", { ); } - if (_extraHeaderIcons) { - _extraHeaderIcons.forEach(icon => { - icons.push(this.attach(icon)); - }); - } - return icons; } });