From f846d2e8fdb1e4d9fe619e238d33e03bf512ac9c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9rgio=20Saquetim?= <1108771+megothss@users.noreply.github.com> Date: Mon, 10 Jun 2024 15:35:08 -0300 Subject: [PATCH] DEV: Extract the contents of the home logo to a component (#27157) This commit extracts the content of the `HomeLogo` to a standalone component. This enables us to utilize the `home-logo-contents` plugin outlet to render an alternative version of the logo using the new component to reuse the rendering logic, but using alternative properties. For example: ```js const logoSmallUrl = settings .theme_uploads["theme-alternative-logo-small"]; const logoUrl = settings.theme_uploads["theme-alternative-logo"]; const mobileLogoUrl = settings .theme_uploads["theme-alternative-logo"]; api.renderInOutlet("home-logo-contents", ); `` --- .../components/header/home-logo-contents.gjs | 37 ++++++++++++ .../app/components/header/home-logo.gjs | 57 ++++++++----------- 2 files changed, 60 insertions(+), 34 deletions(-) create mode 100644 app/assets/javascripts/discourse/app/components/header/home-logo-contents.gjs 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.gjs new file mode 100644 index 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 = ; + +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.gjs index 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 switching if (opts.dark) { @@ -101,42 +104,28 @@ export default class HomeLogo extends Component { - {{#if @minimized}} - {{#if this.logoSmallUrl}} - - {{else}} - {{icon "home"}} - {{/if}} - {{else if this.showMobileLogo}} - - {{else if this.logoUrl}} - - {{else}} -

- {{this.siteSettings.title}} -

- {{/if}} +