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

Fixed changing background image based on light/dark theme #8744

Conversation

gastoner
Copy link
Contributor

@gastoner gastoner commented Sep 4, 2024

What does this PR do?

Fix changing background image based on light/dark theme

Screenshot / video of UI

Screen.Recording.2024-09-04.152535.mp4

What issues does this PR fix or reference?

Close #8526

How to test this PR?

Switch between light/dark theme and check if the recommendation banners reflect the change

@gastoner gastoner requested review from benoitf and a team as code owners September 4, 2024 13:37
@gastoner gastoner requested review from dgolovin, deboer-tim, axel7083 and feloy and removed request for a team September 4, 2024 13:37
Copy link
Contributor

@axel7083 axel7083 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Screencast.from.2024-09-04.16-34-14.mp4

When trying to very quickly change the theme, I am able to have some opposite result

@axel7083
Copy link
Contributor

axel7083 commented Sep 4, 2024

The ExtensionBanners.svelte fetch the isDark on mount, and it is not refresh as the component is reused.

onMount(async () => {
// Retrieve the current theme appearance colour of PD for the banners we will be showing
const appearanceUtil = new AppearanceUtil();
isDark = await appearanceUtil.isDarkMode();
});

@gastoner gastoner force-pushed the poor_contrast_on_supercharge_your_apps_with_banner_graphics_text_on_dashboard branch from 6db3c75 to 76a3160 Compare September 4, 2024 15:01
@gastoner
Copy link
Contributor Author

gastoner commented Sep 4, 2024

@axel7083 try it now!

@axel7083
Copy link
Contributor

axel7083 commented Sep 4, 2024

The ExtensionBanners.svelte fetch the isDark on mount, and it is not refresh as the component is reused.

onMount(async () => {
// Retrieve the current theme appearance colour of PD for the banners we will be showing
const appearanceUtil = new AppearanceUtil();
isDark = await appearanceUtil.isDarkMode();
});

We might need to either, get the isDark at every render (possible but not really performance wise) or trying to get an event listener for it :?

@gastoner
Copy link
Contributor Author

gastoner commented Sep 4, 2024

The ExtensionBanners.svelte fetch the isDark on mount, and it is not refresh as the component is reused.

onMount(async () => {
// Retrieve the current theme appearance colour of PD for the banners we will be showing
const appearanceUtil = new AppearanceUtil();
isDark = await appearanceUtil.isDarkMode();
});

We might need to either, get the isDark at every render (possible but not really performance wise) or trying to get an event listener for it :?

The listener would be probably good, now it should get the boolean value each time user enters the dashboard

@benoitf
Copy link
Collaborator

benoitf commented Sep 4, 2024

it looks like ApperanceUtil isDark or getTheme should be removed and it should be a state (v5) or store v4 being updated/refreshed when configuration is changing

@axel7083
Copy link
Contributor

axel7083 commented Sep 4, 2024

it looks like ApperanceUtil isDark or getTheme should be removed and it should be a state (v5) or store v4 being updated/refreshed when configuration is changing

The ApperanceUtil is doing some hacky stuff to determine the theme

async getTheme(): Promise<string> {
const themeName = await window.getConfigurationValue<string>(
AppearanceSettings.SectionName + '.' + AppearanceSettings.Appearance,
);
const systemTheme = window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light';
if (themeName === AppearanceSettings.SystemEnumValue) {
return systemTheme;
}
return themeName ?? systemTheme;
}

Looking at the api of MediaQueryList there is a addEventListener and removeEventListener which would allow the base system for a quick hack.

But since we are using a configuration value (light / dark / system), we might want to deprecate the AppearanceUtil and have a store as suggested by @benoitf

@gastoner
Copy link
Contributor Author

gastoner commented Sep 4, 2024

it looks like ApperanceUtil isDark or getTheme should be removed and it should be a state (v5) or store v4 being updated/refreshed when configuration is changing

Should I convert it to v5 then? I've done something like this 6db3c75

@feloy

This comment was marked as off-topic.

feloy

This comment was marked as off-topic.

@gastoner
Copy link
Contributor Author

@feloy This PR needs to be updated after will be #8759 closed, probably should convert it to draft for now

@feloy
Copy link
Contributor

feloy commented Sep 17, 2024

@feloy This PR needs to be updated after will be #8759 closed, probably should convert it to draft for now

sorry, my comment was for #8759

@gastoner gastoner force-pushed the poor_contrast_on_supercharge_your_apps_with_banner_graphics_text_on_dashboard branch from 76a3160 to 3339c8d Compare September 19, 2024 09:40
@gastoner gastoner requested a review from feloy September 19, 2024 09:40
@gastoner
Copy link
Contributor Author

There would be a need to improve system change detection (similar problem in MonacoEditor)

@gastoner gastoner force-pushed the poor_contrast_on_supercharge_your_apps_with_banner_graphics_text_on_dashboard branch from 3339c8d to 320efb2 Compare September 19, 2024 13:30
</script>

{#each $extensionBannerInfos as banner (banner.extensionId)}
<ExtensionBanner banner={banner} isDark={$isDark} />
<ExtensionBanner banner={banner} isDark={isDarkTheme} />
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As far as I understand svelte reactivity, it seems to me that the changes in this file are not necessary, we are just adding a layer of reactivity.
(and testing without these changes, it works the same)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see, thank you, I thought that I've forgot to use subscribe here

@gastoner gastoner requested a review from a team as a code owner September 20, 2024 05:26
@gastoner gastoner force-pushed the poor_contrast_on_supercharge_your_apps_with_banner_graphics_text_on_dashboard branch from 6d9acd0 to 68f1dd3 Compare September 20, 2024 05:30
@gastoner gastoner requested a review from feloy September 20, 2024 05:33
Copy link
Collaborator

@benoitf benoitf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice to see using also the new svelte5 syntax

@gastoner gastoner force-pushed the poor_contrast_on_supercharge_your_apps_with_banner_graphics_text_on_dashboard branch from 68f1dd3 to 09918d1 Compare September 20, 2024 08:14
@gastoner gastoner merged commit 50d0ec2 into containers:main Sep 20, 2024
15 checks passed
@podman-desktop-bot podman-desktop-bot added this to the 1.13.0 milestone Sep 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Poor contrast on Supercharge your apps with Red Hat banner graphic's text on Dashboard
5 participants