DEV: Add before / after header-buttons plugin outlets (#25887)

This commit is contained in:
Isaac Janzen 2024-02-26 12:56:21 -07:00 committed by GitHub
parent e440996aca
commit 8805a34001
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 38 additions and 10 deletions

View File

@ -17,6 +17,7 @@ import HamburgerDropdownWrapper from "./glimmer-header/hamburger-dropdown-wrappe
import Icons from "./glimmer-header/icons";
import SearchMenuWrapper from "./glimmer-header/search-menu-wrapper";
import UserMenuWrapper from "./glimmer-header/user-menu-wrapper";
import PluginOutlet from "./plugin-outlet";
const SEARCH_BUTTON_ID = "search-button";
@ -177,13 +178,21 @@ export default class GlimmerHeader extends Component {
@toggleHamburger={{this.toggleHamburger}}
@showSidebar={{@showSidebar}}
>
{{#unless this.currentUser}}
<AuthButtons
@showCreateAccount={{@showCreateAccount}}
@showLogin={{@showLogin}}
@canSignUp={{@canSignUp}}
/>
{{/unless}}
<span class="header-buttons">
<PluginOutlet @name="before-header-buttons" />
{{#unless this.currentUser}}
<AuthButtons
@showCreateAccount={{@showCreateAccount}}
@showLogin={{@showLogin}}
@canSignUp={{@canSignUp}}
/>
{{/unless}}
<PluginOutlet @name="after-header-buttons" />
</span>
{{#if
(not (and this.siteSettings.login_required (not this.currentUser)))
}}

View File

@ -8,7 +8,7 @@ export default class AuthButtons extends Component {
@service header;
<template>
<span class="header-buttons">
<span class="auth-buttons">
{{#if (and @canSignUp (not this.header.topic))}}
<DButton
class="btn-primary btn-small sign-up-button"

View File

@ -300,7 +300,7 @@ createWidget("header-icons", {
});
createWidget("header-buttons", {
tagName: "span.header-buttons",
tagName: "span.auth-buttons",
html(attrs) {
if (this.currentUser) {
@ -535,7 +535,22 @@ export default createWidget("header", {
return headerIcons;
}
const panels = [this.attach("header-buttons", attrs), headerIcons];
const panels = [
h("span.header-buttons", [
new RenderGlimmer(
this,
"span.before-header-buttons",
hbs`<PluginOutlet @name="before-header-buttons"/>`
),
this.attach("header-buttons", attrs),
new RenderGlimmer(
this,
"span.after-header-buttons",
hbs`<PluginOutlet @name="after-header-buttons"/>`
),
]),
headerIcons,
];
if (this.search.visible) {
this.search.inTopicContext = this.search.inTopicContext && inTopicRoute;

View File

@ -106,6 +106,10 @@
align-items: center;
margin-top: 0.2em;
white-space: nowrap;
.auth-buttons {
display: flex;
}
}
.login-button,