@gyeol-ui/tailwind 0.0.0-stage → 0.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.
- package/LICENSE +21 -0
- package/README.md +110 -2
- package/dist/theme.css +33 -0
- package/package.json +57 -3
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 gyeol-ui contributors
|
|
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
CHANGED
|
@@ -1,3 +1,111 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @gyeol-ui/tailwind
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
gyeol-ui의 Design Token을 Tailwind CSS v4 클래스로 쓰게 하는 테마 패키지입니다.
|
|
4
|
+
|
|
5
|
+
> 🚧 아직 npm에 배포하지 않았습니다.
|
|
6
|
+
|
|
7
|
+
## 사용법
|
|
8
|
+
|
|
9
|
+
Tailwind CSS v4(`tailwindcss` `^4`)가 필요합니다. CSS 진입 파일에서 Tailwind 다음에 import합니다.
|
|
10
|
+
|
|
11
|
+
```css
|
|
12
|
+
@import "tailwindcss";
|
|
13
|
+
@import "@gyeol-ui/tailwind";
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
이 두 줄로 토큰 CSS 변수(`--gyeol-*`)와 토큰 클래스를 함께 씁니다. `@gyeol-ui/tokens/tokens.css`는 이 패키지가 import하므로 따로 import하지 않습니다.
|
|
17
|
+
|
|
18
|
+
```html
|
|
19
|
+
<div class="bg-bg-surface text-fg-default border border-border-default p-4 rounded-md">
|
|
20
|
+
…
|
|
21
|
+
</div>
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## 클래스 이름 규칙
|
|
25
|
+
|
|
26
|
+
클래스 이름은 Tailwind 유틸리티 접두어 뒤에 **토큰 이름을 그대로** 붙인 것입니다. Figma Dev Mode에서 본 변수 이름(`bg-surface`)으로 코드를 쓰고 찾을 수 있습니다. 이유는 [ADR-0005](../../docs/adr/0005-tailwind-utilities-keep-token-names.md)에 있습니다.
|
|
27
|
+
|
|
28
|
+
### 색: Role별로 쓸 수 있는 유틸리티가 정해져 있다
|
|
29
|
+
|
|
30
|
+
Semantic 색 토큰 이름의 첫 조각은 Role(색이 칠해지는 자리)입니다. 토큰은 자기 Role에 맞는 유틸리티에서만 클래스가 됩니다.
|
|
31
|
+
|
|
32
|
+
| Role | 토큰 예 | 클래스 | 값 |
|
|
33
|
+
|---|---|---|---|
|
|
34
|
+
| `bg` | `bg-surface` | `bg-bg-surface` | `background-color: var(--gyeol-bg-surface)` |
|
|
35
|
+
| `fg` | `fg-default` | `text-fg-default` | `color: var(--gyeol-fg-default)` |
|
|
36
|
+
| `border` | `border-default` | `border-border-default`, `divide-border-default` | `border-color: var(--gyeol-border-default)` |
|
|
37
|
+
| `ring-offset` | `ring-offset` | `ring-offset-ring-offset` | `--tw-ring-offset-color: var(--gyeol-ring-offset)` |
|
|
38
|
+
| `alpha` 그룹 | `alpha.90` | `bg-alpha-90` | `background-color: var(--gyeol-alpha-90)` |
|
|
39
|
+
|
|
40
|
+
Role에 맞지 않는 조합(`text-bg-surface`, `bg-fg-default`)은 클래스가 없습니다. 배경색을 글자에 칠하는 실수를 막기 위해서입니다. `alpha` 그룹은 `bg-surface`의 투명도 단계이므로 배경에만 씁니다.
|
|
41
|
+
|
|
42
|
+
투명도 수식어(`bg-bg-surface/50`)는 `color-mix(in oklab, …)`로 나옵니다.
|
|
43
|
+
|
|
44
|
+
### 간격과 모서리
|
|
45
|
+
|
|
46
|
+
간격은 `spacing` 토큰의 단계 이름(4px의 배수)을, 모서리는 `radius` 토큰의 이름을 씁니다.
|
|
47
|
+
|
|
48
|
+
| 토큰 | 클래스 예 | 값 |
|
|
49
|
+
|---|---|---|
|
|
50
|
+
| `spacing.4` | `p-4`, `m-4`, `gap-4`, `w-4` | `var(--gyeol-spacing-4)` (16px) |
|
|
51
|
+
| `radius.md` | `rounded-md` | `border-radius: var(--gyeol-radius-md)` |
|
|
52
|
+
|
|
53
|
+
`p-0`처럼 `0`은 토큰이 아니지만 `0px`로 들어 있습니다.
|
|
54
|
+
|
|
55
|
+
## `dark:`
|
|
56
|
+
|
|
57
|
+
Semantic 색 토큰은 Color Scheme에 따라 값이 바뀌므로, 토큰 클래스만 쓰면 `dark:` 없이도 dark에서 맞는 색이 나옵니다. 토큰 밖의 스타일을 Color Scheme에 따라 바꿀 때 `dark:`를 씁니다.
|
|
58
|
+
|
|
59
|
+
`dark:`는 토큰의 Color Scheme 규칙과 같은 조건에서 켜집니다. 그래서 토큰 색과 `dark:` 스타일이 엇갈리지 않습니다.
|
|
60
|
+
|
|
61
|
+
| `<html>`의 `data-color-scheme` | OS가 light | OS가 dark |
|
|
62
|
+
|---|---|---|
|
|
63
|
+
| 없음 | 꺼짐 | 켜짐 |
|
|
64
|
+
| `"light"` | 꺼짐 | 꺼짐 |
|
|
65
|
+
| `"dark"` | 켜짐 | 켜짐 |
|
|
66
|
+
|
|
67
|
+
```html
|
|
68
|
+
<html data-color-scheme="dark">
|
|
69
|
+
…
|
|
70
|
+
<img class="opacity-100 dark:opacity-80" … />
|
|
71
|
+
</html>
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
- 속성은 `<html>`에서만 봅니다. 페이지 일부에 `data-color-scheme`을 달아 Color Scheme을 바꾸는 것은 지원하지 않습니다.
|
|
75
|
+
- Tailwind 기본 `dark:`는 `prefers-color-scheme`만 보므로, 이 패키지가 `@custom-variant dark`로 다시 정의합니다. 조건을 `:where()`로 감싸서 `dark:` 클래스의 명시도는 클래스 하나와 같습니다.
|
|
76
|
+
|
|
77
|
+
## 토큰 밖의 값은 없습니다
|
|
78
|
+
|
|
79
|
+
토큰이 있는 범주(색, 간격, 모서리)에서는 Tailwind 기본값을 비웠습니다. 디자인 언어 밖의 값을 실수로 쓰지 않게 하려는 것입니다.
|
|
80
|
+
|
|
81
|
+
- 기본 팔레트 색이 없습니다: `bg-red-500`, `bg-white`, `text-black` 등.
|
|
82
|
+
- 토큰에 없는 간격 단계가 없습니다: `spacing.5` 토큰이 없으므로 `p-5`도 없습니다.
|
|
83
|
+
- 토큰에 없는 모서리가 없습니다: `rounded-lg` 등.
|
|
84
|
+
|
|
85
|
+
이런 클래스를 쓰면 Tailwind가 CSS를 만들지 않으므로 스타일이 적용되지 않습니다. 필요한 값이 없으면 Figma에 토큰을 추가하도록 디자이너와 이야기하세요.
|
|
86
|
+
|
|
87
|
+
다음은 Tailwind 동작상 남아 있습니다. 나중에 lint 규칙으로 막는 것을 검토합니다.
|
|
88
|
+
|
|
89
|
+
- 임의값: `p-[13px]`, `bg-[#fff]`
|
|
90
|
+
- 키워드: `bg-transparent`, `bg-current`, `w-full`, `p-px`
|
|
91
|
+
|
|
92
|
+
글자 크기, 그림자, breakpoint, 폰트는 아직 토큰이 없어 Tailwind 기본값을 그대로 씁니다.
|
|
93
|
+
|
|
94
|
+
## 개발
|
|
95
|
+
|
|
96
|
+
저장소 루트에서 의존성을 설치한 뒤 이 폴더에서 실행합니다. `@gyeol-ui/tokens`의 빌드 결과를 읽으므로, 저장소 루트의 `pnpm build`나 `pnpm test`처럼 turbo로 실행하면 tokens가 먼저 빌드됩니다.
|
|
97
|
+
|
|
98
|
+
| 명령 | 하는 일 |
|
|
99
|
+
|---|---|
|
|
100
|
+
| `pnpm build` | `@gyeol-ui/tokens/tokens.json`(공개 토큰 목록)으로 `dist/theme.css`를 만들고 publint로 패키지 모양을 검사한다 |
|
|
101
|
+
| `pnpm lint` | oxlint로 코드를 검사한다 |
|
|
102
|
+
| `pnpm test` | Vitest로 테스트를 실행한다 |
|
|
103
|
+
| `pnpm typecheck` | `tsc`로 타입을 검사한다 |
|
|
104
|
+
|
|
105
|
+
`dist/theme.css`는 손으로 쓰지 않고 생성합니다. 토큰이 바뀌면 다시 빌드하는 것만으로 클래스가 따라옵니다.
|
|
106
|
+
|
|
107
|
+
- 테마 텍스트를 쓰는 함수는 [`scripts/format-theme.ts`](./scripts/format-theme.ts)의 `formatTheme(공개 토큰 목록)`입니다. 대응을 정할 수 없는 토큰(표에 없는 Role이나 범주)이 있으면 그 토큰 경로를 모두 담아 실패합니다.
|
|
108
|
+
- Role·범주와 Tailwind namespace의 대응은 [`scripts/format-theme.helper.ts`](./scripts/format-theme.helper.ts)에만 있습니다. 토큰 하나가 어떤 `@theme` 변수가 되는지는 [`scripts/format-theme.helper.test.ts`](./scripts/format-theme.helper.test.ts)에서 볼 수 있습니다.
|
|
109
|
+
- [`scripts/build.ts`](./scripts/build.ts)가 이 함수를 실제 공개 토큰 목록으로 실행해 `dist/theme.css`에 씁니다.
|
|
110
|
+
- 테스트([`scripts/format-theme.test.ts`](./scripts/format-theme.test.ts))는 생성된 텍스트를 비교하지 않고, [`entry.css`](./entry.css)(배포하지 않는 진입 CSS, 위의 import 두 줄)와 함께 `@tailwindcss/node`로 컴파일해 어떤 클래스가 어떤 CSS로 나오는지 확인합니다. 실제 공개 토큰 목록의 모든 토큰도 확인하므로, Tailwind를 올렸을 때 Role별 namespace 동작이 깨지면 테스트가 실패합니다.
|
|
111
|
+
- 컴파일하는 함수(`compileClasses`)와 결과 CSS에서 클래스의 규칙을 찾는 함수(`findRules`, `findDeclarations`)는 [`scripts/__test__/`](./scripts/__test__/)에 있고, 각각 무엇을 받아 무엇을 돌려주는지 옆의 테스트에서 볼 수 있습니다.
|
package/dist/theme.css
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
@import "@gyeol-ui/tokens/tokens.css";
|
|
2
|
+
|
|
3
|
+
@theme inline {
|
|
4
|
+
--color-*: initial;
|
|
5
|
+
--spacing: initial;
|
|
6
|
+
--radius-*: initial;
|
|
7
|
+
--spacing-0: 0px;
|
|
8
|
+
--background-color-bg-surface: var(--gyeol-bg-surface);
|
|
9
|
+
--background-color-bg-subtle: var(--gyeol-bg-subtle);
|
|
10
|
+
--text-color-fg-default: var(--gyeol-fg-default);
|
|
11
|
+
--text-color-fg-muted: var(--gyeol-fg-muted);
|
|
12
|
+
--border-color-border-default: var(--gyeol-border-default);
|
|
13
|
+
--background-color-bg-accent: var(--gyeol-bg-accent);
|
|
14
|
+
--text-color-fg-on-accent: var(--gyeol-fg-on-accent);
|
|
15
|
+
--ring-offset-color-ring-offset: var(--gyeol-ring-offset);
|
|
16
|
+
--background-color-alpha-90: var(--gyeol-alpha-90);
|
|
17
|
+
--spacing-1: var(--gyeol-spacing-1);
|
|
18
|
+
--spacing-2: var(--gyeol-spacing-2);
|
|
19
|
+
--spacing-3: var(--gyeol-spacing-3);
|
|
20
|
+
--spacing-4: var(--gyeol-spacing-4);
|
|
21
|
+
--spacing-6: var(--gyeol-spacing-6);
|
|
22
|
+
--spacing-8: var(--gyeol-spacing-8);
|
|
23
|
+
--radius-sm: var(--gyeol-radius-sm);
|
|
24
|
+
--radius-md: var(--gyeol-radius-md);
|
|
25
|
+
--radius-full: var(--gyeol-radius-full);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
@custom-variant dark {
|
|
29
|
+
@media (prefers-color-scheme: dark) {
|
|
30
|
+
&:where(:root:not([data-color-scheme="light"]), :root:not([data-color-scheme="light"]) *) { @slot; }
|
|
31
|
+
}
|
|
32
|
+
&:where(:root[data-color-scheme="dark"], :root[data-color-scheme="dark"] *) { @slot; }
|
|
33
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,60 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gyeol-ui/tailwind",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "gyeol-ui Design Token을 Tailwind CSS v4 클래스로 쓰는 테마",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"design-system",
|
|
7
|
+
"design-tokens",
|
|
8
|
+
"tailwindcss",
|
|
9
|
+
"tailwind-theme",
|
|
10
|
+
"gyeol-ui"
|
|
11
|
+
],
|
|
12
|
+
"license": "MIT",
|
|
13
|
+
"homepage": "https://gyeol-ui.github.io/gyeol-ui/",
|
|
14
|
+
"bugs": {
|
|
15
|
+
"url": "https://github.com/gyeol-ui/gyeol-ui/issues"
|
|
16
|
+
},
|
|
17
|
+
"repository": {
|
|
18
|
+
"type": "git",
|
|
19
|
+
"url": "git+https://github.com/gyeol-ui/gyeol-ui.git",
|
|
20
|
+
"directory": "packages/tailwind"
|
|
21
|
+
},
|
|
22
|
+
"type": "module",
|
|
23
|
+
"sideEffects": [
|
|
24
|
+
"*.css"
|
|
25
|
+
],
|
|
26
|
+
"files": [
|
|
27
|
+
"dist"
|
|
28
|
+
],
|
|
29
|
+
"exports": {
|
|
30
|
+
".": {
|
|
31
|
+
"style": "./dist/theme.css",
|
|
32
|
+
"default": "./dist/theme.css"
|
|
33
|
+
},
|
|
34
|
+
"./package.json": "./package.json"
|
|
35
|
+
},
|
|
36
|
+
"publishConfig": {
|
|
37
|
+
"access": "public"
|
|
38
|
+
},
|
|
39
|
+
"dependencies": {
|
|
40
|
+
"@gyeol-ui/tokens": "0.1.0"
|
|
41
|
+
},
|
|
42
|
+
"peerDependencies": {
|
|
43
|
+
"tailwindcss": "^4"
|
|
44
|
+
},
|
|
45
|
+
"devDependencies": {
|
|
46
|
+
"@tailwindcss/node": "4.3.5",
|
|
47
|
+
"@types/node": "26.6.6",
|
|
48
|
+
"postcss": "8.5.33",
|
|
49
|
+
"publint": "0.3.25",
|
|
50
|
+
"tailwindcss": "4.3.5",
|
|
51
|
+
"typescript": "7.0.2",
|
|
52
|
+
"vitest": "5.1.0"
|
|
53
|
+
},
|
|
54
|
+
"scripts": {
|
|
55
|
+
"build": "node scripts/build.ts && publint",
|
|
56
|
+
"lint": "oxlint",
|
|
57
|
+
"test": "vitest run",
|
|
58
|
+
"typecheck": "tsc --noEmit"
|
|
59
|
+
}
|
|
6
60
|
}
|