feat: FoxTextButton·FoxLinkButton·FoxIconButton 추가
Figma btn-txt(106:2468) · btn-lnk(107:207) · btn-ico(400:6312) · btn-ico-toggle(404:5247)을 토큰만으로 옮긴다. 컴파일된 CSS에 원시 hex/px/rem 리터럴은 0건이다. btn-ico와 btn-ico-toggle은 계열·크기·모양이 같고 켜짐 상태만 달라 FoxIconButton 하나로 합쳤다. 켜짐은 `aria-pressed`로 표시해 스타일 훅과 접근성 표시를 겸한다. 시안에 켜짐과 hover가 겹치는 조합이 없어(상태가 단일 축이다) 켜진 동안에는 켜짐 색이 유지된다. FoxLinkButton은 href가 있으면 , 없으면
@27bbef71be2dd252b9f7349eccbe3ecb358343a3
--- @fox/README.md
+++ @fox/README.md
... | ... | @@ -8,7 +8,7 @@ |
| 8 | 8 |
styles/ SCSS — 여기가 디자인의 전부입니다 |
| 9 | 9 |
index.scss 토큰 진입점 (앱이 한 번 @use) |
| 10 | 10 |
components.scss 공용 컴포넌트 스타일 묶음 진입점 |
| 11 |
- _fox-button.scss 컴포넌트별 스타일 (개별 @use 가능) |
|
| 11 |
+ _fox-*.scss 컴포넌트별 스타일 (개별 @use 가능) |
|
| 12 | 12 |
abstracts.scss 저작 진입점 — 함수·믹스인 (CSS 출력 0) |
| 13 | 13 |
tokens/ 토큰 map = 단일 진실 공급원 (자동 생성) |
| 14 | 14 |
_root.scss map → --fox-* 커스텀 프로퍼티 |
... | ... | @@ -69,7 +69,7 @@ |
| 69 | 69 |
클래스명이 `fox-` 접두사 + BEM이라 전역에 풀어도 충돌하지 않습니다. Vue·Svelte·서버 |
| 70 | 70 |
템플릿·순수 HTML 어디서든 위 2~4번만 하고 마크업 계약을 지키면 같은 결과가 나옵니다. |
| 71 | 71 |
|
| 72 |
-각 컴포넌트의 **마크업 계약은 해당 스타일 파일 상단 주석**에 있습니다. 버튼은 이렇습니다. |
|
| 72 |
+각 컴포넌트의 **마크업 계약은 해당 스타일 파일 상단 주석**에 있습니다. 버튼 네 종류는 이렇습니다. |
|
| 73 | 73 |
|
| 74 | 74 |
```html |
| 75 | 75 |
<button class="fox-button fox-button--primary fox-button--md"> |
... | ... | @@ -77,10 +77,25 @@ |
| 77 | 77 |
<span class="fox-button__label">버튼</span> |
| 78 | 78 |
<span class="fox-button__icon"><!-- svg (선택) --></span> |
| 79 | 79 |
</button> |
| 80 |
+ |
|
| 81 |
+<button class="fox-text-button fox-text-button--primary fox-text-button--md"> |
|
| 82 |
+ <span class="fox-text-button__label">텍스트 버튼</span> |
|
| 83 |
+</button> |
|
| 84 |
+ |
|
| 85 |
+<a href="…" class="fox-link-button fox-link-button--primary fox-link-button--md"> |
|
| 86 |
+ <span class="fox-link-button__label">링크</span> |
|
| 87 |
+ <span class="fox-link-button__icon"><!-- svg (선택, 항상 라벨 뒤) --></span> |
|
| 88 |
+</a> |
|
| 89 |
+ |
|
| 90 |
+<button class="fox-icon-button fox-icon-button--ghost fox-icon-button--md" aria-label="공유"> |
|
| 91 |
+ <span class="fox-icon-button__icon"><!-- svg --></span> |
|
| 92 |
+</button> |
|
| 80 | 93 |
``` |
| 81 | 94 |
|
| 82 |
-- 비활성은 네이티브 `disabled` 속성으로 표현합니다(별도 클래스 없음). |
|
| 95 |
+- 비활성은 네이티브 `disabled` 속성으로 표현합니다(별도 클래스 없음). 앵커에는 `disabled`가 |
|
| 96 |
+ 없으므로 `aria-disabled="true"`를 쓰고 `href`를 뺍니다. |
|
| 83 | 97 |
- 로딩은 앞 아이콘 자리에 `fox-button__spinner`를 두고 `disabled`를 함께 겁니다. |
| 98 |
+- 토글은 `fox-icon-button`에 `aria-pressed="true|false"`를 더합니다. |
|
| 84 | 99 |
- 아이콘 SVG는 `currentColor`로 그려야 계열별 색이 적용됩니다. 크기는 슬롯이 정합니다. |
| 85 | 100 |
|
| 86 | 101 |
`core/`의 React 컴포넌트는 이 클래스를 조립해주는 **얇은 래퍼**일 뿐입니다 — 쓰지 않아도 |
--- @fox/core/components/index.ts
+++ @fox/core/components/index.ts
... | ... | @@ -1,1 +1,4 @@ |
| 1 | 1 |
export * from "./fox-button"; |
| 2 |
+export * from "./fox-text-button"; |
|
| 3 |
+export * from "./fox-link-button"; |
|
| 4 |
+export * from "./fox-icon-button"; |
--- @fox/dev-test/component-registry.tsx
+++ @fox/dev-test/component-registry.tsx
... | ... | @@ -1,5 +1,10 @@ |
| 1 |
-import type { ReactNode } from "react";
|
|
| 1 |
+"use client"; |
|
| 2 |
+ |
|
| 3 |
+import { useState, type ReactNode } from "react";
|
|
| 2 | 4 |
import { FoxButton } from "../core/components/fox-button";
|
| 5 |
+import { FoxTextButton } from "../core/components/fox-text-button";
|
|
| 6 |
+import { FoxLinkButton } from "../core/components/fox-link-button";
|
|
| 7 |
+import { FoxIconButton } from "../core/components/fox-icon-button";
|
|
| 3 | 8 |
|
| 4 | 9 |
export interface ComponentExample {
|
| 5 | 10 |
/** 해시 링크에 쓰이는 kebab-case 식별자. */ |
... | ... | @@ -16,6 +21,67 @@ |
| 16 | 21 |
<svg viewBox="0 0 16 16" fill="none" stroke="currentColor" strokeWidth="2" aria-hidden="true"> |
| 17 | 22 |
<path d="M6 3l5 5-5 5" /> |
| 18 | 23 |
</svg> |
| 24 |
+ ); |
|
| 25 |
+} |
|
| 26 |
+ |
|
| 27 |
+function DemoStar() {
|
|
| 28 |
+ return ( |
|
| 29 |
+ <svg viewBox="0 0 16 16" fill="currentColor" aria-hidden="true"> |
|
| 30 |
+ <path d="M8 1.6l1.9 4 4.4.6-3.2 3 .8 4.3L8 11.5l-3.9 2 .8-4.3-3.2-3 4.4-.6z" /> |
|
| 31 |
+ </svg> |
|
| 32 |
+ ); |
|
| 33 |
+} |
|
| 34 |
+ |
|
| 35 |
+// overlay 계열은 어두운 반투명 배경이라 밝은 바탕 위에서는 대비를 볼 수 없다. |
|
| 36 |
+function OnPhoto({ children }: { children: ReactNode }) {
|
|
| 37 |
+ return ( |
|
| 38 |
+ <span |
|
| 39 |
+ style={{
|
|
| 40 |
+ display: "inline-flex", |
|
| 41 |
+ gap: "0.8rem", |
|
| 42 |
+ padding: "0.8rem", |
|
| 43 |
+ borderRadius: "0.8rem", |
|
| 44 |
+ backgroundImage: "url(https://picsum.photos/seed/picsum/200/300)", |
|
| 45 |
+ backgroundSize: "cover", |
|
| 46 |
+ }} |
|
| 47 |
+ > |
|
| 48 |
+ {children}
|
|
| 49 |
+ </span> |
|
| 50 |
+ ); |
|
| 51 |
+} |
|
| 52 |
+ |
|
| 53 |
+// active는 호출부가 소유하므로 켜고 끄는 걸 보려면 예제가 상태를 들고 있어야 한다. |
|
| 54 |
+function IconToggleDemo() {
|
|
| 55 |
+ const [on, setOn] = useState(false); |
|
| 56 |
+ return ( |
|
| 57 |
+ <> |
|
| 58 |
+ <FoxIconButton |
|
| 59 |
+ size="md" |
|
| 60 |
+ type="default" |
|
| 61 |
+ label={on ? "즐겨찾기 해제" : "즐겨찾기"}
|
|
| 62 |
+ icon={<DemoStar />}
|
|
| 63 |
+ active={on}
|
|
| 64 |
+ onAction={() => setOn((prev) => !prev)}
|
|
| 65 |
+ /> |
|
| 66 |
+ <FoxIconButton |
|
| 67 |
+ size="md" |
|
| 68 |
+ type="ghost" |
|
| 69 |
+ label={on ? "즐겨찾기 해제" : "즐겨찾기"}
|
|
| 70 |
+ icon={<DemoStar />}
|
|
| 71 |
+ active={on}
|
|
| 72 |
+ onAction={() => setOn((prev) => !prev)}
|
|
| 73 |
+ /> |
|
| 74 |
+ <OnPhoto> |
|
| 75 |
+ <FoxIconButton |
|
| 76 |
+ size="md" |
|
| 77 |
+ type="overlay" |
|
| 78 |
+ label={on ? "즐겨찾기 해제" : "즐겨찾기"}
|
|
| 79 |
+ icon={<DemoStar />}
|
|
| 80 |
+ active={on}
|
|
| 81 |
+ onAction={() => setOn((prev) => !prev)}
|
|
| 82 |
+ /> |
|
| 83 |
+ </OnPhoto> |
|
| 84 |
+ </> |
|
| 19 | 85 |
); |
| 20 | 86 |
} |
| 21 | 87 |
|
... | ... | @@ -90,4 +156,199 @@ |
| 90 | 156 |
}, |
| 91 | 157 |
], |
| 92 | 158 |
}, |
| 159 |
+ {
|
|
| 160 |
+ id: "fox-text-button", |
|
| 161 |
+ name: "FoxTextButton", |
|
| 162 |
+ description: |
|
| 163 |
+ "Figma 시안(btn-txt, 컴포넌트 세트 106:2468)을 토큰만으로 옮겼습니다. 높이를 고정하지 않고 패딩과 line-height로만 크기를 잡습니다. lg만 상하 패딩과 간격이 한 단계 넓습니다.", |
|
| 164 |
+ variants: [ |
|
| 165 |
+ {
|
|
| 166 |
+ label: "계열 (type) — primary는 굵기가 한 단계 더 굵다", |
|
| 167 |
+ node: ( |
|
| 168 |
+ <> |
|
| 169 |
+ <FoxTextButton size="md" type="primary" label="primary" /> |
|
| 170 |
+ <FoxTextButton size="md" type="secondary" label="secondary" /> |
|
| 171 |
+ </> |
|
| 172 |
+ ), |
|
| 173 |
+ }, |
|
| 174 |
+ {
|
|
| 175 |
+ label: "크기 (size)", |
|
| 176 |
+ node: ( |
|
| 177 |
+ <> |
|
| 178 |
+ <FoxTextButton size="lg" label="lg" /> |
|
| 179 |
+ <FoxTextButton size="md" label="md" /> |
|
| 180 |
+ <FoxTextButton size="sm" label="sm" /> |
|
| 181 |
+ <FoxTextButton size="xsm" label="xsm" /> |
|
| 182 |
+ </> |
|
| 183 |
+ ), |
|
| 184 |
+ }, |
|
| 185 |
+ {
|
|
| 186 |
+ label: "아이콘", |
|
| 187 |
+ node: ( |
|
| 188 |
+ <> |
|
| 189 |
+ <FoxTextButton size="md" label="leading" leadingIcon={<DemoIcon />} />
|
|
| 190 |
+ <FoxTextButton size="md" label="trailing" trailingIcon={<DemoIcon />} />
|
|
| 191 |
+ <FoxTextButton |
|
| 192 |
+ size="md" |
|
| 193 |
+ label="both" |
|
| 194 |
+ leadingIcon={<DemoIcon />}
|
|
| 195 |
+ trailingIcon={<DemoIcon />}
|
|
| 196 |
+ /> |
|
| 197 |
+ </> |
|
| 198 |
+ ), |
|
| 199 |
+ }, |
|
| 200 |
+ {
|
|
| 201 |
+ label: "상태 — disabled", |
|
| 202 |
+ node: ( |
|
| 203 |
+ <> |
|
| 204 |
+ <FoxTextButton size="md" label="normal" onAction={() => undefined} />
|
|
| 205 |
+ <FoxTextButton size="md" label="disabled" disabled /> |
|
| 206 |
+ <FoxTextButton size="md" type="secondary" label="disabled (secondary)" disabled /> |
|
| 207 |
+ </> |
|
| 208 |
+ ), |
|
| 209 |
+ }, |
|
| 210 |
+ ], |
|
| 211 |
+ }, |
|
| 212 |
+ {
|
|
| 213 |
+ id: "fox-link-button", |
|
| 214 |
+ name: "FoxLinkButton", |
|
| 215 |
+ description: |
|
| 216 |
+ "Figma 시안(btn-lnk, 컴포넌트 세트 107:207)을 토큰만으로 옮겼습니다. href를 주면 <a>, 없으면 <button>으로 렌더합니다. 방문 색은 브라우저가 실제 방문 기록으로만 켜므로 아래에서 링크를 한 번 눌러 돌아오면 색이 바뀝니다. tertiary만 평소에 밑줄이 없고 hover에서만 생깁니다.", |
|
| 217 |
+ variants: [ |
|
| 218 |
+ {
|
|
| 219 |
+ label: "계열 (type) — hover하면 tertiary에 밑줄이 생긴다", |
|
| 220 |
+ node: ( |
|
| 221 |
+ <> |
|
| 222 |
+ <FoxLinkButton size="md" type="primary" label="primary" href="https://example.com" /> |
|
| 223 |
+ <FoxLinkButton |
|
| 224 |
+ size="md" |
|
| 225 |
+ type="secondary" |
|
| 226 |
+ label="secondary" |
|
| 227 |
+ href="https://example.com" |
|
| 228 |
+ /> |
|
| 229 |
+ <FoxLinkButton size="md" type="tertiary" label="tertiary" href="https://example.com" /> |
|
| 230 |
+ </> |
|
| 231 |
+ ), |
|
| 232 |
+ }, |
|
| 233 |
+ {
|
|
| 234 |
+ label: "크기 (size)", |
|
| 235 |
+ node: ( |
|
| 236 |
+ <> |
|
| 237 |
+ <FoxLinkButton size="lg" label="lg" href="https://example.com" /> |
|
| 238 |
+ <FoxLinkButton size="md" label="md" href="https://example.com" /> |
|
| 239 |
+ <FoxLinkButton size="sm" label="sm" href="https://example.com" /> |
|
| 240 |
+ </> |
|
| 241 |
+ ), |
|
| 242 |
+ }, |
|
| 243 |
+ {
|
|
| 244 |
+ label: "아이콘 — 라벨 뒤에만 놓인다", |
|
| 245 |
+ node: ( |
|
| 246 |
+ <> |
|
| 247 |
+ <FoxLinkButton size="lg" label="lg" href="https://example.com" icon={<DemoIcon />} />
|
|
| 248 |
+ <FoxLinkButton size="md" label="md" href="https://example.com" icon={<DemoIcon />} />
|
|
| 249 |
+ <FoxLinkButton size="sm" label="sm" href="https://example.com" icon={<DemoIcon />} />
|
|
| 250 |
+ </> |
|
| 251 |
+ ), |
|
| 252 |
+ }, |
|
| 253 |
+ {
|
|
| 254 |
+ label: "href 없음 — <button>으로 렌더된다(방문 색이 켜지지 않는다)", |
|
| 255 |
+ node: ( |
|
| 256 |
+ <> |
|
| 257 |
+ <FoxLinkButton size="md" label="onAction만" onAction={() => undefined} />
|
|
| 258 |
+ <FoxLinkButton size="md" type="tertiary" label="tertiary" onAction={() => undefined} />
|
|
| 259 |
+ </> |
|
| 260 |
+ ), |
|
| 261 |
+ }, |
|
| 262 |
+ {
|
|
| 263 |
+ label: "상태 — disabled (앵커는 href가 빠져 포커스·클릭이 함께 사라진다)", |
|
| 264 |
+ node: ( |
|
| 265 |
+ <> |
|
| 266 |
+ <FoxLinkButton size="md" label="disabled (a)" href="https://example.com" disabled /> |
|
| 267 |
+ <FoxLinkButton size="md" label="disabled (button)" disabled /> |
|
| 268 |
+ </> |
|
| 269 |
+ ), |
|
| 270 |
+ }, |
|
| 271 |
+ ], |
|
| 272 |
+ }, |
|
| 273 |
+ {
|
|
| 274 |
+ id: "fox-icon-button", |
|
| 275 |
+ name: "FoxIconButton", |
|
| 276 |
+ description: |
|
| 277 |
+ "Figma 시안(btn-ico 400:6312 + btn-ico-toggle 404:5247)을 토큰만으로 옮겼습니다. 두 시안이 계열·크기·모양이 같고 켜짐 상태만 달라 한 컴포넌트로 합쳤습니다 — active를 주면 토글(aria-pressed)이 됩니다. ghost는 테두리가 없는 대신 아이콘이 한 단계 큽니다.", |
|
| 278 |
+ variants: [ |
|
| 279 |
+ {
|
|
| 280 |
+ label: "계열 (type) — overlay는 사진 위에서 봐야 한다", |
|
| 281 |
+ node: ( |
|
| 282 |
+ <> |
|
| 283 |
+ <FoxIconButton size="md" type="default" label="default" icon={<DemoIcon />} />
|
|
| 284 |
+ <FoxIconButton size="md" type="ghost" label="ghost" icon={<DemoIcon />} />
|
|
| 285 |
+ <OnPhoto> |
|
| 286 |
+ <FoxIconButton size="md" type="overlay" label="overlay" icon={<DemoIcon />} />
|
|
| 287 |
+ </OnPhoto> |
|
| 288 |
+ </> |
|
| 289 |
+ ), |
|
| 290 |
+ }, |
|
| 291 |
+ {
|
|
| 292 |
+ label: "크기 (size) — default 계열", |
|
| 293 |
+ node: ( |
|
| 294 |
+ <> |
|
| 295 |
+ <FoxIconButton size="lg" label="lg" icon={<DemoIcon />} />
|
|
| 296 |
+ <FoxIconButton size="md" label="md" icon={<DemoIcon />} />
|
|
| 297 |
+ <FoxIconButton size="sm" label="sm" icon={<DemoIcon />} />
|
|
| 298 |
+ <FoxIconButton size="xsm" label="xsm" icon={<DemoIcon />} />
|
|
| 299 |
+ </> |
|
| 300 |
+ ), |
|
| 301 |
+ }, |
|
| 302 |
+ {
|
|
| 303 |
+ label: "크기 (size) — ghost는 같은 상자에 아이콘만 한 단계 크다", |
|
| 304 |
+ node: ( |
|
| 305 |
+ <> |
|
| 306 |
+ <FoxIconButton size="lg" type="ghost" label="lg" icon={<DemoIcon />} />
|
|
| 307 |
+ <FoxIconButton size="md" type="ghost" label="md" icon={<DemoIcon />} />
|
|
| 308 |
+ <FoxIconButton size="sm" type="ghost" label="sm" icon={<DemoIcon />} />
|
|
| 309 |
+ <FoxIconButton size="xsm" type="ghost" label="xsm" icon={<DemoIcon />} />
|
|
| 310 |
+ </> |
|
| 311 |
+ ), |
|
| 312 |
+ }, |
|
| 313 |
+ {
|
|
| 314 |
+ label: "토글 — 눌러서 켜고 끈다 (active)", |
|
| 315 |
+ node: <IconToggleDemo />, |
|
| 316 |
+ }, |
|
| 317 |
+ {
|
|
| 318 |
+ label: "토글 켜짐 고정 — 계열별 색 비교", |
|
| 319 |
+ node: ( |
|
| 320 |
+ <> |
|
| 321 |
+ <FoxIconButton size="md" type="default" label="on" icon={<DemoStar />} active />
|
|
| 322 |
+ <FoxIconButton size="md" type="ghost" label="on" icon={<DemoStar />} active />
|
|
| 323 |
+ <OnPhoto> |
|
| 324 |
+ <FoxIconButton size="md" type="overlay" label="on" icon={<DemoStar />} active />
|
|
| 325 |
+ </OnPhoto> |
|
| 326 |
+ </> |
|
| 327 |
+ ), |
|
| 328 |
+ }, |
|
| 329 |
+ {
|
|
| 330 |
+ label: "상태 — disabled (켜짐보다 우선한다)", |
|
| 331 |
+ node: ( |
|
| 332 |
+ <> |
|
| 333 |
+ <FoxIconButton size="md" label="disabled" icon={<DemoIcon />} disabled />
|
|
| 334 |
+ <FoxIconButton size="md" type="ghost" label="disabled" icon={<DemoIcon />} disabled />
|
|
| 335 |
+ <FoxIconButton |
|
| 336 |
+ size="md" |
|
| 337 |
+ type="overlay" |
|
| 338 |
+ label="disabled" |
|
| 339 |
+ icon={<DemoIcon />}
|
|
| 340 |
+ disabled |
|
| 341 |
+ /> |
|
| 342 |
+ <FoxIconButton |
|
| 343 |
+ size="md" |
|
| 344 |
+ label="active + disabled" |
|
| 345 |
+ icon={<DemoStar />}
|
|
| 346 |
+ active |
|
| 347 |
+ disabled |
|
| 348 |
+ /> |
|
| 349 |
+ </> |
|
| 350 |
+ ), |
|
| 351 |
+ }, |
|
| 352 |
+ ], |
|
| 353 |
+ }, |
|
| 93 | 354 |
]; |
--- @fox/styles/components.scss
+++ @fox/styles/components.scss
... | ... | @@ -2,3 +2,6 @@ |
| 2 | 2 |
// 직접 @use 한다. 둘을 같이 써도 Sass가 모듈을 한 번만 로드해 중복되지 않는다. |
| 3 | 3 |
|
| 4 | 4 |
@use "fox-button"; |
| 5 |
+@use "fox-text-button"; |
|
| 6 |
+@use "fox-link-button"; |
|
| 7 |
+@use "fox-icon-button"; |
Add a comment
Delete comment
Once you delete this comment, you won't be able to recover it. Are you sure you want to delete this comment?