Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(dark-light-mode): It adds Dark and Light mode for Brand Logo #59

Merged
merged 8 commits into from
Nov 15, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 14 additions & 6 deletions javascripts/discourse/components/brand-header-contents.gjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import Component from "@glimmer/component";
import { service } from "@ember/service";
import LightDarkImg from "discourse/components/light-dark-img";
import dIcon from "discourse-common/helpers/d-icon";

export default class BrandHeaderContents extends Component {
Expand All @@ -14,10 +15,13 @@ export default class BrandHeaderContents extends Component {
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 {
awesomerobot marked this conversation as resolved.
Show resolved Hide resolved
url: showMobileLogo ? mobileLogoUrl : logoUrl,
mobileUrl: showMobileLogo ? mobileLogoUrl : null,
lightUrl: logoUrl,
darkUrl: logoDarkUrl || logoUrl,
title,
};
}
Expand All @@ -33,17 +37,21 @@ export default class BrandHeaderContents extends Component {
<template>
<div class="title">
<a href={{settings.website_url}}>
{{#if this.brandLogo.url}}
{{#if this.brandLogo.mobileUrl}}
<img
id="brand-logo"
class="logo-big"
src={{this.brandLogo.url}}
src={{this.brandLogo.mobileUrl}}
title={{this.brandLogo.title}}
/>
{{else}}
<h2 id="#brand-text-logo" class="text-logo">
{{settings.brand_name}}
</h2>
<LightDarkImg
id="brand-logo"
class="logo-big"
@lightImg={{this.brandLogo.lightUrl}}
awesomerobot marked this conversation as resolved.
Show resolved Hide resolved
@darkImg={{this.brandLogo.darkUrl}}
title={{this.brandLogo.title}}
/>
{{/if}}
</a>
</div>
Expand Down
2 changes: 2 additions & 0 deletions settings.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ website_url:
default: ""
logo_url:
default: ""
logo_dark_url:
default: ""
mobile_logo_url:
default: ""

Expand Down