@pisodev/test-component-library 2.0.2 → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,15 @@
1
+ import { createContext } from 'react';
2
+ import { Theme, ThemeMode } from './colors.types';
3
+ import { lightTheme } from './colors';
4
+
5
+ export interface ThemeContextType {
6
+ theme: Theme;
7
+ mode: ThemeMode;
8
+ setMode: (mode: ThemeMode) => void;
9
+ }
10
+
11
+ export const ThemeContext = createContext<ThemeContextType>({
12
+ theme: lightTheme,
13
+ mode: 'light',
14
+ setMode: () => {},
15
+ });
@@ -0,0 +1,36 @@
1
+ import React, { useState, ReactNode } from 'react';
2
+ import { useColorScheme } from 'react-native';
3
+ import { ThemeContext } from './ThemeContext';
4
+ import { ThemeMode } from './colors.types';
5
+ import { lightTheme, darkTheme } from './colors';
6
+
7
+ export interface ThemeProviderProps {
8
+ children: ReactNode;
9
+ initialMode?: ThemeMode;
10
+ followSystem?: boolean;
11
+ }
12
+
13
+ export const ThemeProvider: React.FC<ThemeProviderProps> = ({
14
+ children,
15
+ initialMode,
16
+ followSystem = true,
17
+ }) => {
18
+ const systemColorScheme = useColorScheme();
19
+ const [manualMode, setManualMode] = useState<ThemeMode | null>(
20
+ initialMode || null
21
+ );
22
+
23
+ const mode =
24
+ manualMode || (followSystem && systemColorScheme) || 'light';
25
+ const theme = mode === 'light' ? lightTheme : darkTheme;
26
+
27
+ const setMode = (newMode: ThemeMode) => {
28
+ setManualMode(newMode);
29
+ };
30
+
31
+ return (
32
+ <ThemeContext.Provider value={{ theme, mode, setMode }}>
33
+ {children}
34
+ </ThemeContext.Provider>
35
+ );
36
+ };
@@ -0,0 +1,67 @@
1
+ import React, { useState, useEffect, ReactNode } from 'react';
2
+ import { ThemeContext } from './ThemeContext';
3
+ import { ThemeMode } from './colors.types';
4
+ import { lightTheme, darkTheme } from './colors';
5
+
6
+ export interface ThemeProviderProps {
7
+ children: ReactNode;
8
+ initialMode?: ThemeMode;
9
+ }
10
+
11
+ export const ThemeProvider: React.FC<ThemeProviderProps> = ({
12
+ children,
13
+ initialMode = 'light',
14
+ }) => {
15
+ const [mode, setMode] = useState<ThemeMode>(initialMode);
16
+ const theme = mode === 'light' ? lightTheme : darkTheme;
17
+
18
+ useEffect(() => {
19
+ // HTML 클래스 업데이트
20
+ document.documentElement.classList.remove('light', 'dark');
21
+ document.documentElement.classList.add(mode);
22
+
23
+ // CSS Variables 업데이트
24
+ const root = document.documentElement;
25
+
26
+ // Gray colors
27
+ root.style.setProperty('--gray-50', theme.colors.gray[50]);
28
+ root.style.setProperty('--gray-100', theme.colors.gray[100]);
29
+ root.style.setProperty('--gray-200', theme.colors.gray[200]);
30
+ root.style.setProperty('--gray-400', theme.colors.gray[400]);
31
+ root.style.setProperty('--gray-600', theme.colors.gray[600]);
32
+ root.style.setProperty('--gray-800', theme.colors.gray[800]);
33
+ root.style.setProperty('--gray-900', theme.colors.gray[900]);
34
+
35
+ // Green colors
36
+ root.style.setProperty('--green-400', theme.colors.green[400]);
37
+ root.style.setProperty('--green-500', theme.colors.green[500]);
38
+ root.style.setProperty('--green-600', theme.colors.green[600]);
39
+
40
+ // Blue colors
41
+ root.style.setProperty('--blue-400', theme.colors.blue[400]);
42
+ root.style.setProperty('--blue-500', theme.colors.blue[500]);
43
+ root.style.setProperty('--blue-600', theme.colors.blue[600]);
44
+
45
+ // Red colors
46
+ root.style.setProperty('--red-400', theme.colors.red[400]);
47
+ root.style.setProperty('--red-500', theme.colors.red[500]);
48
+ root.style.setProperty('--red-600', theme.colors.red[600]);
49
+
50
+ // Semantic colors
51
+ root.style.setProperty('--color-info', theme.semantic.info);
52
+ root.style.setProperty('--color-success', theme.semantic.success);
53
+ root.style.setProperty('--color-error', theme.semantic.error);
54
+ root.style.setProperty('--color-warning', theme.semantic.warning);
55
+
56
+ // Paper colors
57
+ root.style.setProperty('--paper-default', theme.paper.default);
58
+ root.style.setProperty('--paper-neutral', theme.paper.neutral);
59
+ root.style.setProperty('--paper-dialog', theme.paper.dialog);
60
+ }, [mode, theme]);
61
+
62
+ return (
63
+ <ThemeContext.Provider value={{ theme, mode, setMode }}>
64
+ {children}
65
+ </ThemeContext.Provider>
66
+ );
67
+ };
@@ -0,0 +1,81 @@
1
+ import { Theme } from './colors.types';
2
+
3
+ export const lightTheme: Theme = {
4
+ colors: {
5
+ gray: {
6
+ 50: '#F6F8FA',
7
+ 100: '#EEF0F2',
8
+ 200: '#E6E8EA',
9
+ 400: '#CED0D2',
10
+ 600: '#86888A',
11
+ 800: '#2C2E30',
12
+ 900: '#0C0E10',
13
+ },
14
+ green: {
15
+ 400: '#18C792',
16
+ 500: '#16B383',
17
+ 600: '#12976F',
18
+ },
19
+ blue: {
20
+ 400: '#1473FF',
21
+ 500: '#1267E6',
22
+ 600: '#0F57C2',
23
+ },
24
+ red: {
25
+ 400: '#EB4242',
26
+ 500: '#D43B3B',
27
+ 600: '#B33232',
28
+ },
29
+ },
30
+ semantic: {
31
+ info: '#1473FF',
32
+ success: '#18C792',
33
+ error: '#EB4242',
34
+ warning: '#F0B800',
35
+ },
36
+ paper: {
37
+ default: '#FFFFFF',
38
+ neutral: '#F6F8FA',
39
+ dialog: '#FFFFFF',
40
+ },
41
+ };
42
+
43
+ export const darkTheme: Theme = {
44
+ colors: {
45
+ gray: {
46
+ 50: '#1A1C1E',
47
+ 100: '#282A2C',
48
+ 200: '#36383A',
49
+ 400: '#525456',
50
+ 600: '#888A8C',
51
+ 800: '#CCCED0',
52
+ 900: '#FFFFFF',
53
+ },
54
+ green: {
55
+ 400: '#1EEEAF',
56
+ 500: '#54F2C2',
57
+ 600: '#73F4CD',
58
+ },
59
+ blue: {
60
+ 400: '#1473FF',
61
+ 500: '#4C95FF',
62
+ 600: '#6DA8FF',
63
+ },
64
+ red: {
65
+ 400: '#FF4848',
66
+ 500: '#FF7474',
67
+ 600: '#FF8E8E',
68
+ },
69
+ },
70
+ semantic: {
71
+ info: '#1473FF',
72
+ success: '#1EEEAF',
73
+ error: '#FF4848',
74
+ warning: '#FFC400',
75
+ },
76
+ paper: {
77
+ default: '#0C0E10',
78
+ neutral: '#0C0E10',
79
+ dialog: '#1A1C1E',
80
+ },
81
+ };
@@ -0,0 +1,48 @@
1
+ // 간소화된 컬러 타입 (예시용)
2
+ export interface ColorScale {
3
+ gray: {
4
+ 50: string;
5
+ 100: string;
6
+ 200: string;
7
+ 400: string;
8
+ 600: string;
9
+ 800: string;
10
+ 900: string;
11
+ };
12
+ green: {
13
+ 400: string;
14
+ 500: string;
15
+ 600: string;
16
+ };
17
+ blue: {
18
+ 400: string;
19
+ 500: string;
20
+ 600: string;
21
+ };
22
+ red: {
23
+ 400: string;
24
+ 500: string;
25
+ 600: string;
26
+ };
27
+ }
28
+
29
+ export interface SemanticColors {
30
+ info: string;
31
+ success: string;
32
+ error: string;
33
+ warning: string;
34
+ }
35
+
36
+ export interface PaperColors {
37
+ default: string;
38
+ neutral: string;
39
+ dialog: string;
40
+ }
41
+
42
+ export interface Theme {
43
+ colors: ColorScale;
44
+ semantic: SemanticColors;
45
+ paper: PaperColors;
46
+ }
47
+
48
+ export type ThemeMode = 'light' | 'dark';
@@ -0,0 +1,4 @@
1
+ export { ThemeProvider } from './ThemeProvider.native';
2
+ export { useTheme } from './useTheme';
3
+ export { lightTheme, darkTheme } from './colors';
4
+ export type { Theme, ThemeMode, ColorScale, SemanticColors, PaperColors } from './colors.types';
@@ -0,0 +1,4 @@
1
+ export { ThemeProvider } from './ThemeProvider.web';
2
+ export { useTheme } from './useTheme';
3
+ export { lightTheme, darkTheme } from './colors';
4
+ export type { Theme, ThemeMode, ColorScale, SemanticColors, PaperColors } from './colors.types';
@@ -0,0 +1,12 @@
1
+ import { useContext } from 'react';
2
+ import { ThemeContext } from './ThemeContext';
3
+
4
+ export const useTheme = () => {
5
+ const context = useContext(ThemeContext);
6
+
7
+ if (!context) {
8
+ throw new Error('useTheme must be used within ThemeProvider');
9
+ }
10
+
11
+ return context;
12
+ };
@@ -0,0 +1,7 @@
1
+ import { Theme, ThemeMode } from './colors.types';
2
+ export interface ThemeContextType {
3
+ theme: Theme;
4
+ mode: ThemeMode;
5
+ setMode: (mode: ThemeMode) => void;
6
+ }
7
+ export declare const ThemeContext: import("react").Context<ThemeContextType>;
@@ -0,0 +1,8 @@
1
+ import React, { ReactNode } from 'react';
2
+ import { ThemeMode } from './colors.types';
3
+ export interface ThemeProviderProps {
4
+ children: ReactNode;
5
+ initialMode?: ThemeMode;
6
+ followSystem?: boolean;
7
+ }
8
+ export declare const ThemeProvider: React.FC<ThemeProviderProps>;
@@ -0,0 +1,7 @@
1
+ import React, { ReactNode } from 'react';
2
+ import { ThemeMode } from './colors.types';
3
+ export interface ThemeProviderProps {
4
+ children: ReactNode;
5
+ initialMode?: ThemeMode;
6
+ }
7
+ export declare const ThemeProvider: React.FC<ThemeProviderProps>;
@@ -0,0 +1,3 @@
1
+ import { Theme } from './colors.types';
2
+ export declare const lightTheme: Theme;
3
+ export declare const darkTheme: Theme;
@@ -0,0 +1,43 @@
1
+ export interface ColorScale {
2
+ gray: {
3
+ 50: string;
4
+ 100: string;
5
+ 200: string;
6
+ 400: string;
7
+ 600: string;
8
+ 800: string;
9
+ 900: string;
10
+ };
11
+ green: {
12
+ 400: string;
13
+ 500: string;
14
+ 600: string;
15
+ };
16
+ blue: {
17
+ 400: string;
18
+ 500: string;
19
+ 600: string;
20
+ };
21
+ red: {
22
+ 400: string;
23
+ 500: string;
24
+ 600: string;
25
+ };
26
+ }
27
+ export interface SemanticColors {
28
+ info: string;
29
+ success: string;
30
+ error: string;
31
+ warning: string;
32
+ }
33
+ export interface PaperColors {
34
+ default: string;
35
+ neutral: string;
36
+ dialog: string;
37
+ }
38
+ export interface Theme {
39
+ colors: ColorScale;
40
+ semantic: SemanticColors;
41
+ paper: PaperColors;
42
+ }
43
+ export type ThemeMode = 'light' | 'dark';
@@ -0,0 +1,4 @@
1
+ export { ThemeProvider } from './ThemeProvider.native';
2
+ export { useTheme } from './useTheme';
3
+ export { lightTheme, darkTheme } from './colors';
4
+ export type { Theme, ThemeMode, ColorScale, SemanticColors, PaperColors } from './colors.types';
@@ -0,0 +1,4 @@
1
+ export { ThemeProvider } from './ThemeProvider.web';
2
+ export { useTheme } from './useTheme';
3
+ export { lightTheme, darkTheme } from './colors';
4
+ export type { Theme, ThemeMode, ColorScale, SemanticColors, PaperColors } from './colors.types';
@@ -0,0 +1 @@
1
+ export declare const useTheme: () => import("./ThemeContext").ThemeContextType;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pisodev/test-component-library",
3
- "version": "2.0.2",
3
+ "version": "2.1.0",
4
4
  "description": "웹과 React Native를 위한 컴포넌트 라이브러리",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.esm.js",