@nexus-cross/tokens 1.0.0-beta.1 → 1.0.0-beta.3
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/TOKENS.md +21 -0
- package/dist/company-vars.css +1 -1
- package/dist/company.css +1 -1
- package/package.json +6 -2
- package/scripts/postinstall.js +1 -1
- package/scripts/setup-cursor-rules.cjs +53 -0
- package/README.md +0 -197
package/dist/TOKENS.md
CHANGED
|
@@ -5,11 +5,32 @@
|
|
|
5
5
|
|
|
6
6
|
## 설치 및 사용
|
|
7
7
|
|
|
8
|
+
### Tailwind v4 (권장)
|
|
8
9
|
```css
|
|
9
10
|
@import "tailwindcss";
|
|
10
11
|
@import "@nexus-cross/tokens/company.css";
|
|
11
12
|
```
|
|
12
13
|
|
|
14
|
+
### Tailwind v3
|
|
15
|
+
```js
|
|
16
|
+
// tailwind.config.js
|
|
17
|
+
module.exports = {
|
|
18
|
+
presets: [require("@nexus-cross/tokens/tailwind")],
|
|
19
|
+
};
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
### 순수 CSS (Tailwind 없이)
|
|
23
|
+
```css
|
|
24
|
+
@import "@nexus-cross/tokens/css";
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
### JS/TS API
|
|
28
|
+
```ts
|
|
29
|
+
import { getTheme } from "@nexus-cross/tokens";
|
|
30
|
+
const { semantic } = getTheme("dark");
|
|
31
|
+
// semantic.bg.default.base → "#1E232E"
|
|
32
|
+
```
|
|
33
|
+
|
|
13
34
|
## Color Tokens (@theme → Tailwind 클래스)
|
|
14
35
|
|
|
15
36
|
### Background
|
package/dist/company-vars.css
CHANGED
package/dist/company.css
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nexus-cross/tokens",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
3
|
+
"version": "1.0.0-beta.3",
|
|
4
4
|
"description": "TO-NEXUS Design Tokens - 디자인 시스템 토큰 라이브러리",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.mjs",
|
|
@@ -20,8 +20,12 @@
|
|
|
20
20
|
"dist",
|
|
21
21
|
"src/tailwind.js",
|
|
22
22
|
"src/data",
|
|
23
|
-
"scripts/postinstall.js"
|
|
23
|
+
"scripts/postinstall.js",
|
|
24
|
+
"scripts/setup-cursor-rules.cjs"
|
|
24
25
|
],
|
|
26
|
+
"bin": {
|
|
27
|
+
"nexus-tokens-setup": "./scripts/setup-cursor-rules.cjs"
|
|
28
|
+
},
|
|
25
29
|
"keywords": [
|
|
26
30
|
"design-tokens",
|
|
27
31
|
"design-system",
|
package/scripts/postinstall.js
CHANGED
|
@@ -13,7 +13,7 @@ const path = require('path');
|
|
|
13
13
|
const RULE_FILENAME = 'nexus-tokens.mdc';
|
|
14
14
|
const FRONTMATTER = `---
|
|
15
15
|
description: "NEXUS Design Token Reference — 색상, 타이포그래피, 간격 등 모든 디자인 토큰의 Tailwind 클래스와 CSS 변수"
|
|
16
|
-
|
|
16
|
+
alwaysApply: true
|
|
17
17
|
---
|
|
18
18
|
|
|
19
19
|
`;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
const fs = require('fs');
|
|
4
|
+
const path = require('path');
|
|
5
|
+
|
|
6
|
+
const FRONTMATTER = `---
|
|
7
|
+
description: "NEXUS Design Token Reference — 색상, 타이포그래피, 간격 등 모든 디자인 토큰의 Tailwind 클래스와 CSS 변수"
|
|
8
|
+
alwaysApply: true
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
`;
|
|
12
|
+
|
|
13
|
+
function findProjectRoot(startDir) {
|
|
14
|
+
let dir = startDir;
|
|
15
|
+
while (dir !== path.parse(dir).root) {
|
|
16
|
+
const pkgPath = path.join(dir, 'package.json');
|
|
17
|
+
if (fs.existsSync(pkgPath) && !dir.includes('node_modules')) {
|
|
18
|
+
return dir;
|
|
19
|
+
}
|
|
20
|
+
dir = path.dirname(dir);
|
|
21
|
+
}
|
|
22
|
+
return null;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function run() {
|
|
26
|
+
const projectRoot = findProjectRoot(process.cwd());
|
|
27
|
+
if (!projectRoot) {
|
|
28
|
+
console.log('[@nexus-cross/tokens] 프로젝트 루트를 찾을 수 없습니다.');
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const tokensMd = path.join(projectRoot, 'node_modules', '@nexus-cross', 'tokens', 'dist', 'TOKENS.md');
|
|
33
|
+
if (!fs.existsSync(tokensMd)) {
|
|
34
|
+
console.log('[@nexus-cross/tokens] dist/TOKENS.md를 찾을 수 없습니다.');
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const targetDir = path.join(projectRoot, '.cursor', 'rules');
|
|
39
|
+
fs.mkdirSync(targetDir, { recursive: true });
|
|
40
|
+
|
|
41
|
+
const content = FRONTMATTER + fs.readFileSync(tokensMd, 'utf-8');
|
|
42
|
+
const dest = path.join(targetDir, 'nexus-tokens.mdc');
|
|
43
|
+
const destExists = fs.existsSync(dest);
|
|
44
|
+
|
|
45
|
+
if (!destExists || fs.readFileSync(dest, 'utf-8') !== content) {
|
|
46
|
+
fs.writeFileSync(dest, content, 'utf-8');
|
|
47
|
+
console.log(`[@nexus-cross/tokens] ${destExists ? '업데이트' : '설치'}: .cursor/rules/nexus-tokens.mdc`);
|
|
48
|
+
} else {
|
|
49
|
+
console.log('[@nexus-cross/tokens] Cursor rules가 이미 최신 상태입니다.');
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
run();
|
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
|