Skip to content

Commit

Permalink
[Feat]: theme 적용을 위한 Provider 추가 (#47)
Browse files Browse the repository at this point in the history
  • Loading branch information
minseong0324 authored Jan 7, 2025
1 parent 73b7a7f commit 8461f8b
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 4 deletions.
6 changes: 4 additions & 2 deletions apps/web/src/app/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import type { Metadata } from 'next';
import localFont from 'next/font/local';
import './globals.css';
//import '@repo/ui/styles';
import '@repo/theme/styles';
//import '@repo/ui/styles';
import { ThemeProvider } from '@repo/theme';

const geistSans = localFont({
src: './fonts/GeistVF.woff',
Expand All @@ -28,7 +29,8 @@ export default function RootLayout({
return (
<html lang="en">
<body className={`${geistSans.variable} ${geistMono.variable}`}>
{children}
<ThemeProvider theme="light">{children}</ThemeProvider>{' '}
{/** TODO: 추후 시스템 감지 설정 추가 예정 */}
</body>
</html>
);
Expand Down
4 changes: 3 additions & 1 deletion packages/theme/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,11 @@
"@vanilla-extract/css": "^1.17.0",
"@vanilla-extract/next-plugin": "^2.4.8",
"@vanilla-extract/recipes": "^0.5.5",
"@vanilla-extract/sprinkles": "^1.6.3"
"@vanilla-extract/sprinkles": "^1.6.3",
"react": "^18"
},
"devDependencies": {
"@types/react": "^18.2.0",
"@vanilla-extract/esbuild-plugin": "^2.3.5",
"esbuild": "^0.21.0",
"esbuild-plugin-preserve-directives": "^0.0.11"
Expand Down
16 changes: 16 additions & 0 deletions packages/theme/src/components/ThemeProvider.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { ReactNode } from 'react';
import { lightThemeClass, darkThemeClass } from '../themes/themes.css';

type ThemeProviderProps = {
children: ReactNode;
theme?: 'light' | 'dark';
};

export function ThemeProvider({
children,
theme = 'light',
}: ThemeProviderProps) {
const themeClass = theme === 'light' ? lightThemeClass : darkThemeClass;

return <div className={themeClass}>{children}</div>;
}
3 changes: 2 additions & 1 deletion packages/theme/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export * from './tokens';
export * from './themes';
export * from './sprinkles';
export * from './tokens';
export * from './components/ThemeProvider';
7 changes: 7 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 8461f8b

Please sign in to comment.