From 3402e1c8182fa2d5fed33c8bf4eaea131af4124e Mon Sep 17 00:00:00 2001 From: Kris Date: Thu, 12 Dec 2024 17:01:02 -0500 Subject: [PATCH] DEV: Refactor for readability and add tests for logo display logic (#65) Co-authored-by: Jarek Radosz --- .../components/brand-header-contents.gjs | 64 ++++++++----------- spec/system/viewing_brand_header_spec.rb | 27 ++++++++ 2 files changed, 53 insertions(+), 38 deletions(-) diff --git a/javascripts/discourse/components/brand-header-contents.gjs b/javascripts/discourse/components/brand-header-contents.gjs index 86591bb..1d466b0 100644 --- a/javascripts/discourse/components/brand-header-contents.gjs +++ b/javascripts/discourse/components/brand-header-contents.gjs @@ -7,66 +7,54 @@ export default class BrandHeaderContents extends Component { @service site; get shouldShow() { - return !this.site.mobileView || settings.show_bar_on_mobile; + return this.site.desktopView || settings.show_bar_on_mobile; } - get brandLogo() { - const mobileView = this.site.mobileView; - const mobileLogoUrl = settings.mobile_logo_url || ""; - const showMobileLogo = mobileView && mobileLogoUrl.length > 0; - const logoUrl = settings.logo_url || ""; - const logoDarkUrl = settings.logo_dark_url || ""; - const title = settings.brand_name; - - return { - mobileUrl: showMobileLogo ? mobileLogoUrl : null, - lightImg: { - url: logoUrl, - }, - darkImg: { - url: logoDarkUrl, - }, - title, - }; + get mobileLogoUrl() { + return this.site.mobileView ? settings.mobile_logo_url : null; } - get hasIcons() { - return settings.icons && settings.icons.length > 0; + get lightLogo() { + return { url: settings.logo_url || "" }; } - get hasLinks() { - return settings.links && settings.links.length > 0; + get darkLogo() { + return { url: settings.logo_dark_url || "" }; }