mirror of
https://github.com/hsjobeki/noogle.git
synced 2024-12-25 15:04:30 +03:00
Merge pull request #403 from nix-community/johannes
Website/theme: dark mode by default
This commit is contained in:
commit
6e910a5040
@ -1,5 +1,5 @@
|
|||||||
"use client";
|
"use client";
|
||||||
import { CssBaseline, useMediaQuery } from "@mui/material";
|
import { CssBaseline } from "@mui/material";
|
||||||
import { cssThemeOptions } from "@/styles/theme";
|
import { cssThemeOptions } from "@/styles/theme";
|
||||||
import { ReactNode, useEffect, useState } from "react";
|
import { ReactNode, useEffect, useState } from "react";
|
||||||
import { Toaster } from "react-hot-toast";
|
import { Toaster } from "react-hot-toast";
|
||||||
@ -13,19 +13,19 @@ import {
|
|||||||
const theme = extendTheme(cssThemeOptions);
|
const theme = extendTheme(cssThemeOptions);
|
||||||
|
|
||||||
const ModeTracker = () => {
|
const ModeTracker = () => {
|
||||||
const userPrefersDarkmode = useMediaQuery("(prefers-color-scheme: dark)");
|
|
||||||
const { setMode } = useColorScheme();
|
const { setMode } = useColorScheme();
|
||||||
|
|
||||||
const [mounted, setMounted] = useState(false);
|
const [mounted, setMounted] = useState(false);
|
||||||
|
|
||||||
useEffect(
|
useEffect(
|
||||||
() => {
|
() => {
|
||||||
setMounted(true);
|
setMounted(true);
|
||||||
|
const persistedMode = localStorage.getItem("mui-mode");
|
||||||
setMode(userPrefersDarkmode ? "dark" : "light");
|
if (!persistedMode) {
|
||||||
|
setMode("dark");
|
||||||
|
}
|
||||||
},
|
},
|
||||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
[userPrefersDarkmode]
|
[]
|
||||||
);
|
);
|
||||||
|
|
||||||
if (!mounted) {
|
if (!mounted) {
|
||||||
|
@ -5,6 +5,7 @@ import { ReactNode, Suspense } from "react";
|
|||||||
import { SocialIcons } from "./layout";
|
import { SocialIcons } from "./layout";
|
||||||
import localFont from "next/font/local";
|
import localFont from "next/font/local";
|
||||||
import { styled } from "@mui/material/styles";
|
import { styled } from "@mui/material/styles";
|
||||||
|
import { ThemeSwitch } from "./themeSwitch";
|
||||||
|
|
||||||
const HeaderLink = styled(Link)(({ theme }) => ({
|
const HeaderLink = styled(Link)(({ theme }) => ({
|
||||||
color: theme.palette.primary.contrastText + "!important",
|
color: theme.palette.primary.contrastText + "!important",
|
||||||
@ -64,17 +65,6 @@ export const Header = (props: HeaderProps) => {
|
|||||||
{"Noogλe"}
|
{"Noogλe"}
|
||||||
</Button>
|
</Button>
|
||||||
</Box>
|
</Box>
|
||||||
{/* <Box
|
|
||||||
sx={{
|
|
||||||
justifySelf: "start",
|
|
||||||
display: { xs: "block", md: "none" },
|
|
||||||
color: "primary.contrastText",
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<IconButton color="inherit" aria-label="Home">
|
|
||||||
<Home />
|
|
||||||
</IconButton>
|
|
||||||
</Box> */}
|
|
||||||
{search && (
|
{search && (
|
||||||
<Box
|
<Box
|
||||||
sx={{
|
sx={{
|
||||||
@ -104,6 +94,7 @@ export const Header = (props: HeaderProps) => {
|
|||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<SocialIcons />
|
<SocialIcons />
|
||||||
|
<ThemeSwitch />
|
||||||
</Box>
|
</Box>
|
||||||
</Box>
|
</Box>
|
||||||
|
|
||||||
|
@ -23,7 +23,12 @@ export const SocialIcons = () => {
|
|||||||
sx={{ color: "inherit" }}
|
sx={{ color: "inherit" }}
|
||||||
>
|
>
|
||||||
<Tooltip title="Github">
|
<Tooltip title="Github">
|
||||||
<IconButton color="inherit" aria-label="nixos github">
|
<IconButton
|
||||||
|
sx={{
|
||||||
|
color: "#fff",
|
||||||
|
}}
|
||||||
|
aria-label="nixos github"
|
||||||
|
>
|
||||||
<GitHubIcon />
|
<GitHubIcon />
|
||||||
</IconButton>
|
</IconButton>
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
|
Loading…
Reference in New Issue
Block a user