@tide-design/foundation 0.0.0-stage → 0.11.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.
@@ -0,0 +1,15 @@
1
+ /**
2
+ * `@tide-design/foundation/internal`: 문서 앱(Token 블록), 빌드 스크립트, 테스트가 쓰는 내부 도우미.
3
+ *
4
+ * @internal 앱 개발자용 공개 계약이 아니다. 문서에 싣지 않고, 예고 없이 바뀌거나 사라질 수 있다.
5
+ * @packageDocumentation
6
+ */
7
+ import { primitiveHex } from "./color.js";
8
+ import { BackgroundSlot, SlotColorRef, SlotMix, SlotOverlay, SlotOverrides, SlotRule, SlotStep, SlotValue, colorSlots, familyOverrides, familySlotSteps, mixHex, resolveSlotSteps, slotPrimitive, slotRule, slotValueHex } from "./colorSlot.js";
9
+ import { colorValueHex, roleFamily, roleOverrides, roleSharedSlots, semanticEntries, semanticHex, shadowColor } from "./semantic.js";
10
+ import { TideColor, colorFamilyNames, colorSlotHex, colorSlotValues, isRole, roleNames, roleSlotToken, tideColorNames } from "./colorName.js";
11
+ import { AccentUtility, accentDefaultDeclarations, accentUtilities, accentVar, dataColorRule, familyThemeDeclarations, familyVar, primitiveVar, roleAliasCss, semanticVar, tideFamilyThemeDeclarations } from "./colorCss.js";
12
+ import { ColorContrastResult, ColorContrastRule, checkColorContrast, colorContrastRules, contrastExclusions, contrastPairRatio, contrastRatio, opaqueSemanticHex } from "./contrast.js";
13
+ import { fontFamilyCss } from "./typography.js";
14
+ import { shadowCss } from "./shape.js";
15
+ export { type AccentUtility, type BackgroundSlot, type ColorContrastResult, type ColorContrastRule, type SlotColorRef, type SlotMix, type SlotOverlay, type SlotOverrides, type SlotRule, type SlotStep, type SlotValue, type TideColor, accentDefaultDeclarations, accentUtilities, accentVar, checkColorContrast, colorContrastRules, colorFamilyNames, colorSlotHex, colorSlotValues, colorSlots, colorValueHex, contrastExclusions, contrastPairRatio, contrastRatio, dataColorRule, familyOverrides, familySlotSteps, familyThemeDeclarations, familyVar, fontFamilyCss, isRole, mixHex, opaqueSemanticHex, primitiveHex, primitiveVar, resolveSlotSteps, roleAliasCss, roleFamily, roleNames, roleOverrides, roleSharedSlots, roleSlotToken, semanticEntries, semanticHex, semanticVar, shadowColor, shadowCss, slotPrimitive, slotRule, slotValueHex, tideColorNames, tideFamilyThemeDeclarations };
@@ -0,0 +1,10 @@
1
+ import { primitiveHex } from "./color.js";
2
+ import { colorSlots, familyOverrides, familySlotSteps, mixHex, resolveSlotSteps, slotPrimitive, slotRule, slotValueHex } from "./colorSlot.js";
3
+ import { colorValueHex, roleFamily, roleOverrides, roleSharedSlots, semanticEntries, semanticHex, shadowColor } from "./semantic.js";
4
+ import { colorFamilyNames, colorSlotHex, colorSlotValues, isRole, roleNames, roleSlotToken, tideColorNames } from "./colorName.js";
5
+ import { accentDefaultDeclarations, accentUtilities, accentVar, dataColorRule, familyThemeDeclarations, familyVar, primitiveVar, roleAliasCss, semanticVar, tideFamilyThemeDeclarations } from "./colorCss.js";
6
+ import { checkColorContrast, colorContrastRules, contrastExclusions, contrastPairRatio, contrastRatio, opaqueSemanticHex } from "./contrast.js";
7
+ import { fontFamilyCss } from "./typography.js";
8
+ import { shadowCss } from "./shape.js";
9
+
10
+ export { accentDefaultDeclarations, accentUtilities, accentVar, checkColorContrast, colorContrastRules, colorFamilyNames, colorSlotHex, colorSlotValues, colorSlots, colorValueHex, contrastExclusions, contrastPairRatio, contrastRatio, dataColorRule, familyOverrides, familySlotSteps, familyThemeDeclarations, familyVar, fontFamilyCss, isRole, mixHex, opaqueSemanticHex, primitiveHex, primitiveVar, resolveSlotSteps, roleAliasCss, roleFamily, roleNames, roleOverrides, roleSharedSlots, roleSlotToken, semanticEntries, semanticHex, semanticVar, shadowColor, shadowCss, slotPrimitive, slotRule, slotValueHex, tideColorNames, tideFamilyThemeDeclarations };
@@ -0,0 +1,20 @@
1
+ /**
2
+ * duration 2단계. `duration-<이름>` class와 공개 계약 `--tide-duration-<이름>`이 쓴다.
3
+ * - fast: hover·press, 색 전환, Switch thumb, 오버레이가 사라질 때. 시간을 적지 않은 transition의 기본값이다.
4
+ * - normal: 가끔 쓰는 오버레이(Popover, Toast, Dialog류)가 나타날 때
5
+ */
6
+ export declare const duration: {
7
+ readonly fast: "150ms";
8
+ readonly normal: "300ms";
9
+ };
10
+ /** duration 단계 이름 */
11
+ export type DurationName = keyof typeof duration;
12
+ /**
13
+ * easing. `ease-<이름>` class와 공개 계약 `--tide-ease-<이름>`이 쓴다.
14
+ * - out: Tide Component 전부. 나타날 때와 사라질 때 모두. 시간을 적지 않은 transition의 기본값이다.
15
+ */
16
+ export declare const easing: {
17
+ readonly out: "cubic-bezier(0, 0, 0.2, 1)";
18
+ };
19
+ /** easing 이름 */
20
+ export type EasingName = keyof typeof easing;
package/dist/motion.js ADDED
@@ -0,0 +1,17 @@
1
+ // src/motion.ts
2
+ /**
3
+ * duration 2단계. `duration-<이름>` class와 공개 계약 `--tide-duration-<이름>`이 쓴다.
4
+ * - fast: hover·press, 색 전환, Switch thumb, 오버레이가 사라질 때. 시간을 적지 않은 transition의 기본값이다.
5
+ * - normal: 가끔 쓰는 오버레이(Popover, Toast, Dialog류)가 나타날 때
6
+ */
7
+ const duration = {
8
+ fast: "150ms",
9
+ normal: "300ms"
10
+ };
11
+ /**
12
+ * easing. `ease-<이름>` class와 공개 계약 `--tide-ease-<이름>`이 쓴다.
13
+ * - out: Tide Component 전부. 나타날 때와 사라질 때 모두. 시간을 적지 않은 transition의 기본값이다.
14
+ */
15
+ const easing = { out: "cubic-bezier(0, 0, 0.2, 1)" };
16
+
17
+ export { duration, easing };
@@ -0,0 +1,265 @@
1
+ import { ColorFamily, PrimitiveColorName } from "./color.js";
2
+ import { BackgroundSlot, ColorSlot, familyOverrides, slotRule } from "./colorSlot.js";
3
+ /** Theme 이름 */
4
+ export type ThemeName = "light" | "dark";
5
+ /**
6
+ * Primitive에 투명도를 더한 색. overlay, 무채색 호버(`bg-hover`·`bg-active`), shadow 색에만 쓰고, CSS에는 8자리 hex로 나간다.
7
+ */
8
+ export interface AlphaColor {
9
+ readonly primitive: PrimitiveColorName;
10
+ /** 0~1 */
11
+ readonly alpha: number;
12
+ }
13
+ /**
14
+ * Semantic Token 하나가 가리키는 값. `transparent`는 light raised border에만 쓴다(CSS에서도 `transparent` 키워드로 나간다).
15
+ */
16
+ export type SemanticColorValue = PrimitiveColorName | AlphaColor | MixedColor | "transparent";
17
+ /**
18
+ * 두 Primitive를 섞은 불투명한 색(ADR 0022의 덮기·섞기). `base` 위에 `mix`를 `amount`만큼 덮은 값이다.
19
+ * 빌드할 때 hex(`#rrggbb`)로 계산해 CSS에 넣는다. 예: blue-100 + gray-950 4%
20
+ */
21
+ export interface MixedColor {
22
+ readonly base: PrimitiveColorName;
23
+ readonly mix: PrimitiveColorName;
24
+ /** 0~1 */
25
+ readonly amount: number;
26
+ }
27
+ /** Theme별로 가리키는 값 */
28
+ export interface ThemedColor {
29
+ readonly light: SemanticColorValue;
30
+ readonly dark: SemanticColorValue;
31
+ }
32
+ /**
33
+ * Tide가 정한 Role 6개. 앱이 `RoleRegistry`에 더한 Role은 들어 있지 않다.
34
+ * Tide 안의 계산(Semantic Token 이름, 대비 쌍)은 이 타입을 쓴다. 앱 Role에는 Role Token이 생기지 않기 때문이다.
35
+ */
36
+ export type TideRole = "neutral" | "primary" | "success" | "warning" | "danger" | "info";
37
+ /**
38
+ * Role이 참조하는 Primitive 계열.
39
+ * @internal `@tide-design/foundation/internal` 전용. 앱 개발자용 공개 계약이 아니다(문서 앱·빌드 스크립트·테스트용).
40
+ */
41
+ export declare const roleFamily: {
42
+ readonly neutral: "gray";
43
+ readonly primary: "blue";
44
+ readonly success: "green";
45
+ readonly warning: "amber";
46
+ readonly danger: "red";
47
+ readonly info: "cyan";
48
+ };
49
+ /**
50
+ * Role별로 계열 규칙에서 덮어쓸 값.
51
+ * @internal `@tide-design/foundation/internal` 전용. 앱 개발자용 공개 계약이 아니다(문서 앱·빌드 스크립트·테스트용).
52
+ */
53
+ export declare const roleOverrides: {
54
+ readonly neutral: {
55
+ readonly subtle: {
56
+ readonly dark: 900;
57
+ };
58
+ readonly "subtle-hover": {
59
+ readonly dark: 800;
60
+ };
61
+ readonly "subtle-active": {
62
+ readonly dark: 700;
63
+ };
64
+ };
65
+ };
66
+ /**
67
+ * 역할 Token 대신 공통 Semantic Token을 쓰는 Role 슬롯. on-solid는 모든 Role이 `text-on-solid`를 쓴다.
68
+ * @internal `@tide-design/foundation/internal` 전용. 앱 개발자용 공개 계약이 아니다(문서 앱·빌드 스크립트·테스트용).
69
+ */
70
+ export declare const roleSharedSlots: {
71
+ readonly neutral: {
72
+ readonly text: "text-default";
73
+ readonly border: "border-strong";
74
+ readonly "on-subtle": "text-default";
75
+ };
76
+ };
77
+ /**
78
+ * Role 목록. Tide Role 6개가 들어 있고, 앱은 module augmentation으로 자기 Role(예: `brand`)을 더한다.
79
+ * 앱 Role의 색은 `@tide-design/foundation/color-family`의 `defineColorFamily`와 `tide-color build`로 만든다.
80
+ *
81
+ * ```ts
82
+ * declare module "@tide-design/components" {
83
+ * interface RoleRegistry {
84
+ * brand: true;
85
+ * }
86
+ * }
87
+ * ```
88
+ */
89
+ export interface RoleRegistry extends Record<TideRole, true> {}
90
+ /**
91
+ * Role. 뜻이 있는 색이다. 행동·의미 Component의 `color`로 고르고, `data-color` 속성으로 accent 슬롯에 꽂는다.
92
+ * Tide Role 6개와 앱이 `RoleRegistry`에 더한 Role이다.
93
+ */
94
+ export type Role = keyof RoleRegistry;
95
+ /**
96
+ * 색 계열 목록. Tide 색 계열 8개(장식 계열 purple·mint 포함)가 들어 있고, 앱은 module augmentation으로 장식용 계열을 더한다.
97
+ * Tide가 Primitive 계열을 더하면 이 목록도 함께 넓어진다.
98
+ *
99
+ * ```ts
100
+ * declare module "@tide-design/components" {
101
+ * interface ColorFamilyRegistry {
102
+ * brand: true;
103
+ * }
104
+ * }
105
+ * ```
106
+ */
107
+ export interface ColorFamilyRegistry extends Record<ColorFamily, true> {}
108
+ /**
109
+ * 색 계열 이름. 뜻이 없는 색이라 장식·분류 Component가 쓴다.
110
+ * Tide 색 계열(`ColorFamily`)과 앱이 `ColorFamilyRegistry`에 더한 계열이다.
111
+ */
112
+ export type ColorFamilyName = keyof ColorFamilyRegistry;
113
+ /** 색 이름(Color). `data-color` 속성이 받는 모든 이름이다(Role과 색 계열). */
114
+ export type Color = Role | ColorFamilyName;
115
+ type Lookup<Table, K1, K2, K3, Fallback> = K1 extends keyof Table ? K2 extends keyof Table[K1] ? K3 extends keyof Table[K1][K2] ? Table[K1][K2][K3] : Fallback : Fallback : Fallback;
116
+ type FamilyStep<Family, Slot extends ColorSlot, Theme extends ThemeName> = Lookup<typeof familyOverrides, Family, Slot, Theme, (typeof slotRule)[Slot][Theme]>;
117
+ type RoleStep<Name extends TideRole, Slot extends ColorSlot, Theme extends ThemeName> = Lookup<typeof roleOverrides, Name, Slot, Theme, FamilyStep<(typeof roleFamily)[Name], Slot, Theme>>;
118
+ type StepName<Family extends string, Step> = Step extends number ? `${Family}-${Step}` : Step extends string ? Step : MixedColor;
119
+ type RoleSlotColor<Name extends TideRole, Slot extends ColorSlot> = {
120
+ readonly light: StepName<(typeof roleFamily)[Name], RoleStep<Name, Slot, "light">>;
121
+ readonly dark: StepName<(typeof roleFamily)[Name], RoleStep<Name, Slot, "dark">>;
122
+ };
123
+ /** 그 슬롯을 공통 Token과 나눠 쓰지 않고 자기 Role Token을 가진 Role. 예: text는 neutral 제외 */
124
+ type OwnRole<Slot extends ColorSlot> = { [Name in TideRole]: Name extends keyof typeof roleSharedSlots ? Slot extends keyof (typeof roleSharedSlots)[Name] ? never : Name : Name; }[TideRole];
125
+ type RoleBackgroundTokens = { readonly [Key in `${TideRole}-${BackgroundSlot}`]: Key extends `${infer Name extends TideRole}-${infer Slot extends BackgroundSlot}` ? RoleSlotColor<Name, Slot> : never; };
126
+ type RoleTextTokens = { readonly [Name in OwnRole<"text">]: RoleSlotColor<Name, "text">; } & { readonly [Name in OwnRole<"on-subtle"> as `${Name}-on-subtle`]: RoleSlotColor<Name, "on-subtle">; };
127
+ type RoleBorderTokens = { readonly [Name in OwnRole<"border">]: RoleSlotColor<Name, "border">; } & { readonly [Name in OwnRole<"subtle-border"> as `${Name}-subtle`]: RoleSlotColor<Name, "subtle-border">; };
128
+ declare const commonBackground: {
129
+ readonly canvas: {
130
+ readonly light: "white";
131
+ readonly dark: "gray-950";
132
+ };
133
+ readonly surface: {
134
+ readonly light: "white";
135
+ readonly dark: "gray-950";
136
+ };
137
+ readonly raised: {
138
+ readonly light: "white";
139
+ readonly dark: "gray-900";
140
+ };
141
+ readonly disabled: {
142
+ readonly light: "gray-100";
143
+ readonly dark: "gray-900";
144
+ };
145
+ readonly overlay: {
146
+ readonly light: {
147
+ readonly primitive: "gray-950";
148
+ readonly alpha: 0.5;
149
+ };
150
+ readonly dark: {
151
+ readonly primitive: "gray-950";
152
+ readonly alpha: 0.7;
153
+ };
154
+ };
155
+ readonly hover: {
156
+ readonly light: {
157
+ readonly primitive: "gray-950";
158
+ readonly alpha: 0.04;
159
+ };
160
+ readonly dark: {
161
+ readonly primitive: "white";
162
+ readonly alpha: 0.06;
163
+ };
164
+ };
165
+ readonly active: {
166
+ readonly light: {
167
+ readonly primitive: "gray-950";
168
+ readonly alpha: 0.08;
169
+ };
170
+ readonly dark: {
171
+ readonly primitive: "white";
172
+ readonly alpha: 0.1;
173
+ };
174
+ };
175
+ };
176
+ declare const commonText: {
177
+ readonly default: {
178
+ readonly light: "gray-900";
179
+ readonly dark: "gray-50";
180
+ };
181
+ readonly muted: {
182
+ readonly light: "gray-700";
183
+ readonly dark: "gray-300";
184
+ };
185
+ readonly disabled: {
186
+ readonly light: "gray-400";
187
+ readonly dark: "gray-600";
188
+ };
189
+ readonly "on-solid": {
190
+ readonly light: "white";
191
+ readonly dark: "white";
192
+ };
193
+ };
194
+ declare const commonBorder: {
195
+ readonly default: {
196
+ readonly light: "gray-200";
197
+ readonly dark: "gray-800";
198
+ };
199
+ readonly strong: {
200
+ readonly light: "gray-500";
201
+ readonly dark: "gray-400";
202
+ };
203
+ readonly raised: {
204
+ readonly light: "transparent";
205
+ readonly dark: "gray-800";
206
+ };
207
+ };
208
+ declare const commonOutline: {
209
+ readonly focus: {
210
+ readonly light: "blue-600";
211
+ readonly dark: "blue-400";
212
+ };
213
+ };
214
+ export declare const semantic: {
215
+ readonly background: typeof commonBackground & RoleBackgroundTokens;
216
+ readonly text: typeof commonText & RoleTextTokens;
217
+ readonly border: typeof commonBorder & RoleBorderTokens;
218
+ readonly outline: typeof commonOutline;
219
+ };
220
+ /** Semantic namespace와 Utility class 접두사 */
221
+ export type SemanticNamespace = "background" | "text" | "border" | "outline";
222
+ export declare const semanticPrefix: {
223
+ readonly background: "bg";
224
+ readonly text: "text";
225
+ readonly border: "border";
226
+ readonly outline: "outline";
227
+ };
228
+ /** Semantic Token의 Utility class 이름. 예: `bg-primary-solid`, `text-muted` */
229
+ export type SemanticColorName = { [Namespace in SemanticNamespace]: `${(typeof semanticPrefix)[Namespace]}-${keyof (typeof semantic)[Namespace] & string}`; }[SemanticNamespace];
230
+ /**
231
+ * Theme별 shadow 색. CSS에서는 `--tide-shadow-color`로 쓴다.
232
+ * @internal `@tide-design/foundation/internal` 전용. 앱 개발자용 공개 계약이 아니다(문서 앱·빌드 스크립트·테스트용).
233
+ */
234
+ export declare const shadowColor: {
235
+ readonly light: {
236
+ readonly primitive: "gray-950";
237
+ readonly alpha: 0.08;
238
+ };
239
+ readonly dark: {
240
+ readonly primitive: "black";
241
+ readonly alpha: 0.3;
242
+ };
243
+ };
244
+ /**
245
+ * 모든 Semantic Token(namespace, Utility class 이름, Theme별 값).
246
+ * @internal `@tide-design/foundation/internal` 전용. 앱 개발자용 공개 계약이 아니다(문서 앱·빌드 스크립트·테스트용).
247
+ */
248
+ export declare function semanticEntries(): {
249
+ readonly namespace: SemanticNamespace;
250
+ readonly key: string;
251
+ readonly className: SemanticColorName;
252
+ readonly value: ThemedColor;
253
+ }[];
254
+ /**
255
+ * 값을 hex로 바꾼다. alpha가 있으면 8자리 hex(`#rrggbbaa`)다. `transparent`는 `#00000000`이다.
256
+ * 덮기·섞기(`MixedColor`)는 계산한 6자리 hex다.
257
+ * @internal `@tide-design/foundation/internal` 전용. 앱 개발자용 공개 계약이 아니다(문서 앱·빌드 스크립트·테스트용).
258
+ */
259
+ export declare function colorValueHex(value: SemanticColorValue): string;
260
+ /**
261
+ * Semantic Token이 Theme에서 가리키는 hex.
262
+ * @internal `@tide-design/foundation/internal` 전용. 앱 개발자용 공개 계약이 아니다(문서 앱·빌드 스크립트·테스트용).
263
+ */
264
+ export declare function semanticHex(name: SemanticColorName, theme: ThemeName): string;
265
+ export {};
@@ -0,0 +1,225 @@
1
+ import { primitiveHex } from "./color.js";
2
+ import { colorSlots, familyOverrides, mixHex, resolveSlotSteps, slotPrimitive } from "./colorSlot.js";
3
+
4
+ // src/semantic.ts
5
+ /**
6
+ * Role이 참조하는 Primitive 계열.
7
+ * @internal `@tide-design/foundation/internal` 전용. 앱 개발자용 공개 계약이 아니다(문서 앱·빌드 스크립트·테스트용).
8
+ */
9
+ const roleFamily = {
10
+ neutral: "gray",
11
+ primary: "blue",
12
+ success: "green",
13
+ warning: "amber",
14
+ danger: "red",
15
+ info: "cyan"
16
+ };
17
+ /**
18
+ * Role별로 계열 규칙에서 덮어쓸 값.
19
+ * @internal `@tide-design/foundation/internal` 전용. 앱 개발자용 공개 계약이 아니다(문서 앱·빌드 스크립트·테스트용).
20
+ */
21
+ const roleOverrides = { neutral: {
22
+ subtle: { dark: 900 },
23
+ "subtle-hover": { dark: 800 },
24
+ "subtle-active": { dark: 700 }
25
+ } };
26
+ /**
27
+ * 역할 Token 대신 공통 Semantic Token을 쓰는 Role 슬롯. on-solid는 모든 Role이 `text-on-solid`를 쓴다.
28
+ * @internal `@tide-design/foundation/internal` 전용. 앱 개발자용 공개 계약이 아니다(문서 앱·빌드 스크립트·테스트용).
29
+ */
30
+ const roleSharedSlots = { neutral: {
31
+ text: "text-default",
32
+ border: "border-strong",
33
+ "on-subtle": "text-default"
34
+ } };
35
+ /**
36
+ * 계열 슬롯 값을 Semantic 값으로 바꾼다. 단계는 Primitive 이름, 덮기·섞기는 `MixedColor`다.
37
+ * 예: (`blue`, 600) → `blue-600`, (`blue`, 100 + gray-950 4%) → `{ base: "blue-100", mix: "gray-950", amount: 0.04 }`
38
+ * @internal `@tide-design/foundation/internal` 전용. 앱 개발자용 공개 계약이 아니다(문서 앱·빌드 스크립트·테스트용).
39
+ */
40
+ function slotColorValue(family, value) {
41
+ const name = (ref) => slotPrimitive(family, ref);
42
+ if (typeof value !== "object") return name(value);
43
+ if ("mix" in value) return {
44
+ base: name(value.mix[0]),
45
+ mix: name(value.mix[1]),
46
+ amount: .5
47
+ };
48
+ return {
49
+ base: name(value.step),
50
+ mix: value.overlay,
51
+ amount: value.amount
52
+ };
53
+ }
54
+ const roles = Object.keys(roleFamily);
55
+ const backgroundSlots = colorSlots.filter((slot) => slot !== "text" && slot !== "border" && slot !== "subtle-border" && slot !== "on-solid" && slot !== "on-subtle");
56
+ /** 그 슬롯을 공통 Token과 나눠 쓰지 않는 Role */
57
+ function ownRoles(slot) {
58
+ const shared = roleSharedSlots;
59
+ return roles.filter((role) => !Object.hasOwn(shared[role] ?? {}, slot));
60
+ }
61
+ /** Role 슬롯이 가리키는 값. 계열 규칙 → 계열 덮어쓸 값 → Role 덮어쓸 값 순서로 얹는다. */
62
+ function roleSlotColor(role, slot) {
63
+ const family = roleFamily[role];
64
+ const steps = resolveSlotSteps(familyOverrides[family], roleOverrides[role])[slot];
65
+ return {
66
+ light: slotColorValue(family, steps.light),
67
+ dark: slotColorValue(family, steps.dark)
68
+ };
69
+ }
70
+ const commonBackground = {
71
+ canvas: {
72
+ light: "white",
73
+ dark: "gray-950"
74
+ },
75
+ surface: {
76
+ light: "white",
77
+ dark: "gray-950"
78
+ },
79
+ raised: {
80
+ light: "white",
81
+ dark: "gray-900"
82
+ },
83
+ disabled: {
84
+ light: "gray-100",
85
+ dark: "gray-900"
86
+ },
87
+ overlay: {
88
+ light: {
89
+ primitive: "gray-950",
90
+ alpha: .5
91
+ },
92
+ dark: {
93
+ primitive: "gray-950",
94
+ alpha: .7
95
+ }
96
+ },
97
+ hover: {
98
+ light: {
99
+ primitive: "gray-950",
100
+ alpha: .04
101
+ },
102
+ dark: {
103
+ primitive: "white",
104
+ alpha: .06
105
+ }
106
+ },
107
+ active: {
108
+ light: {
109
+ primitive: "gray-950",
110
+ alpha: .08
111
+ },
112
+ dark: {
113
+ primitive: "white",
114
+ alpha: .1
115
+ }
116
+ }
117
+ };
118
+ const commonText = {
119
+ default: {
120
+ light: "gray-900",
121
+ dark: "gray-50"
122
+ },
123
+ muted: {
124
+ light: "gray-700",
125
+ dark: "gray-300"
126
+ },
127
+ disabled: {
128
+ light: "gray-400",
129
+ dark: "gray-600"
130
+ },
131
+ "on-solid": {
132
+ light: "white",
133
+ dark: "white"
134
+ }
135
+ };
136
+ const commonBorder = {
137
+ default: {
138
+ light: "gray-200",
139
+ dark: "gray-800"
140
+ },
141
+ strong: {
142
+ light: "gray-500",
143
+ dark: "gray-400"
144
+ },
145
+ raised: {
146
+ light: "transparent",
147
+ dark: "gray-800"
148
+ }
149
+ };
150
+ const commonOutline = { focus: {
151
+ light: "blue-600",
152
+ dark: "blue-400"
153
+ } };
154
+ const semantic = {
155
+ background: {
156
+ ...commonBackground,
157
+ ...Object.fromEntries(roles.flatMap((role) => backgroundSlots.map((slot) => [`${role}-${slot}`, roleSlotColor(role, slot)])))
158
+ },
159
+ text: {
160
+ ...commonText,
161
+ ...Object.fromEntries(ownRoles("text").map((role) => [role, roleSlotColor(role, "text")])),
162
+ ...Object.fromEntries(ownRoles("on-subtle").map((role) => [`${role}-on-subtle`, roleSlotColor(role, "on-subtle")]))
163
+ },
164
+ border: {
165
+ ...commonBorder,
166
+ ...Object.fromEntries(ownRoles("border").map((role) => [role, roleSlotColor(role, "border")])),
167
+ ...Object.fromEntries(ownRoles("subtle-border").map((role) => [`${role}-subtle`, roleSlotColor(role, "subtle-border")]))
168
+ },
169
+ outline: commonOutline
170
+ };
171
+ const semanticPrefix = {
172
+ background: "bg",
173
+ text: "text",
174
+ border: "border",
175
+ outline: "outline"
176
+ };
177
+ /**
178
+ * Theme별 shadow 색. CSS에서는 `--tide-shadow-color`로 쓴다.
179
+ * @internal `@tide-design/foundation/internal` 전용. 앱 개발자용 공개 계약이 아니다(문서 앱·빌드 스크립트·테스트용).
180
+ */
181
+ const shadowColor = {
182
+ light: {
183
+ primitive: "gray-950",
184
+ alpha: .08
185
+ },
186
+ dark: {
187
+ primitive: "black",
188
+ alpha: .3
189
+ }
190
+ };
191
+ /**
192
+ * 모든 Semantic Token(namespace, Utility class 이름, Theme별 값).
193
+ * @internal `@tide-design/foundation/internal` 전용. 앱 개발자용 공개 계약이 아니다(문서 앱·빌드 스크립트·테스트용).
194
+ */
195
+ function semanticEntries() {
196
+ return Object.keys(semantic).flatMap((namespace) => Object.entries(semantic[namespace]).map(([key, value]) => ({
197
+ namespace,
198
+ key,
199
+ className: `${semanticPrefix[namespace]}-${key}`,
200
+ value
201
+ })));
202
+ }
203
+ /**
204
+ * 값을 hex로 바꾼다. alpha가 있으면 8자리 hex(`#rrggbbaa`)다. `transparent`는 `#00000000`이다.
205
+ * 덮기·섞기(`MixedColor`)는 계산한 6자리 hex다.
206
+ * @internal `@tide-design/foundation/internal` 전용. 앱 개발자용 공개 계약이 아니다(문서 앱·빌드 스크립트·테스트용).
207
+ */
208
+ function colorValueHex(value) {
209
+ if (value === "transparent") return "#00000000";
210
+ if (typeof value === "string") return primitiveHex(value);
211
+ if ("base" in value) return mixHex(primitiveHex(value.base), primitiveHex(value.mix), value.amount);
212
+ const alpha = Math.round(value.alpha * 255).toString(16).padStart(2, "0");
213
+ return `${primitiveHex(value.primitive)}${alpha}`;
214
+ }
215
+ /**
216
+ * Semantic Token이 Theme에서 가리키는 hex.
217
+ * @internal `@tide-design/foundation/internal` 전용. 앱 개발자용 공개 계약이 아니다(문서 앱·빌드 스크립트·테스트용).
218
+ */
219
+ function semanticHex(name, theme) {
220
+ const entry = semanticEntries().find((candidate) => candidate.className === name);
221
+ if (!entry) throw new Error(`Semantic Token이 아니다: ${name}`);
222
+ return colorValueHex(entry.value[theme]);
223
+ }
224
+
225
+ export { colorValueHex, roleFamily, roleOverrides, roleSharedSlots, semantic, semanticEntries, semanticHex, semanticPrefix, shadowColor, slotColorValue };
@@ -0,0 +1,89 @@
1
+ /**
2
+ * radius 5단계. `rounded-<이름>` class와 공개 계약 `--tide-rounded-<이름>`이 쓴다.
3
+ * - sm: 작은 표시 요소, 목록 안 항목
4
+ * - md: 조작 요소(모든 size)
5
+ * - lg: 담는 요소(Card, Alert, Popover, 목록, Toast, Accordion)
6
+ * - xl: Dialog류
7
+ * - full: 원·알약형
8
+ */
9
+ export declare const radius: {
10
+ readonly sm: "0.25rem";
11
+ readonly md: "0.375rem";
12
+ readonly lg: "0.5rem";
13
+ readonly xl: "0.75rem";
14
+ readonly full: "9999px";
15
+ };
16
+ /** radius 단계 이름 */
17
+ export type RadiusName = keyof typeof radius;
18
+ /** 그림자 레이어 하나. 길이는 px, `mix`는 `--tide-shadow-color`를 남기는 비율(%)이다. */
19
+ export interface ShadowLayer {
20
+ readonly x: number;
21
+ readonly y: number;
22
+ readonly blur: number;
23
+ readonly spread: number;
24
+ readonly mix: number;
25
+ }
26
+ /**
27
+ * Elevation 3단계. 각 단계는 [가까운 레이어, 먼 레이어]다. 값은 spec 표를 그대로 옮겼다.
28
+ * `shadow-<이름>` class와 공개 계약 `--tide-shadow-<이름>`이 쓴다. Theme에 따라 `--tide-shadow-color`만 바뀐다.
29
+ * - sm: Switch thumb
30
+ * - md: Popover, 목록, Tooltip, Toast
31
+ * - lg: Dialog류
32
+ */
33
+ export declare const shadow: {
34
+ readonly sm: readonly [{
35
+ readonly x: 0;
36
+ readonly y: 1;
37
+ readonly blur: 1;
38
+ readonly spread: 0;
39
+ readonly mix: 60;
40
+ }, {
41
+ readonly x: 0;
42
+ readonly y: 1;
43
+ readonly blur: 2;
44
+ readonly spread: 0;
45
+ readonly mix: 100;
46
+ }];
47
+ readonly md: readonly [{
48
+ readonly x: 0;
49
+ readonly y: 1;
50
+ readonly blur: 3;
51
+ readonly spread: 0;
52
+ readonly mix: 50;
53
+ }, {
54
+ readonly x: 0;
55
+ readonly y: 4;
56
+ readonly blur: 12;
57
+ readonly spread: -2;
58
+ readonly mix: 100;
59
+ }];
60
+ readonly lg: readonly [{
61
+ readonly x: 0;
62
+ readonly y: 2;
63
+ readonly blur: 6;
64
+ readonly spread: -1;
65
+ readonly mix: 50;
66
+ }, {
67
+ readonly x: 0;
68
+ readonly y: 12;
69
+ readonly blur: 24;
70
+ readonly spread: -6;
71
+ readonly mix: 100;
72
+ }];
73
+ };
74
+ /** Elevation 단계 이름 */
75
+ export type ShadowName = keyof typeof shadow;
76
+ /**
77
+ * 포커스 표시 ring의 두께와 offset. 공개 계약은 `--tide-focus-ring-width`, `--tide-focus-ring-offset`이다.
78
+ * `focus-ring` utility가 쓰고, `focus-field`의 투명 outline(forced-colors 전용) 두께도 같은 값을 쓴다.
79
+ */
80
+ export declare const focusRing: {
81
+ readonly width: "2px";
82
+ readonly offset: "2px";
83
+ };
84
+ /**
85
+ * Elevation 단계를 CSS `box-shadow` 값으로 만든다. 두 레이어 모두
86
+ * `color-mix(in srgb, var(--tide-shadow-color) N%, transparent)`로 색을 낮춘다(100%도 같은 형태로 쓴다).
87
+ * @internal `@tide-design/foundation/internal` 전용. 앱 개발자용 공개 계약이 아니다(문서 앱·빌드 스크립트·테스트용).
88
+ */
89
+ export declare function shadowCss(name: ShadowName): string;