chroma-ux 1.0.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.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,111 @@
1
+ # chroma-ux
2
+
3
+ OKLCH 기반 UX/UI 디자인 토큰 생성 라이브러리. **런타임 의존성 0**, ESM/CJS 지원.
4
+
5
+ - **Primary 고정**: 브랜드 Primary 색상을 라이트/다크 모드별로 고정
6
+ - **라이트·다크 동시 생성**: 한 번의 호출로 두 테마 토큰 세트 생성
7
+ - **확장 토큰**: 버튼 상태(hover/pressed/disabled), semantic, border/divider/focusRing
8
+ - **접근성**: WCAG AA/AAA, CVD(색약/색맹) 시뮬레이션
9
+
10
+ ---
11
+
12
+ ## 한 줄로 시작하기 (npx)
13
+
14
+ 설치 없이 바로 사용:
15
+
16
+ ```bash
17
+ # Primary 색상만 넣으면 JSON 토큰 출력
18
+ npx chroma-ux 5B5FF5
19
+
20
+ # CSS 변수로 출력
21
+ npx chroma-ux #5B5FF5 --css
22
+ ```
23
+
24
+ ---
25
+
26
+ ## 설치
27
+
28
+ ```bash
29
+ npm install chroma-ux
30
+ ```
31
+
32
+ ---
33
+
34
+ ## 사용법
35
+
36
+ ### ESM
37
+
38
+ ```javascript
39
+ import { recommendTokensDual } from "chroma-ux";
40
+
41
+ const { light, dark } = recommendTokensDual({
42
+ primaryHex: "#5B5FF5",
43
+ contrastTarget: "AA",
44
+ randomSeed: 42,
45
+ });
46
+
47
+ console.log(light.tokens.primary); // #5B5FF5
48
+ console.log(dark.tokens.background);
49
+ ```
50
+
51
+ ### CJS
52
+
53
+ ```javascript
54
+ const { recommendTokensDual } = require("chroma-ux");
55
+
56
+ const result = recommendTokensDual({ primaryHex: "#5B5FF5" });
57
+ ```
58
+
59
+ ### JSON 내보내기
60
+
61
+ ```javascript
62
+ import { recommendTokensDualAsJson } from "chroma-ux";
63
+
64
+ const json = recommendTokensDualAsJson({ primaryHex: "#5B5FF5" });
65
+ ```
66
+
67
+ ---
68
+
69
+ ## API
70
+
71
+ ### `recommendTokensDual(options)`
72
+
73
+ | 옵션 | 기본값 | 설명 |
74
+ |------|-------|------|
75
+ | `primaryHex` | **필수** | 브랜드 Primary (hex) |
76
+ | `primaryDarkHex` | `primaryHex` | 다크 전용 Primary |
77
+ | `seedHex` | - | 중성/액센트 시드 |
78
+ | `contrastTarget` | `"AA"` | `"AA"` \| `"AAA"` |
79
+ | `iterations` | `3500` | 최적화 반복 수 |
80
+ | `randomSeed` | 랜덤 | 재현용 시드 |
81
+
82
+ ### `validateTokens(tokens, target?, cvdModes?)`
83
+
84
+ 대비·상태 검증.
85
+
86
+ ---
87
+
88
+ ## npm 배포
89
+
90
+ **배포되는 파일**: `dist`(빌드 결과) + `bin`(CLI)만 포함. 소스(`src`, `build.js`)는 제외됩니다.
91
+
92
+ ```bash
93
+ # 1. npm 로그인 (최초 1회)
94
+ npm login
95
+
96
+ # 2. 패키지명 중복 확인 (chroma-ux가 이미 있으면 다른 이름 사용)
97
+ npm search chroma-ux
98
+
99
+ # 3. package.json의 repository.url을 본인 GitHub으로 수정
100
+
101
+ # 4. 배포
102
+ npm publish
103
+ ```
104
+
105
+ 배포 시 `prepublishOnly`가 자동으로 `npm run build`를 실행해 `dist`를 생성합니다.
106
+
107
+ ---
108
+
109
+ ## 라이선스
110
+
111
+ MIT
package/bin/cli.cjs ADDED
@@ -0,0 +1,56 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+
4
+ const { recommendTokensDual, recommendTokensDualAsJson } = require("../dist/cjs/index.cjs");
5
+
6
+ const args = process.argv.slice(2);
7
+ const hexArg = args.find((a) => /^#?[0-9A-Fa-f]{6}$/.test(a.replace("#", "")));
8
+ const primaryHex = hexArg ? ("#" + hexArg.replace(/^#/, "")) : null;
9
+
10
+ if (!primaryHex) {
11
+ console.error(`
12
+ chroma-ux — Primary 색상으로 라이트/다크 토큰 생성
13
+
14
+ 사용법:
15
+ npx chroma-ux <primary-hex>
16
+
17
+ 예시:
18
+ npx chroma-ux 5B5FF5
19
+ npx chroma-ux #5B5FF5
20
+
21
+ 옵션:
22
+ --json JSON 형식으로 출력 (기본)
23
+ --css CSS 변수 형식으로 출력
24
+ `);
25
+ process.exit(1);
26
+ }
27
+
28
+ const format = args.includes("--css") ? "css" : "json";
29
+ const result = recommendTokensDual({
30
+ primaryHex,
31
+ contrastTarget: "AA",
32
+ iterations: 3000,
33
+ randomSeed: 42,
34
+ });
35
+
36
+ if (format === "css") {
37
+ const { light, dark } = result;
38
+ console.log("/* Light theme */");
39
+ console.log(":root {");
40
+ Object.entries(light.tokens).forEach(([k, v]) => {
41
+ if (typeof v === "string" && v.startsWith("#")) {
42
+ console.log(` --color-${k.replace(/([A-Z])/g, "-$1").toLowerCase()}: ${v};`);
43
+ }
44
+ });
45
+ console.log("}\n");
46
+ console.log("/* Dark theme */");
47
+ console.log('[data-theme="dark"] {');
48
+ Object.entries(dark.tokens).forEach(([k, v]) => {
49
+ if (typeof v === "string" && v.startsWith("#")) {
50
+ console.log(` --color-${k.replace(/([A-Z])/g, "-$1").toLowerCase()}: ${v};`);
51
+ }
52
+ });
53
+ console.log("}");
54
+ } else {
55
+ console.log(recommendTokensDualAsJson({ primaryHex, contrastTarget: "AA", randomSeed: 42 }));
56
+ }