-
Notifications
You must be signed in to change notification settings - Fork 10
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
Changes from 6 commits
a27ed15
4075ae4
ec7d81b
54fc384
b3eb9c6
d2040a1
9f802bf
eddcc45
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,19 +31,32 @@ interface MarkdownPopoverProps { | |
open: boolean; | ||
onClose?: () => void; | ||
markdownText?: string; | ||
applicationTheme?: string; | ||
} | ||
|
||
export default function MarkdownPopover({ | ||
anchorEl, | ||
markdownText, | ||
open, | ||
onClose, | ||
applicationTheme, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use hook. |
||
}: MarkdownPopoverProps) { | ||
if (!markdownText) { | ||
return null; | ||
} | ||
|
||
const components = { | ||
a: (props: Record<string, unknown>) => { | ||
const { node: _, ...rest } = props; | ||
return ( | ||
<a | ||
{...rest} | ||
style={{ | ||
color: applicationTheme ? "#90caf9" : "#1e90ff", | ||
}} | ||
/> | ||
); | ||
}, | ||
code: (props: Record<string, unknown>) => { | ||
const { node: _, ...rest } = props; | ||
return <code {...rest} style={{ color: "green" }} />; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -42,6 +42,8 @@ import { | |
LocateMode, | ||
TimeSeriesChartType, | ||
TimeAnimationInterval, | ||
APPLICATION_THEMES, | ||
ApplicationThemes, | ||
Comment on lines
+45
to
+46
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why two of them? |
||
} from "@/states/controlState"; | ||
import { GEOGRAPHIC_CRS, WEB_MERCATOR_CRS } from "@/model/proj"; | ||
import { | ||
|
@@ -238,6 +240,13 @@ const SettingsDialog: React.FC<SettingsDialogProps> = ({ | |
openDialog("userOverlays"); | ||
}; | ||
|
||
function handleApplicationThemeChange( | ||
event: React.ChangeEvent<HTMLInputElement | HTMLTextAreaElement>, | ||
) { | ||
updateSettings({ | ||
applicationTheme: event.target.value as ApplicationThemes, | ||
}); | ||
} | ||
const overlayLayer = findLayer(overlayLayers, settings.selectedOverlayId); | ||
const overlayLabel = getLayerTitle(overlayLayer); | ||
|
||
|
@@ -279,8 +288,25 @@ const SettingsDialog: React.FC<SettingsDialogProps> = ({ | |
))} | ||
</TextField> | ||
</SettingsSubPanel> | ||
<SettingsSubPanel | ||
label={i18n.get("Change application theme")} | ||
> | ||
<TextField | ||
variant="standard" | ||
select | ||
sx={styles.textField} | ||
value={settings.applicationTheme} | ||
onChange={handleApplicationThemeChange} | ||
margin="normal" | ||
> | ||
{APPLICATION_THEMES.map(([value, label]) => ( | ||
<MenuItem key={value} value={value}> | ||
{i18n.get(label)} | ||
</MenuItem> | ||
))} | ||
</TextField> | ||
</SettingsSubPanel> | ||
</SettingsPanel> | ||
|
||
<SettingsPanel title={i18n.get("Time-Series")}> | ||
<SettingsSubPanel | ||
label={i18n.get("Show chart after adding a place")} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -61,6 +61,7 @@ interface UserVariablesDialogProps { | |
) => void; | ||
expressionCapabilities: ExpressionCapabilities | null; | ||
serverUrl: string; | ||
applicationTheme: string; | ||
} | ||
|
||
export default function UserVariablesDialog({ | ||
|
@@ -73,6 +74,7 @@ export default function UserVariablesDialog({ | |
updateDatasetUserVariables, | ||
expressionCapabilities, | ||
serverUrl, | ||
applicationTheme, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use context hook? |
||
}: UserVariablesDialogProps) { | ||
const [localUserVariables, setLocalUserVariables] = | ||
useState<UserVariable[]>(userVariables); | ||
|
@@ -139,6 +141,7 @@ export default function UserVariablesDialog({ | |
<HelpButton | ||
size="medium" | ||
helpUrl={i18n.get("docs/user-variables.en.md")} | ||
applicationTheme={applicationTheme} | ||
/> | ||
</Box> | ||
<Box> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -45,6 +45,7 @@ const mapStateToProps = (state: AppState) => { | |
userVariables: selectedUserVariablesSelector(state), | ||
expressionCapabilities: expressionCapabilitiesSelector(state), | ||
serverUrl: selectedServerSelector(state).url, | ||
applicationTheme: state.controlState.applicationTheme, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
}; | ||
}; | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -79,7 +79,7 @@ export interface Branding { | |
windowTitle: string; | ||
windowIcon: string | null; | ||
compact: boolean; | ||
themeName: "dark" | "light"; | ||
themeName: "light"; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. A type with one choice? Why does this make sense? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Will fix that. |
||
primaryColor: PaletteColorOptions; | ||
secondaryColor: PaletteColorOptions; | ||
headerBackgroundColor?: string; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use hook.