Skip to content

Conversation

@blacktoast
Copy link
Contributor

@blacktoast blacktoast commented Jan 6, 2026

Pull Request

Thank you for raising a Pull Request. Please follow the instruction.

  • I’ve read CONTRIBUTING.md and followed the guidelines.

Summary

  • Dark Mode Implementation
    The default setting follows the system preference. Clicking the theme button once or more saves the selected theme to local storage.

Links (Issue References, etc, if there's any)

@blacktoast blacktoast changed the title Retto/oko 378 add dark mode in Demo Jan 6, 2026
Comment on lines 44 to 75
const themeInitScript = `
(function() {
try {
const stored = localStorage.getItem('theme');
let preference = 'system';
if (stored) {
const parsed = JSON.parse(stored);
preference = parsed.state?.preference || 'system';
}
let theme = preference;
if (preference === 'system') {
theme = window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light';
}
document.documentElement.setAttribute('data-theme', theme);
} catch (e) {}
})();
`;

export default function RootLayout({
children,
}: Readonly<{
children: React.ReactNode;
}>) {
return (
<html lang="en">
// To prevent flickering in dark mode or light mode in Next.js, an inline script is required.
// The reason is that even when using LayoutEffect in React, it executes after hydration.
<html lang="en" suppressHydrationWarning>
<head>
<script dangerouslySetInnerHTML={{ __html: themeInitScript }} />
</head>
<body
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a line script to prevent flickering before hydtraion.

@blacktoast blacktoast marked this pull request as ready for review January 7, 2026 07:03
import { IntegrationCard } from "./integration_card/integration_card";
import { useViewState } from "@oko-wallet-demo-web/state/view";
import { ThemeButton } from "@oko-wallet-demo-web/components/theme/theme_button";
import { Spacing } from "@oko-wallet-common-ui/spacing/spacing";
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Invalid import

| "quaternary-solid";
| "quaternary-solid"
| "brand-solid";
titleColor?: BaseTypographyProps["color"];
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please try not to use the "Indexed Access Type" of TypeScript.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there any particular advantage to using BaseTypographyColor over using BaseTypographyProps["color"]?

content,
hideFloatingArrow,
backgroundColor = "primary-solid",
titleColor = "white",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm also against the idea of having parameter default value

export const THEME_STORAGE_KEY = "theme";
export const THEME_ATTRIBUTE = "data-theme";

export const themeInitScript = `
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✔️

@eldenpark eldenpark merged commit c57d753 into main Jan 8, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants