From 8e687fd70f69e2cecc7d7548008f97fa6d06359b Mon Sep 17 00:00:00 2001 From: awesomerobot Date: Wed, 11 Dec 2024 14:26:55 -0500 Subject: [PATCH] DEV: Refactor for readability and add tests for logo display logic --- .../components/brand-header-contents.gjs | 64 ++++++++----------- spec/system/viewing_brand_header_spec.rb | 18 ++++++ 2 files changed, 44 insertions(+), 38 deletions(-) diff --git a/javascripts/discourse/components/brand-header-contents.gjs b/javascripts/discourse/components/brand-header-contents.gjs index 86591bb..9a574af 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.isMobileView || 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 || "" }; }