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

Viewer theme can be switched between dark or light theme #433

Merged
merged 8 commits into from
Nov 29, 2024

Conversation

ruchimotwaniBC
Copy link
Contributor

@ruchimotwaniBC ruchimotwaniBC commented Sep 25, 2024

Implemented the theme changing dropdown in Settings dialog.

The default theme of the application is taken from config.json and if not then default theme is according to users system.
image

Changes in MarkdownPopover are to support the link color for dark theme.

@ruchimotwaniBC ruchimotwaniBC requested review from forman and removed request for forman September 25, 2024 16:07
@ruchimotwaniBC ruchimotwaniBC changed the title Application theme can be switched to dark mode Application theme can be switched between dark or light theme Sep 25, 2024
@ruchimotwaniBC ruchimotwaniBC changed the title Application theme can be switched between dark or light theme Viewer theme can be switched between dark or light theme Sep 30, 2024
Copy link
Member

@forman forman left a comment

Choose a reason for hiding this comment

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

@ruchimotwaniBC , looks good, thanks!

Could you please change the implementation logic as follows:

  1. Change the control state's currentAppTheme type to string.
  2. If Config.instance.branding.themeName is set, initialize control state's currentAppTheme to its value.
  3. Only if Config.instance.branding.themeName is NOT set, allow for changing the theme in the Settings.

Copy link
Collaborator

@clarasb clarasb left a comment

Choose a reason for hiding this comment

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

Reviewed from a user-perspective:

The switch between themes works really well.
But it seems to have no effect on the apprerance of an editor used in the following features:

  1. Import Places
  2. Sidebar -> Metadata -> JSON Format

@ruchimotwaniBC
Copy link
Contributor Author

Reviewed from a user-perspective:

The switch between themes works really well. But it seems to have no effect on the apprerance of an editor used in the following features:

  1. Import Places
  2. Sidebar -> Metadata -> JSON Format

Ok I check. Thanks @clarasb

@@ -45,6 +45,7 @@ const mapStateToProps = (state: AppState) => {
userVariables: selectedUserVariablesSelector(state),
expressionCapabilities: expressionCapabilitiesSelector(state),
serverUrl: selectedServerSelector(state).url,
applicationTheme: state.controlState.applicationTheme,
Copy link
Member

Choose a reason for hiding this comment

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

The current theme should be available through the MUI theme context object. Please double-check the MUI docs on how to that (usually using the React ? useContext()` hook.

@@ -73,6 +74,7 @@ export default function UserVariablesDialog({
updateDatasetUserVariables,
expressionCapabilities,
serverUrl,
applicationTheme,
Copy link
Member

Choose a reason for hiding this comment

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

Use context hook?

}

export default function MarkdownPopover({
anchorEl,
markdownText,
open,
onClose,
applicationTheme,
Copy link
Member

Choose a reason for hiding this comment

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

Use hook.

@@ -32,9 +32,10 @@ import MarkdownPopover from "@/components/MarkdownPopover";
interface HelpButtonProps {
size?: "small" | "medium" | "large";
helpUrl?: string;
applicationTheme?: string;
Copy link
Member

Choose a reason for hiding this comment

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

Use hook.

@@ -79,7 +79,7 @@ export interface Branding {
windowTitle: string;
windowIcon: string | null;
compact: boolean;
themeName: "dark" | "light";
themeName: "light";
Copy link
Member

Choose a reason for hiding this comment

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

A type with one choice? Why does this make sense?
The branding should provide the initial theme.

Copy link
Member

Choose a reason for hiding this comment

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

Will fix that.

Copy link
Collaborator

@clarasb clarasb left a comment

Choose a reason for hiding this comment

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

The feature looks great!

(tested from a user-perspective)

Copy link
Member

@forman forman left a comment

Choose a reason for hiding this comment

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

Comment on lines +45 to +46
APPLICATION_THEMES,
ApplicationThemes,
Copy link
Member

Choose a reason for hiding this comment

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

Why two of them?

@@ -79,7 +79,7 @@ export interface Branding {
windowTitle: string;
windowIcon: string | null;
compact: boolean;
themeName: "dark" | "light";
themeName: "light";
Copy link
Member

Choose a reason for hiding this comment

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

Will fix that.

@@ -160,6 +166,7 @@ export interface ControlState {
exportPlacesAsCollection: boolean;
exportZipArchive: boolean;
exportFileName: string;
themeMode: string;
Copy link
Member

Choose a reason for hiding this comment

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

"light" | "dark" | "system" - I will fix that

@forman forman merged commit 081dc5d into main Nov 29, 2024
3 checks passed
@forman forman deleted the ruchi_xxx_change_theme branch November 29, 2024 13:55
@forman forman restored the ruchi_xxx_change_theme branch November 29, 2024 13:56
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.

3 participants