Skip to content

Commit

Permalink
fix: color mode conditional components
Browse files Browse the repository at this point in the history
  • Loading branch information
kamescg committed Aug 31, 2023
1 parent 9cc1904 commit b504c88
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 8 deletions.
6 changes: 3 additions & 3 deletions components/shared/is-dark-theme.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@

import { ReactNode } from "react"

import { useColorMode } from "@/lib/state/color-mode"
import { useTheme } from "next-themes"

interface IsDarkThemeProps {
children: ReactNode
}

export const IsDarkTheme = ({ children }: IsDarkThemeProps) => {
const [colorMode] = useColorMode()
const { theme } = useTheme()

if (colorMode !== "light") return <>{children}</>
if (theme !== "light") return <>{children}</>

return null
}
6 changes: 3 additions & 3 deletions components/shared/is-light-theme.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@

import { ReactNode } from "react"

import { useColorMode } from "@/lib/state/color-mode"
import { useTheme } from "next-themes"

interface IsLightThemeProps {
children: ReactNode
}

export const IsLightTheme = ({ children }: IsLightThemeProps) => {
const [colorMode] = useColorMode()
const { theme } = useTheme()

if (colorMode === "light") return <>{children}</>
if (theme === "light") return <>{children}</>

return null
}
1 change: 0 additions & 1 deletion components/shared/mode-toggle.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import {

export function ModeToggle() {
const { setTheme } = useTheme()

return (
<DropdownMenu>
<DropdownMenuTrigger asChild>
Expand Down
2 changes: 1 addition & 1 deletion styles/globals.css
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
}

.dark {
--background: 0 0% 3.9%;
--background: 0 0% 7.5%;
--foreground: 0 0% 98%;

--card: 0 0% 3.9%;
Expand Down

0 comments on commit b504c88

Please sign in to comment.