-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #534 from omnifed/533-docs-mode-toggle-weirdness
docs: hotfix button issue
- Loading branch information
Showing
9 changed files
with
59 additions
and
19 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
'use server' | ||
|
||
import type { ColorModes } from '@cerberus-design/react' | ||
import type { ThemeName } from '@/styled-system/themes' | ||
import { getCookie } from './cookies' | ||
|
||
export async function getCachedTheme() { | ||
const themeName = (await getCookie('theme')) as ThemeName | ||
const colorModeName = (await getCookie('colorMode')) as ColorModes | undefined | ||
return { | ||
themeName, | ||
colorModeName, | ||
cached: Boolean(themeName && colorModeName), | ||
} | ||
} |
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,15 @@ | ||
import { getCachedTheme } from '../actions/theme' | ||
import { setCookie } from '../actions/cookies' | ||
|
||
export async function GET() { | ||
const { themeName, colorModeName, cached } = await getCachedTheme() | ||
|
||
if (!cached) { | ||
await setCookie('theme', themeName) | ||
await setCookie('colorMode', colorModeName) | ||
} | ||
|
||
return new Response( | ||
JSON.stringify({ themeName, colorModeName, success: true }), | ||
) | ||
} |
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
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
Large diffs are not rendered by default.
Oops, something went wrong.
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