Skip to content

Commit 081710a

Browse files
authored
Adds feature flag to toggle theme by double clicking logo (#252)
1 parent 93da725 commit 081710a

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

renderer/layouts/MainLayout.tsx

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import {
55
GridItem,
66
Heading,
77
HStack,
8+
useColorMode,
89
VStack,
910
} from "@chakra-ui/react";
1011
import { useRouter } from "next/router";
@@ -17,6 +18,7 @@ import { BackButton } from "@/components/BackButton/BackButton";
1718
import { StatusIndicator } from "@/components/StatusIndicator/StatusIndicator";
1819
import { TestnetBanner } from "@/components/TestnetBanner/TestnetBanner";
1920
import { useFeatureFlags } from "@/providers/FeatureFlagsProvider";
21+
import { trpcReact } from "@/providers/TRPCProvider";
2022
import { ChakraLink } from "@/ui/ChakraLink/ChakraLink";
2123
import { COLORS } from "@/ui/colors";
2224
import { AddressBook } from "@/ui/SVGs/AddressBook";
@@ -111,12 +113,19 @@ function ResponsiveLogo() {
111113
function Sidebar() {
112114
const router = useRouter();
113115
const { formatMessage } = useIntl();
114-
116+
const { colorMode } = useColorMode();
115117
const { flags } = useFeatureFlags();
116-
118+
const { mutate: setUserSettings } = trpcReact.setUserSettings.useMutation();
117119
return (
118120
<Flex flexDirection="column" alignItems="stretch" w="100%">
119121
<Box
122+
onDoubleClick={() => {
123+
if (flags.themeToggle.enabled) {
124+
colorMode === "dark"
125+
? setUserSettings({ theme: "light" })
126+
: setUserSettings({ theme: "dark" });
127+
}
128+
}}
120129
pl={4}
121130
mb={10}
122131
color={flags.demoFlag.enabled ? "#2C72FF" : undefined}

renderer/providers/FeatureFlagsProvider.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,12 @@ const FLAGS_DEFINITION = [
2727
"Turning this flag on will enable importing Ledger accounts and signing transactions with your Ledger device.",
2828
key: "ledgerSupport",
2929
},
30+
{
31+
name: "Global Theme Toggle",
32+
description:
33+
"Turning this flag on will allow double clicking the logo to change the theme",
34+
key: "themeToggle",
35+
},
3036
] as const;
3137

3238
type FlagsDefinition = Writable<(typeof FLAGS_DEFINITION)[number]>;

0 commit comments

Comments
 (0)