Skip to content

Commit 7e463ba

Browse files
FEATURE: adds Dark and Light mode for Brand Logo (#59)
Co-authored-by: Kris <[email protected]>
1 parent f204e13 commit 7e463ba

File tree

3 files changed

+21
-6
lines changed

3 files changed

+21
-6
lines changed

javascripts/discourse/components/brand-header-contents.gjs

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import Component from "@glimmer/component";
22
import { service } from "@ember/service";
3+
import LightDarkImg from "discourse/components/light-dark-img";
34
import dIcon from "discourse-common/helpers/d-icon";
45

56
export default class BrandHeaderContents extends Component {
@@ -14,10 +15,17 @@ export default class BrandHeaderContents extends Component {
1415
const mobileLogoUrl = settings.mobile_logo_url || "";
1516
const showMobileLogo = mobileView && mobileLogoUrl.length > 0;
1617
const logoUrl = settings.logo_url || "";
18+
const logoDarkUrl = settings.logo_dark_url || "";
1719
const title = settings.brand_name;
1820

1921
return {
20-
url: showMobileLogo ? mobileLogoUrl : logoUrl,
22+
mobileUrl: showMobileLogo ? mobileLogoUrl : null,
23+
lightImg: {
24+
url: logoUrl,
25+
},
26+
darkImg: {
27+
url: logoDarkUrl,
28+
},
2129
title,
2230
};
2331
}
@@ -33,17 +41,21 @@ export default class BrandHeaderContents extends Component {
3341
<template>
3442
<div class="title">
3543
<a href={{settings.website_url}}>
36-
{{#if this.brandLogo.url}}
44+
{{#if this.brandLogo.mobileUrl}}
3745
<img
3846
id="brand-logo"
3947
class="logo-big"
40-
src={{this.brandLogo.url}}
48+
src={{this.brandLogo.mobileUrl}}
4149
title={{this.brandLogo.title}}
4250
/>
4351
{{else}}
44-
<h2 id="#brand-text-logo" class="text-logo">
45-
{{settings.brand_name}}
46-
</h2>
52+
<LightDarkImg
53+
id="brand-logo"
54+
class="logo-big"
55+
@lightImg={{this.brandLogo.lightImg}}
56+
@darkImg={{this.brandLogo.darkImg}}
57+
title={{this.brandLogo.title}}
58+
/>
4759
{{/if}}
4860
</a>
4961
</div>

settings.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ website_url:
44
default: ""
55
logo_url:
66
default: ""
7+
logo_dark_url:
8+
default: ""
79
mobile_logo_url:
810
default: ""
911

spec/system/viewing_brand_header_spec.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949

5050
expect(page).to have_selector(
5151
'img#brand-logo[title="some name"][src="http://some.url.com/logo.png"]',
52+
visible: :all,
5253
)
5354

5455
expect(page).to have_link("First Link", href: "http://some.url.com/first", target: "_blank")

0 commit comments

Comments
 (0)