@nexus-cross/tokens 1.0.1-beta.1 → 1.0.2-beta.1
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.
- package/dist/company-vars.css +1 -1
- package/dist/company.css +1 -1
- package/package.json +1 -1
- package/README.md +0 -197
package/dist/company-vars.css
CHANGED
package/dist/company.css
CHANGED
package/package.json
CHANGED
package/README.md
DELETED
|
@@ -1,197 +0,0 @@
|
|
|
1
|
-
# @nexus-cross/tokens
|
|
2
|
-
|
|
3
|
-
NEXUS 디자인 토큰 라이브러리 - 색상, 타이포그래피, 간격 등 디자인 토큰을 TypeScript/JavaScript로 제공합니다.
|
|
4
|
-
|
|
5
|
-
## 설치
|
|
6
|
-
|
|
7
|
-
```bash
|
|
8
|
-
npm install @nexus-cross/tokens
|
|
9
|
-
# or
|
|
10
|
-
yarn add @nexus-cross/tokens
|
|
11
|
-
# or
|
|
12
|
-
pnpm add @nexus-cross/tokens
|
|
13
|
-
```
|
|
14
|
-
|
|
15
|
-
## 사용법
|
|
16
|
-
|
|
17
|
-
### 기본 사용 (getTheme)
|
|
18
|
-
|
|
19
|
-
```typescript
|
|
20
|
-
import { getTheme, typography, spacing } from '@nexus-cross/tokens';
|
|
21
|
-
|
|
22
|
-
// 테마 선택
|
|
23
|
-
function App({ isDark }: { isDark: boolean }) {
|
|
24
|
-
const { semantic, palette } = getTheme(isDark ? 'dark' : 'light');
|
|
25
|
-
|
|
26
|
-
return (
|
|
27
|
-
<div style={{
|
|
28
|
-
backgroundColor: semantic.bg.default.base,
|
|
29
|
-
color: semantic.text.primary.base,
|
|
30
|
-
padding: spacing.md,
|
|
31
|
-
}}>
|
|
32
|
-
<h1 style={{
|
|
33
|
-
fontSize: typography.heading.large.fontSize,
|
|
34
|
-
color: semantic.accent.primary.base,
|
|
35
|
-
}}>
|
|
36
|
-
Hello NEXUS
|
|
37
|
-
</h1>
|
|
38
|
-
</div>
|
|
39
|
-
);
|
|
40
|
-
}
|
|
41
|
-
```
|
|
42
|
-
|
|
43
|
-
### Palette vs Semantic
|
|
44
|
-
|
|
45
|
-
```typescript
|
|
46
|
-
// ❌ 나쁜 예: palette를 직접 사용 (UI 의미가 불명확)
|
|
47
|
-
<div style={{ color: palette.neutral[900] }}>텍스트</div>
|
|
48
|
-
|
|
49
|
-
// ✅ 좋은 예: semantic 색상 사용 (의미 기반, 테마 자동 적용)
|
|
50
|
-
<div style={{ color: semantic.text.primary.base }}>텍스트</div>
|
|
51
|
-
```
|
|
52
|
-
|
|
53
|
-
### React Context를 이용한 테마 적용
|
|
54
|
-
|
|
55
|
-
```typescript
|
|
56
|
-
import { createContext, useContext, useState, useEffect } from 'react';
|
|
57
|
-
import { getTheme, type ColorMode, type Theme } from '@nexus-cross/tokens';
|
|
58
|
-
|
|
59
|
-
const ThemeContext = createContext<{ theme: Theme; mode: ColorMode } | null>(null);
|
|
60
|
-
|
|
61
|
-
export function ThemeProvider({ children }) {
|
|
62
|
-
const [mode, setMode] = useState<ColorMode>('dark');
|
|
63
|
-
const theme = getTheme(mode);
|
|
64
|
-
|
|
65
|
-
return (
|
|
66
|
-
<ThemeContext.Provider value={{ theme, mode, setMode }}>
|
|
67
|
-
{children}
|
|
68
|
-
</ThemeContext.Provider>
|
|
69
|
-
);
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
export const useTheme = () => {
|
|
73
|
-
const ctx = useContext(ThemeContext);
|
|
74
|
-
if (!ctx) throw new Error('useTheme must be within ThemeProvider');
|
|
75
|
-
return ctx;
|
|
76
|
-
};
|
|
77
|
-
|
|
78
|
-
// 사용
|
|
79
|
-
function Button() {
|
|
80
|
-
const { theme } = useTheme();
|
|
81
|
-
return (
|
|
82
|
-
<button style={{
|
|
83
|
-
backgroundColor: theme.semantic.accent.primary.base,
|
|
84
|
-
color: theme.semantic.accent['on-primary'],
|
|
85
|
-
}}>
|
|
86
|
-
클릭
|
|
87
|
-
</button>
|
|
88
|
-
);
|
|
89
|
-
}
|
|
90
|
-
```
|
|
91
|
-
|
|
92
|
-
## 구조
|
|
93
|
-
|
|
94
|
-
```
|
|
95
|
-
@nexus-cross/tokens
|
|
96
|
-
├── data/ # SSOT JSON 데이터
|
|
97
|
-
│ └── color.json # Semantic Mode-Aware 구조
|
|
98
|
-
├── palette # 테마 독립적 기본 색상 팔레트 (단일 값)
|
|
99
|
-
│ ├── neutral # Gray scale
|
|
100
|
-
│ ├── brand # 브랜드 색상
|
|
101
|
-
│ ├── green # 상태 색상
|
|
102
|
-
│ ├── red
|
|
103
|
-
│ ├── yellow
|
|
104
|
-
│ └── blue
|
|
105
|
-
├── themes # 테마별 semantic 색상
|
|
106
|
-
│ ├── light # 라이트 테마 (createSemantic(palette, 'light'))
|
|
107
|
-
│ └── dark # 다크 테마 (createSemantic(palette, 'dark'))
|
|
108
|
-
├── typography # 타이포그래피
|
|
109
|
-
├── spacing # 간격
|
|
110
|
-
├── shadows # 그림자
|
|
111
|
-
└── breakpoints # 반응형 브레이크포인트
|
|
112
|
-
```
|
|
113
|
-
|
|
114
|
-
### Semantic Mode-Aware 구조
|
|
115
|
-
|
|
116
|
-
**Primitive**는 순수 색상값만 가집니다 (mode 무관):
|
|
117
|
-
```typescript
|
|
118
|
-
palette.brand[500] // #22C55E (항상 동일)
|
|
119
|
-
palette.neutral[50] // #FAFAFA (항상 동일)
|
|
120
|
-
```
|
|
121
|
-
|
|
122
|
-
**Semantic**에서 mode별로 다른 primitive를 참조합니다:
|
|
123
|
-
```typescript
|
|
124
|
-
// color.json 구조
|
|
125
|
-
{
|
|
126
|
-
"semantic": {
|
|
127
|
-
"text": {
|
|
128
|
-
"primary": {
|
|
129
|
-
"base": {
|
|
130
|
-
"light": { "source": "neutral.950" }, // → #09090B
|
|
131
|
-
"dark": { "source": "neutral.50" } // → #FAFAFA
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
// 사용 시
|
|
139
|
-
const lightTheme = getTheme('light');
|
|
140
|
-
lightTheme.semantic.text.primary.base // #09090B (어두운 색)
|
|
141
|
-
|
|
142
|
-
const darkTheme = getTheme('dark');
|
|
143
|
-
darkTheme.semantic.text.primary.base // #FAFAFA (밝은 색)
|
|
144
|
-
```
|
|
145
|
-
|
|
146
|
-
## API
|
|
147
|
-
|
|
148
|
-
### getTheme(mode: 'light' | 'dark')
|
|
149
|
-
|
|
150
|
-
지정된 mode의 테마를 반환합니다.
|
|
151
|
-
|
|
152
|
-
```typescript
|
|
153
|
-
const { mode, palette, semantic } = getTheme('dark');
|
|
154
|
-
```
|
|
155
|
-
|
|
156
|
-
### palette
|
|
157
|
-
|
|
158
|
-
테마 독립적인 순수 색상값입니다.
|
|
159
|
-
|
|
160
|
-
```typescript
|
|
161
|
-
import { palette } from '@nexus-cross/tokens';
|
|
162
|
-
|
|
163
|
-
palette.neutral[500] // #71717A
|
|
164
|
-
palette.brand[500] // #22C55E
|
|
165
|
-
```
|
|
166
|
-
|
|
167
|
-
### light, dark (Pre-built)
|
|
168
|
-
|
|
169
|
-
편의를 위한 미리 생성된 semantic 토큰입니다.
|
|
170
|
-
|
|
171
|
-
```typescript
|
|
172
|
-
import { light, dark } from '@nexus-cross/tokens';
|
|
173
|
-
|
|
174
|
-
// getTheme('light').semantic과 동일
|
|
175
|
-
light.text.primary.base
|
|
176
|
-
```
|
|
177
|
-
|
|
178
|
-
## 개발
|
|
179
|
-
|
|
180
|
-
```bash
|
|
181
|
-
# 빌드
|
|
182
|
-
npm run build
|
|
183
|
-
|
|
184
|
-
# 개발 모드 (watch)
|
|
185
|
-
npm run dev
|
|
186
|
-
|
|
187
|
-
# 타입 체크
|
|
188
|
-
npm run type-check
|
|
189
|
-
```
|
|
190
|
-
|
|
191
|
-
## 문서
|
|
192
|
-
|
|
193
|
-
디자인 토큰의 상세 스펙은 [`../../docs/tokens/`](../../docs/tokens/) 디렉토리를 참고하세요.
|
|
194
|
-
|
|
195
|
-
## 라이선스
|
|
196
|
-
|
|
197
|
-
ISC
|