This repository was archived by the owner on Feb 7, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 22
FIX: Render the correct logo for the active scheme when logo is minimized #57
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
29 changes: 29 additions & 0 deletions
29
javascripts/discourse/connectors/home-logo-contents__after/minimized-hook.gjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| import Component from "@glimmer/component"; | ||
| import { action } from "@ember/object"; | ||
| import didUpdate from "@ember/render-modifiers/modifiers/did-update"; | ||
| import { service } from "@ember/service"; | ||
| import { | ||
| changeHomeLogo, | ||
| COLOR_SCHEME_OVERRIDE_KEY, | ||
| } from "../../lib/color-scheme-override"; | ||
|
|
||
| export default class MinimizedHook extends Component { | ||
| @service keyValueStore; | ||
|
|
||
| @action | ||
| onMinimizedChange() { | ||
| const storedOverride = this.keyValueStore.getItem( | ||
| COLOR_SCHEME_OVERRIDE_KEY | ||
| ); | ||
| if (storedOverride) { | ||
| changeHomeLogo(storedOverride); | ||
| } | ||
| } | ||
|
|
||
| <template> | ||
| <span | ||
| class="hidden color-toggler-minimized-hook" | ||
| {{didUpdate this.onMinimizedChange @outletArgs.minimized}} | ||
| /> | ||
| </template> | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1,2 @@ | ||
| en: | ||
| toggle_button_title: Toggle color scheme | ||
| toggle_button_title: Toggle color palette |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,60 @@ | ||
| # frozen_string_literal: true | ||
|
|
||
| RSpec.describe "", system: true do | ||
| fab!(:topic) { Fabricate(:post).topic } | ||
| fab!(:user) | ||
| fab!(:post) { Fabricate(:post, topic:, raw: <<~POST * 20) } | ||
| Very lengthy post with lots of height for testing logo change when scrolling | ||
|
|
||
| Here's another paragraph to make the post take very large vertical space\n | ||
| POST | ||
|
|
||
| fab!(:dark_mode_image) { Fabricate(:image_upload, color: "white", width: 400, height: 120) } | ||
| fab!(:light_mode_image) { Fabricate(:image_upload, color: "black", width: 400, height: 120) } | ||
|
|
||
| fab!(:small_dark_mode_image) { Fabricate(:image_upload, color: "white", width: 120, height: 120) } | ||
| fab!(:small_light_mode_image) do | ||
| Fabricate(:image_upload, color: "black", width: 120, height: 120) | ||
| end | ||
|
|
||
| let!(:theme_component) { upload_theme_component } | ||
|
|
||
| let(:topic_page) { PageObjects::Pages::Topic.new } | ||
|
|
||
| before do | ||
| SiteSetting.logo = light_mode_image | ||
| SiteSetting.logo_small = small_light_mode_image | ||
| SiteSetting.logo_dark = dark_mode_image | ||
| SiteSetting.logo_small_dark = small_dark_mode_image | ||
| sign_in(user) | ||
| end | ||
|
|
||
| it "applies the correct `media` attribute on the source element when the logo is minimized upon scrolling" do | ||
| topic_page.visit_topic(topic) | ||
|
|
||
| dark_logo_source = | ||
| find( | ||
| ".title picture source[media=\"(prefers-color-scheme: dark)\"][srcset*=\"#{dark_mode_image.url}\"]", | ||
| visible: false, | ||
| ) | ||
| expect(dark_logo_source).to be_present | ||
|
|
||
| find(".color-scheme-toggler").click | ||
|
|
||
| dark_logo_source = | ||
| find( | ||
| ".title picture source[media=\"all\"][srcset*=\"#{dark_mode_image.url}\"]", | ||
| visible: false, | ||
| ) | ||
| expect(dark_logo_source).to be_present | ||
|
|
||
| page.scroll_to(find(".topic-footer-main-buttons .create")) | ||
|
|
||
| dark_logo_source = | ||
| find( | ||
| ".title picture source[media=\"all\"][srcset*=\"#{small_dark_mode_image.url}\"]", | ||
| visible: false, | ||
| ) | ||
| expect(dark_logo_source).to be_present | ||
| end | ||
| end |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.