From e60967397938ab1a562b74a1d7f702ea1b65d52f Mon Sep 17 00:00:00 2001 From: porink0424 Date: Wed, 14 Feb 2024 11:45:59 +0900 Subject: [PATCH] Follow-up of #806 --- optuna_dashboard/ts/components/Settings.tsx | 186 ++++++++++---------- optuna_dashboard/ts/state.ts | 6 +- 2 files changed, 99 insertions(+), 93 deletions(-) diff --git a/optuna_dashboard/ts/components/Settings.tsx b/optuna_dashboard/ts/components/Settings.tsx index 23ac647e..4e7a38dd 100644 --- a/optuna_dashboard/ts/components/Settings.tsx +++ b/optuna_dashboard/ts/components/Settings.tsx @@ -8,6 +8,7 @@ import { Stack, useTheme, IconButton, + Box, } from "@mui/material" import ClearIcon from "@mui/icons-material/Clear" import { useRecoilState } from "recoil" @@ -22,31 +23,113 @@ export const Settings = ({ handleClose }: SettingsProps) => { const [plotlyColorTheme, setPlotlyColorTheme] = useRecoilState( plotlyColorThemeState ) + const [plotBackendRendering, setPlotBackendRendering] = useRecoilState( + plotBackendRenderingState + ) const handleDarkModeColorChange = (event: SelectChangeEvent) => { const dark = event.target.value as PlotlyColorThemeDark - setPlotlyColorTheme((prev) => ({ ...prev, dark })) + setPlotlyColorTheme((cur) => ({ ...cur, dark })) } const handleLightModeColorChange = (event: SelectChangeEvent) => { const light = event.target.value as PlotlyColorThemeLight - setPlotlyColorTheme((prev) => ({ ...prev, light })) + setPlotlyColorTheme((cur) => ({ ...cur, light })) } - const [plotBackendRendering, setPlotBackendRendering] = - useRecoilState(plotBackendRenderingState) - const handleBackendRenderingChange = () => { - setPlotBackendRendering(!plotBackendRendering) + const togglePlotBackendRendering = () => { + setPlotBackendRendering((cur) => !cur) } return ( - + + + + Settings + + + + + Plotly Color Scales + + {theme.palette.mode === "dark" ? ( + <> + + Dark Mode + + + + Only the "Default" color scale is supported in dark mode + + + ) : ( + + Light Mode + + + )} + + + + + Use Plotlypy + + + + + { > - - - Settings - - - - - Plotly Color Scales - - {theme.palette.mode === "dark" ? ( - <> - - Dark Mode - - - - Only the "Default" color scale is supported in dark mode - - - ) : ( - - Light Mode - - - )} - - - Use Plotlypy - - - - + ) } diff --git a/optuna_dashboard/ts/state.ts b/optuna_dashboard/ts/state.ts index f8d51e64..5828985f 100644 --- a/optuna_dashboard/ts/state.ts +++ b/optuna_dashboard/ts/state.ts @@ -119,10 +119,8 @@ export const usePlotlyColorTheme = (mode: string): Partial => { } export const useBackendRender = (): boolean => { - const plotBackendRendering = useRecoilValue( - plotBackendRenderingState - ) - const plotlypyIsAvailable = useRecoilValue(plotlypyIsAvailableState) + const plotBackendRendering = useRecoilValue(plotBackendRenderingState) + const plotlypyIsAvailable = useRecoilValue(plotlypyIsAvailableState) if (plotBackendRendering) { if (plotlypyIsAvailable) {