Skip to content

Commit

Permalink
[Task] #61, mobile Theme Swticher placed on top right
Browse files Browse the repository at this point in the history
  • Loading branch information
Type-Style committed May 16, 2024
1 parent e8bc18c commit 3316aa4
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/client/components/ModeSwitcher.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import React from 'react';
import { useColorScheme } from '@mui/material/styles';
import { Button, useMediaQuery } from '@mui/material';
import { LightMode, Nightlight } from '@mui/icons-material';
import * as css from "../css/modeSwticher.module.css";

function ModeSwitcher() {
const { mode, setMode } = useColorScheme();
Expand All @@ -13,7 +14,8 @@ function ModeSwitcher() {

return (
<Button
variant='contained' size='large'
className={css.modeSwitcher}
variant='outlined' size='large'
startIcon={mode === 'dark' ? <Nightlight/> : <LightMode/>}
onClick={() => {
if (mode === 'light') {
Expand Down
19 changes: 19 additions & 0 deletions src/client/css/modeSwticher.module.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
.modeSwitcher[class] {
position: fixed;
inset: 1rem 1rem auto auto;

color: var(--text);
border-color: currentColor;

&:hover {
background-color: color-mix(in oklch, var(--neutral) 20%, transparent);
border-color: currentColor;
}

[data-mui-color-scheme="dark"] & {
color: var(--main);
&:hover {
background-color: color-mix(in oklch, white 10%, transparent);
}
}
}

0 comments on commit 3316aa4

Please sign in to comment.