Skip to content
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

Fix detecting dark theme leftovers #153

Merged
merged 1 commit into from
Sep 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useDarkMode } from "usehooks-ts";
import { useTheme } from "next-themes";
import { useSwitchChain } from "wagmi";
import { ArrowsRightLeftIcon } from "@heroicons/react/24/solid";
import { getNetworkColor } from "~~/hooks/scaffold-eth";
Expand All @@ -9,7 +9,8 @@ type NetworkOptionsProps = {
};

export const NetworkOptions = ({ hidden = false }: NetworkOptionsProps) => {
const { isDarkMode } = useDarkMode();
const { resolvedTheme } = useTheme();
const isDarkMode = resolvedTheme === "dark";
const { switchChain } = useSwitchChain();
const mainChainId = useAbiNinjaState(state => state.mainChainId);
const chains = useGlobalState(state => state.chains);
Expand Down
5 changes: 3 additions & 2 deletions packages/nextjs/hooks/scaffold-eth/useNetworkColor.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useTargetNetwork } from "./useTargetNetwork";
import { useDarkMode } from "usehooks-ts";
import { useTheme } from "next-themes";
import { ChainWithAttributes } from "~~/utils/scaffold-eth";

export const DEFAULT_NETWORK_COLOR: [string, string] = ["#666666", "#bbbbbb"];
Expand All @@ -13,7 +13,8 @@ export function getNetworkColor(network: ChainWithAttributes, isDarkMode: boolea
* Gets the color of the target network
*/
export const useNetworkColor = (network?: ChainWithAttributes) => {
const { isDarkMode } = useDarkMode();
const { resolvedTheme } = useTheme();
const isDarkMode = resolvedTheme === "dark";
const { targetNetwork } = useTargetNetwork();

return getNetworkColor(network || targetNetwork, isDarkMode);
Expand Down
Loading