diff --git a/portal-ui/package.json b/portal-ui/package.json index cb73237a8..f7860a8c2 100644 --- a/portal-ui/package.json +++ b/portal-ui/package.json @@ -10,7 +10,7 @@ "local-storage-fallback": "^4.1.1", "lodash": "^4.17.21", "luxon": "^3.4.3", - "mds": "https://github.com/minio/mds.git#v0.12.1", + "mds": "https://github.com/minio/mds.git#v0.12.2", "react": "^18.1.0", "react-component-export-image": "^1.0.6", "react-copy-to-clipboard": "^5.0.2", diff --git a/portal-ui/src/StyleHandler.tsx b/portal-ui/src/StyleHandler.tsx index 5cf2fa4c2..90e0e84ae 100644 --- a/portal-ui/src/StyleHandler.tsx +++ b/portal-ui/src/StyleHandler.tsx @@ -31,6 +31,7 @@ const StyleHandler = ({ children }: IStyleHandler) => { const colorVariants = useSelector( (state: AppState) => state.system.overrideStyles, ); + const darkMode = useSelector((state: AppState) => state.system.darkMode); let thm = undefined; @@ -38,11 +39,12 @@ const StyleHandler = ({ children }: IStyleHandler) => { thm = generateOverrideTheme(colorVariants); } - // ThemeHandler is needed for MDS components theming. Eventually we will remove Theme Provider & use only mds themes. return ( - {children} + + {children} + ); }; diff --git a/portal-ui/src/screens/Console/Common/DarkModeActivator/DarkModeActivator.tsx b/portal-ui/src/screens/Console/Common/DarkModeActivator/DarkModeActivator.tsx new file mode 100644 index 000000000..2d4131c6d --- /dev/null +++ b/portal-ui/src/screens/Console/Common/DarkModeActivator/DarkModeActivator.tsx @@ -0,0 +1,48 @@ +// This file is part of MinIO Console Server +// Copyright (c) 2023 MinIO, Inc. +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + +import React from "react"; +import { Button, DarkModeIcon } from "mds"; +import TooltipWrapper from "../TooltipWrapper/TooltipWrapper"; +import { useSelector } from "react-redux"; +import { AppState, useAppDispatch } from "../../../../store"; +import { setDarkMode } from "../../../../systemSlice"; +import { storeDarkMode } from "../../../../utils/stylesUtils"; + +const DarkModeActivator = () => { + const dispatch = useAppDispatch(); + + const darkMode = useSelector((state: AppState) => state.system.darkMode); + + const darkModeActivator = () => { + const currentStatus = !!darkMode; + + dispatch(setDarkMode(!currentStatus)); + storeDarkMode(!currentStatus ? "on" : "off"); + }; + + return ( + +