forked from mui/material-ui
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3a1e93e
commit 85087cc
Showing
7 changed files
with
262 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
'use server'; | ||
import { cookies } from 'next/headers'; | ||
|
||
// eslint-disable-next-line import/prefer-default-export | ||
export async function setTheme(theme: string) { | ||
cookies().set('theme', theme); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
'use client'; | ||
import * as React from 'react'; | ||
import { css } from '@mui/zero-runtime'; | ||
import { setTheme } from '../app/actions'; | ||
|
||
export default function ThemeToggle({ value }: { value: string }) { | ||
return ( | ||
<select | ||
value={value} | ||
className={css({ | ||
position: 'fixed', | ||
top: '1rem', | ||
right: '1rem', | ||
zIndex: 1000, | ||
})} | ||
onChange={async (event) => { | ||
await setTheme(event.target.value); | ||
}} | ||
> | ||
<option value="light">light</option> | ||
<option value="dark">dark</option> | ||
</select> | ||
); | ||
} |
Oops, something went wrong.