A platform for community discussion. Free, open, simple.
DEV: Extract the contents of the home logo to a component (#27157)
Sérgio Saquetimf846d2e8fdb1
diff --git a/app/assets/javascripts/discourse/app/components/header/home-logo-contents.gjs b/app/assets/javascripts/discourse/app/components/header/home-logo-contents.gjsnew file mode 100644index 00000000000..d76f6b402d2--- /dev/null+++ b/app/assets/javascripts/discourse/app/components/header/home-logo-contents.gjs@@ -0,0 +1,37 @@+import icon from "discourse-common/helpers/d-icon";+import Logo from "./logo";++const HomeLogoContents = <template>+ {{#if @minimized}}+ {{#if @logoSmallUrl}}+ <Logo+ @key="logo-small"+ @url={{@logoSmallUrl}}+ @title={{@title}}+ @darkUrl={{@logoSmallUrlDark}}+ />+ {{else}}+ {{icon "home"}}+ {{/if}}+ {{else if @showMobileLogo}}+ <Logo+ @key="logo-mobile"+ @url={{@mobileLogoUrl}}+ @title={{@title}}+ @darkUrl={{@mobileLogoUrlDark}}+ />+ {{else if @logoUrl}}+ <Logo+ @key="logo-big"+ @url={{@logoUrl}}+ @title={{@title}}+ @darkUrl={{@logoUrlDark}}+ />+ {{else}}+ <h1 id="site-text-logo" class="text-logo">+ {{@title}}+ </h1>+ {{/if}}+</template>;++export default HomeLogoContents;diff --git a/app/assets/javascripts/discourse/app/components/header/home-logo.gjs b/app/assets/javascripts/discourse/app/components/header/home-logo.gjsindex 2f6b5ec5d91..37404fdb196 100644--- a/app/assets/javascripts/discourse/app/components/header/home-logo.gjs+++ b/app/assets/javascripts/discourse/app/components/header/home-logo.gjs@@ -7,9 +7,8 @@ import PluginOutlet from "discourse/components/plugin-outlet";import concatClass from "discourse/helpers/concat-class";import { wantsNewWindow } from "discourse/lib/intercept-click";import DiscourseURL from "discourse/lib/url";-import icon from "discourse-common/helpers/d-icon";import getURL from "discourse-common/lib/get-url";-import Logo from "./logo";+import HomeLogoContents from "./home-logo-contents";let hrefCallback;@@ -64,6 +63,10 @@ export default class HomeLogo extends Component {return this.logoResolver("mobile_logo", { dark: this.darkModeAvailable });}+ get title() {+ return this.siteSettings.title;+ }+logoResolver(name, opts = {}) {// get alternative logos for browser dark dark mode switchingif (opts.dark) {@@ -101,42 +104,28 @@ export default class HomeLogo extends Component {<PluginOutlet@name="home-logo-contents"@outletArgs={{hash- minimized=@minimized- logoUrl=this.logoUrllogoSmallUrl=this.logoSmallUrl+ logoSmallUrlDark=this.logoSmallUrlDark+ logoUrl=this.logoUrl+ logoUrlDark=this.logoUrlDark+ minimized=@minimized+ mobileLogoUrl=this.mobileLogoUrl+ mobileLogoUrlDark=this.mobileLogoUrlDarkshowMobileLogo=this.showMobileLogo+ title=this.title}}>- {{#if @minimized}}- {{#if this.logoSmallUrl}}- <Logo- @key="logo-small"- @url={{this.logoSmallUrl}}- @title={{this.siteSettings.title}}- @darkUrl={{this.logoSmallUrlDark}}- />- {{else}}- {{icon "home"}}- {{/if}}- {{else if this.showMobileLogo}}- <Logo- @key="logo-mobile"- @url={{this.mobileLogoUrl}}- @title={{this.siteSettings.title}}- @darkUrl={{this.mobileLogoUrlDark}}- />- {{else if this.logoUrl}}- <Logo- @key="logo-big"- @url={{this.logoUrl}}- @title={{this.siteSettings.title}}- @darkUrl={{this.logoUrlDark}}- />- {{else}}- <h1 id="site-text-logo" class="text-logo">- {{this.siteSettings.title}}- </h1>- {{/if}}+ <HomeLogoContents+ @logoSmallUrl={{this.logoSmallUrl}}+ @logoSmallUrlDark={{this.logoSmallUrlDark}}+ @logoUrl={{this.logoUrl}}+ @logoUrlDark={{this.logoUrlDark}}+ @minimized={{@minimized}}+ @mobileLogoUrl={{this.mobileLogoUrl}}+ @mobileLogoUrlDark={{this.mobileLogoUrlDark}}+ @showMobileLogo={{this.showMobileLogo}}+ @title={{this.title}}+ /></PluginOutlet></a></div>