Remove old macaw theme key (#3251)
* Remove old macaw theme key * Handle cases when mixed values are enabled * Handle cases when mixed values are enabled * Handle cases when mixed values are enabled
This commit is contained in:
parent
5b7ad12ef0
commit
f5c4a5ad49
2 changed files with 19 additions and 4 deletions
|
@ -1,5 +1,4 @@
|
||||||
import { useUser } from "@dashboard/auth";
|
import { useUser } from "@dashboard/auth";
|
||||||
import { isDarkTheme } from "@dashboard/misc";
|
|
||||||
import { staffMemberDetailsUrl } from "@dashboard/staff/urls";
|
import { staffMemberDetailsUrl } from "@dashboard/staff/urls";
|
||||||
import { useTheme } from "@dashboard/theme";
|
import { useTheme } from "@dashboard/theme";
|
||||||
import { useTheme as useLegacyTheme } from "@saleor/macaw-ui";
|
import { useTheme as useLegacyTheme } from "@saleor/macaw-ui";
|
||||||
|
@ -21,11 +20,10 @@ import { ThemeSwitcher } from "./ThemeSwitcher";
|
||||||
export const UserControls = () => {
|
export const UserControls = () => {
|
||||||
const { user, logout } = useUser();
|
const { user, logout } = useUser();
|
||||||
const { theme, setTheme } = useTheme();
|
const { theme, setTheme } = useTheme();
|
||||||
const { themeType: legacyThemeType, setTheme: setLegacyTheme } =
|
const { setTheme: setLegacyTheme } = useLegacyTheme();
|
||||||
useLegacyTheme();
|
|
||||||
|
|
||||||
const handleClick = () => {
|
const handleClick = () => {
|
||||||
setLegacyTheme(isDarkTheme(legacyThemeType) ? "light" : "dark");
|
setLegacyTheme(theme === "defaultLight" ? "dark" : "light");
|
||||||
setTheme(theme === "defaultLight" ? "defaultDark" : "defaultLight");
|
setTheme(theme === "defaultLight" ? "defaultDark" : "defaultLight");
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -84,6 +84,23 @@ if (process.env.GTM_ID) {
|
||||||
|
|
||||||
errorTracker.init();
|
errorTracker.init();
|
||||||
|
|
||||||
|
/*
|
||||||
|
Handle legacy theming toggle. Since we use new and old macaw,
|
||||||
|
we need to handle both theme swticher for a while.
|
||||||
|
*/
|
||||||
|
const handleLegacyTheming = () => {
|
||||||
|
const activeTheme = localStorage.getItem("activeMacawUITheme");
|
||||||
|
|
||||||
|
if (activeTheme === "defaultDark") {
|
||||||
|
localStorage.setItem("macaw-ui-theme", "dark");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
localStorage.setItem("macaw-ui-theme", "light");
|
||||||
|
};
|
||||||
|
|
||||||
|
handleLegacyTheming();
|
||||||
|
|
||||||
const App: React.FC = () => (
|
const App: React.FC = () => (
|
||||||
<SaleorProvider client={saleorClient}>
|
<SaleorProvider client={saleorClient}>
|
||||||
<ApolloProvider client={apolloClient}>
|
<ApolloProvider client={apolloClient}>
|
||||||
|
|
Loading…
Reference in a new issue