@finhay-pro/leaf-design-system 0.1.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.
- package/README.md +342 -0
- package/dist/button.css +174 -0
- package/dist/cdn/leaf-0.1.1.min.css +2 -0
- package/dist/cdn/leaf-0.1.1.min.js +2 -0
- package/dist/classes.css +681 -0
- package/dist/color.css +191 -0
- package/dist/components/Button/Button.d.ts +33 -0
- package/dist/components/Button/Button.d.ts.map +1 -0
- package/dist/components/Button/Button.js +26 -0
- package/dist/components/Button/Button.js.map +1 -0
- package/dist/components/Button/index.d.ts +2 -0
- package/dist/components/Button/index.d.ts.map +1 -0
- package/dist/components/Button/index.js +2 -0
- package/dist/components/Button/index.js.map +1 -0
- package/dist/components/Tabs/Tabs.d.ts +37 -0
- package/dist/components/Tabs/Tabs.d.ts.map +1 -0
- package/dist/components/Tabs/Tabs.js +44 -0
- package/dist/components/Tabs/Tabs.js.map +1 -0
- package/dist/components/Tabs/index.d.ts +2 -0
- package/dist/components/Tabs/index.d.ts.map +1 -0
- package/dist/components/Tabs/index.js +2 -0
- package/dist/components/Tabs/index.js.map +1 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +9 -0
- package/dist/index.js.map +1 -0
- package/dist/styles.css +914 -0
- package/dist/tabs.css +189 -0
- package/dist/tokens.css +234 -0
- package/dist/typography.css +130 -0
- package/dist/utils/joinClass.d.ts +3 -0
- package/dist/utils/joinClass.d.ts.map +1 -0
- package/dist/utils/joinClass.js +5 -0
- package/dist/utils/joinClass.js.map +1 -0
- package/package.json +55 -0
package/README.md
ADDED
|
@@ -0,0 +1,342 @@
|
|
|
1
|
+
# @finhay-pro/leaf-design-system
|
|
2
|
+
|
|
3
|
+
Design system của Finhay dưới dạng **CSS class dùng sẵn**. Mọi style đều đọc từ CSS variables trong
|
|
4
|
+
[`@finhay/leaf-tokens`](../tokens) — không hard-code giá trị nào.
|
|
5
|
+
|
|
6
|
+
Package không export component cho typography và color: bạn viết thẳng thẻ HTML của mình và gắn
|
|
7
|
+
class, nên dùng được ở mọi nơi (React, Next.js, Vue, HTML thuần, template của thư viện khác) mà
|
|
8
|
+
không phải bọc thêm một lớp component hay truyền props.
|
|
9
|
+
|
|
10
|
+
Landing page HTML tĩnh (không có bundler) dùng bản CDN: 1 thẻ `<link>` + 1 thẻ `<script>` — xem
|
|
11
|
+
[HTML tĩnh (CDN)](#html-tĩnh-cdn).
|
|
12
|
+
|
|
13
|
+
## Cài đặt
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
pnpm add @finhay-pro/leaf-design-system
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Import CSS (bắt buộc, làm một lần ở entry của app)
|
|
20
|
+
|
|
21
|
+
Class chỉ đọc `var(--…)`, không tự khai báo giá trị — nên **luôn import `tokens.css` trước**, rồi
|
|
22
|
+
chọn phần class cần dùng.
|
|
23
|
+
|
|
24
|
+
| Import | Nội dung |
|
|
25
|
+
| ------------------------------------------- | ----------------------------------------------------------- |
|
|
26
|
+
| `@finhay-pro/leaf-design-system/tokens.css` | Chỉ token (primitive + semantic + typography), không class. |
|
|
27
|
+
| `@finhay-pro/leaf-design-system/typography.css` | Chỉ class typography. |
|
|
28
|
+
| `@finhay-pro/leaf-design-system/color.css` | Chỉ class color. |
|
|
29
|
+
| `@finhay-pro/leaf-design-system/button.css` | Style của component `Button`. |
|
|
30
|
+
| `@finhay-pro/leaf-design-system/tabs.css` | Style của component `Tabs` / `Tab`. |
|
|
31
|
+
| `@finhay-pro/leaf-design-system/classes.css` | Tất cả class + component, không token. |
|
|
32
|
+
| `@finhay-pro/leaf-design-system/styles.css` | Token + tất cả class + component. Một dòng là đủ. |
|
|
33
|
+
|
|
34
|
+
Trong app dùng Tailwind v4, import bằng CSS, **sau** `@import "tailwindcss"`:
|
|
35
|
+
|
|
36
|
+
```css
|
|
37
|
+
@import "tailwindcss";
|
|
38
|
+
|
|
39
|
+
/* 1. Token — luôn đứng đầu */
|
|
40
|
+
@import "@finhay-pro/leaf-design-system/tokens.css";
|
|
41
|
+
|
|
42
|
+
/* 2. Bộ class nền tảng */
|
|
43
|
+
@import "@finhay-pro/leaf-design-system/typography.css";
|
|
44
|
+
@import "@finhay-pro/leaf-design-system/color.css";
|
|
45
|
+
|
|
46
|
+
/* 3. Component nào dùng thì import cái đó */
|
|
47
|
+
@import "@finhay-pro/leaf-design-system/button.css";
|
|
48
|
+
@import "@finhay-pro/leaf-design-system/tabs.css";
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
Muốn gọn thì một dòng `@import "@finhay-pro/leaf-design-system/styles.css";` thay cho cả khối trên.
|
|
52
|
+
|
|
53
|
+
Component đọc thẳng token chứ không dùng class color, nên `tokens.css` + `typography.css` + CSS của
|
|
54
|
+
component là đủ để component hiển thị đúng. App đang giữ bộ màu riêng (vd. `@theme` của Tailwind)
|
|
55
|
+
có thể bỏ `color.css` để không bị class màu của Leaf đè lên.
|
|
56
|
+
|
|
57
|
+
## Typography class
|
|
58
|
+
|
|
59
|
+
Tên class trùng đúng tên token trong Figma:
|
|
60
|
+
|
|
61
|
+
| Nhóm | Class |
|
|
62
|
+
| ------- | ------------------------------------------------------------- |
|
|
63
|
+
| Display | `display-1`, `display-2`, `display-3` |
|
|
64
|
+
| Heading | `heading-1`, `heading-2`, `heading-3` |
|
|
65
|
+
| Body | `body-1` / `body-1-highlight` … `body-5` / `body-5-highlight` |
|
|
66
|
+
|
|
67
|
+
Body có hai phiên bản: tên trần là văn bản thường, hậu tố `-highlight` dùng khi cần nhấn mạnh.
|
|
68
|
+
|
|
69
|
+
| Class | font-size | line-height | font-weight |
|
|
70
|
+
| ----------------------------- | --------- | ----------- | ----------- |
|
|
71
|
+
| `display-1` | 122px | 134px | 700 |
|
|
72
|
+
| `display-2` | 76px | 88px | 600 |
|
|
73
|
+
| `display-3` | 60px | 72px | 600 |
|
|
74
|
+
| `heading-1` | 36px | 48px | 600 |
|
|
75
|
+
| `heading-2` | 28px | 36px | 600 |
|
|
76
|
+
| `heading-3` | 24px | 32px | 600 |
|
|
77
|
+
| `body-1` / `body-1-highlight` | 20px | 30px | 400 / 600 |
|
|
78
|
+
| `body-2` / `body-2-highlight` | 18px | 28px | 400 / 600 |
|
|
79
|
+
| `body-3` / `body-3-highlight` | 16px | 24px | 400 / 600 |
|
|
80
|
+
| `body-4` / `body-4-highlight` | 14px | 20px | 400 / 600 |
|
|
81
|
+
| `body-5` / `body-5-highlight` | 12px | 16px | 400 / 600 |
|
|
82
|
+
|
|
83
|
+
## Cách dùng
|
|
84
|
+
|
|
85
|
+
Chọn thẻ theo **ngữ nghĩa** nội dung, chọn class theo **hình thức** mong muốn — hai việc độc lập
|
|
86
|
+
nhau, nên một `h1` hoàn toàn có thể hiển thị bằng style `display-3`.
|
|
87
|
+
|
|
88
|
+
```html
|
|
89
|
+
<h1 class="heading-1">Danh mục đầu tư</h1>
|
|
90
|
+
<p class="body-3">Cập nhật lần cuối 5 phút trước.</p>
|
|
91
|
+
<label class="body-4-highlight" for="amount">Số tiền đầu tư</label>
|
|
92
|
+
|
|
93
|
+
<!-- Vẫn là h1 để screen reader và SEO hiểu đúng cấp bậc, nhưng to như display -->
|
|
94
|
+
<h1 class="display-3">Finhay</h1>
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
Trong React / Next.js, class đi thẳng vào `className` của bất kỳ element hay component nào:
|
|
98
|
+
|
|
99
|
+
```tsx
|
|
100
|
+
<h2 className="heading-2">Tài sản của bạn</h2>
|
|
101
|
+
|
|
102
|
+
// Class typography lo cỡ chữ, class color lo màu, Tailwind lo spacing/layout
|
|
103
|
+
<p className="body-3 text-secondary mt-2">Lợi nhuận kỳ vọng 8.5%/năm</p>
|
|
104
|
+
|
|
105
|
+
// Gắn vào component của thư viện khác cũng chỉ là một chuỗi class
|
|
106
|
+
<Link href="/tai-khoan" className="body-3-highlight">
|
|
107
|
+
Tài khoản
|
|
108
|
+
</Link>
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
## Color class
|
|
112
|
+
|
|
113
|
+
Tiền tố nói thuộc tính, phần sau nói vai trò của token: `text-*` cho màu chữ, `base-*` cho màu nền,
|
|
114
|
+
`border-*` cho màu viền. Ba bộ dùng chung một hậu tố nên nhớ một bộ là suy ra được cả ba —
|
|
115
|
+
`text-red` / `base-red` / `border-red`, `text-primary` / `base-primary` / `border-primary`. Nhóm
|
|
116
|
+
system bỏ chữ `system` trong tên class (token vẫn là `--system-red`), còn `border-*` lấy màu từ
|
|
117
|
+
thang base vì viền luôn là màu bề mặt. Class chỉ trỏ vào token nên tự đổi theo theme, không cần
|
|
118
|
+
viết thêm gì cho light mode.
|
|
119
|
+
|
|
120
|
+
| Nhóm | Class |
|
|
121
|
+
| ---------------- | --------------------------------------------------------------------------------------- |
|
|
122
|
+
| Text color | `text-primary`, `text-secondary`, `text-tertiary`, `text-quaternary`, `text-highlight` |
|
|
123
|
+
| Background | `base-primary` … `base-quinary`, `base-highlight` |
|
|
124
|
+
| Border color | `border-primary` … `border-quinary` (màu của thang base), `border-highlight` |
|
|
125
|
+
| System (đủ 3 bộ) | `text-*`, `base-*`, `border-*` với `red`, `green`, `yellow`, `orange`, `blue`, `purple` |
|
|
126
|
+
|
|
127
|
+
```html
|
|
128
|
+
<div class="base-secondary border-quaternary border p-4">
|
|
129
|
+
<h3 class="heading-3 text-primary">Tích luỹ</h3>
|
|
130
|
+
<p class="body-4 text-secondary">Lợi nhuận kỳ vọng 8.5%/năm</p>
|
|
131
|
+
<p class="body-4 text-red">Số dư không đủ</p>
|
|
132
|
+
</div>
|
|
133
|
+
|
|
134
|
+
<!-- Dark là mặc định; light chỉ cần một attribute, class giữ nguyên -->
|
|
135
|
+
<html data-theme="light"></html>
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
## Cần biết
|
|
139
|
+
|
|
140
|
+
- **Class typography chỉ set đúng 3 thuộc tính** (`font-size`, `line-height`, `font-weight`) và
|
|
141
|
+
**class color chỉ set đúng 1** (`color` / `background-color` / `border-color`). Font family,
|
|
142
|
+
letter spacing, margin, border width… nằm ngoài phạm vi — app tự setup ở tầng global
|
|
143
|
+
(`body { font-family: var(--font-sans) }`, CSS reset…) hoặc thêm bằng Tailwind.
|
|
144
|
+
- **Typography nằm trong `@layer components`**, nên utility của Tailwind v4 (`@layer utilities`)
|
|
145
|
+
luôn thắng: `class="heading-1 font-bold"` hay `class="body-3 text-2xl"` override được bình
|
|
146
|
+
thường, không cần important modifier.
|
|
147
|
+
- **Color nằm trong `@layer utilities`** — ngược lại: màu là token gốc nên trùng tên thì phải
|
|
148
|
+
thắng. Class màu của Leaf đứng cùng layer với utility của Tailwind và được import sau, nên nếu
|
|
149
|
+
app tự khai báo `--color-primary` / `--color-red` trong `@theme` thì `text-primary`, `text-red`
|
|
150
|
+
vẫn ra màu của Leaf. Điều kiện: `@import "@finhay-pro/leaf-design-system/…"` phải nằm **sau**
|
|
151
|
+
`@import "tailwindcss"`.
|
|
152
|
+
- **Class không có biến thể `hover:` / `focus:` / opacity** — nó là CSS thuần, không phải utility do
|
|
153
|
+
Tailwind sinh ra. Cần state thì dùng arbitrary value trỏ vào cùng token:
|
|
154
|
+
`hover:text-[var(--text-highlight)]` (pseudo-class có specificity cao hơn nên thắng). Riêng biến
|
|
155
|
+
thể responsive cùng specificity với class màu và được ghi ra trước, nên cần important modifier:
|
|
156
|
+
`md:text-[var(--text-secondary)]!`.
|
|
157
|
+
- **Chỉ semantic token mới có class.** Primitive (`--neutral-500`, `--brand-300`…) là nguồn nội bộ,
|
|
158
|
+
dùng thẳng trong UI là mất khả năng đổi theme.
|
|
159
|
+
- **Tên class không có prefix.** Đây là những tên khá phổ thông, nên app dùng Leaf cần cân nhắc kỹ
|
|
160
|
+
nếu load kèm CSS framework khác (Bootstrap cũng định nghĩa `.display-1`–`.display-6`). Với
|
|
161
|
+
Tailwind thì màu của Leaf luôn thắng khi trùng tên — đó là chủ đích; muốn dùng màu riêng của app
|
|
162
|
+
thì đặt tên khác `primary`/`secondary`/`red`… hoặc gọi qua arbitrary value.
|
|
163
|
+
- Typography token hiện chỉ có **bộ Desktop**. Chưa có responsive type set, nên các style Display
|
|
164
|
+
cần app tự xử lý ở breakpoint nhỏ.
|
|
165
|
+
|
|
166
|
+
## Phát triển
|
|
167
|
+
|
|
168
|
+
```bash
|
|
169
|
+
pnpm --filter @finhay-pro/leaf-design-system build # tsc → dist/ + gom CSS + bản CDN
|
|
170
|
+
pnpm --filter @finhay-pro/leaf-design-system dev # gom CSS + tsc --watch
|
|
171
|
+
pnpm --filter @finhay-pro/leaf-design-system typecheck
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
CSS trong `dist` được sinh bởi `scripts/build-css.mjs` (mỗi `src/**/*.css` ra một file riêng, nội
|
|
175
|
+
tuyến token vào `tokens.css` / `styles.css`). Sau đó `scripts/build-cdn.mjs` sinh bản CDN
|
|
176
|
+
`dist/cdn/leaf-<version>.min.{css,js}`. Không sửa file trong `dist`.
|
|
177
|
+
|
|
178
|
+
`build` ghi đè `dist` tại chỗ, **không xoá `dist` trước** (chỉ `prepublishOnly` mới `clean`):
|
|
179
|
+
`turbo run dev` luôn build package trước docs, và nếu `dist` biến mất dù chỉ một lúc thì Turbopack
|
|
180
|
+
cache luôn lỗi resolve `@finhay-pro/leaf-design-system/…css`. Gặp lỗi "no valid target file was found"
|
|
181
|
+
khi chạy docs: xoá `apps/docs/.next/dev` rồi chạy lại `pnpm dev`.
|
|
182
|
+
|
|
183
|
+
**Mọi hình thức nằm trong CSS** và chỉ đọc attribute (`data-*`, `aria-*`, `:disabled`), kể cả
|
|
184
|
+
typography của label. Component React chỉ gắn attribute, không gắn class theo prop — nhờ vậy HTML
|
|
185
|
+
tĩnh viết cùng markup là ra cùng kết quả. Attribute thiếu → CSS lấy mặc định giống prop React.
|
|
186
|
+
|
|
187
|
+
Thêm bộ class mới: tạo `src/styles/<tên>.css` — script tự sinh `dist/<tên>.css` và gom vào
|
|
188
|
+
`classes.css` + `styles.css`; chỉ cần thêm một dòng `"./<tên>.css"` vào `exports` của
|
|
189
|
+
`package.json`.
|
|
190
|
+
Thêm component React (khi thật sự cần state/behavior, không phải để bọc style): tạo
|
|
191
|
+
`src/components/<Tên>/` (kèm `<tên>.css` nếu cần) rồi re-export trong `src/index.ts`. CSS của
|
|
192
|
+
component cũng ra `dist/<tên>.css` và được gom vào `classes.css` / `styles.css` — nhớ thêm dòng
|
|
193
|
+
`"./<tên>.css"` vào `exports`. Tên file CSS phải duy nhất trong cả `src/` (script báo lỗi nếu trùng).
|
|
194
|
+
Component có hành vi (như Tabs) cần thêm bản vanilla cho HTML tĩnh trong `src/vanilla/` và gắn vào
|
|
195
|
+
`window.Leaf` qua `src/vanilla/index.ts`. `src/vanilla` chỉ vào bản CDN, không vào bản npm.
|
|
196
|
+
|
|
197
|
+
## Components
|
|
198
|
+
|
|
199
|
+
| Export | Mô tả |
|
|
200
|
+
| -------------- | -------------------------------------------------------------------------------------- |
|
|
201
|
+
| `Button` | Khung icon · label · icon — bật/tắt từng phần (`showLeadingIcon` / `showTrailingIcon`) |
|
|
202
|
+
| `Tabs` / `Tab` | Tabs Items — `addon` = slot động `[---]` (text / icon) |
|
|
203
|
+
|
|
204
|
+
```css
|
|
205
|
+
/* Ngoài tokens.css + typography.css, mỗi component cần CSS riêng của nó */
|
|
206
|
+
@import "@finhay-pro/leaf-design-system/button.css";
|
|
207
|
+
@import "@finhay-pro/leaf-design-system/tabs.css";
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
```tsx
|
|
211
|
+
import { Button, Tabs, Tab } from "@finhay-pro/leaf-design-system";
|
|
212
|
+
|
|
213
|
+
<Button priority="primary" size="md" leadingIcon={<PlusIcon />} trailingIcon={<PlusIcon />}>
|
|
214
|
+
Label
|
|
215
|
+
</Button>
|
|
216
|
+
{/* Chỉ icon → layout tròn */}
|
|
217
|
+
<Button aria-label="Thêm" leadingIcon={<PlusIcon />} />
|
|
218
|
+
|
|
219
|
+
<Tabs variant="buy" defaultValue="buy">
|
|
220
|
+
<Tab value="buy" addon="1.2%">
|
|
221
|
+
Mua
|
|
222
|
+
</Tab>
|
|
223
|
+
</Tabs>
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
## HTML tĩnh (CDN)
|
|
227
|
+
|
|
228
|
+
Cho landing page / trang dựng tay không có bundler. Giống Bootstrap: 1 `<link>` + 1 `<script>` là
|
|
229
|
+
dùng được toàn bộ class typography, color, Button và Tabs.
|
|
230
|
+
|
|
231
|
+
```html
|
|
232
|
+
<link rel="stylesheet" href="https://<cdn>/leaf-0.1.0.min.css" />
|
|
233
|
+
<script src="https://<cdn>/leaf-0.1.0.min.js" defer></script>
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
| File | Nội dung |
|
|
237
|
+
| ------------------------ | ------------------------------------------------------------------------------ |
|
|
238
|
+
| `leaf-<version>.min.css` | `styles.css` đã minify: token + typography + color + CSS của mọi component. |
|
|
239
|
+
| `leaf-<version>.min.js` | Hành vi Tabs, gắn vào `window.Leaf`. Trang không dùng Tabs có thể bỏ file này. |
|
|
240
|
+
|
|
241
|
+
Link thật (do tool admin CDN trả về) nằm ở trang docs **Develop → Web**. Trang demo đủ mọi biến thể:
|
|
242
|
+
[`examples/static.html`](examples/static.html) (mở bằng `file://` sau khi build).
|
|
243
|
+
|
|
244
|
+
### Button
|
|
245
|
+
|
|
246
|
+
Không cần JS. Thiếu attribute nào thì lấy mặc định giống prop React.
|
|
247
|
+
|
|
248
|
+
| Attribute | Giá trị | Mặc định |
|
|
249
|
+
| ---------------------------- | --------------------------------------------- | --------- |
|
|
250
|
+
| `data-priority` | `primary` `secondary` `tertiary` `ghost` | `primary` |
|
|
251
|
+
| `data-size` | `lg` `md` `sm` | `lg` |
|
|
252
|
+
| `data-status` | `normal` `destruction` | `normal` |
|
|
253
|
+
| `data-icon-only` | `true` — chỉ có icon → tròn, cần `aria-label` | — |
|
|
254
|
+
| `disabled` / `aria-disabled` | native / `"true"` | — |
|
|
255
|
+
|
|
256
|
+
```html
|
|
257
|
+
<button class="leaf-button">Tiếp tục</button>
|
|
258
|
+
<button class="leaf-button" data-priority="secondary" data-size="md">Secondary</button>
|
|
259
|
+
|
|
260
|
+
<button class="leaf-button" data-size="md">
|
|
261
|
+
<span class="leaf-button__icon" aria-hidden="true"><svg>…</svg></span>
|
|
262
|
+
<span class="leaf-button__label">Thêm</span>
|
|
263
|
+
</button>
|
|
264
|
+
|
|
265
|
+
<button class="leaf-button" data-icon-only="true" aria-label="Thêm">
|
|
266
|
+
<span class="leaf-button__icon" aria-hidden="true"><svg>…</svg></span>
|
|
267
|
+
</button>
|
|
268
|
+
```
|
|
269
|
+
|
|
270
|
+
### Tabs
|
|
271
|
+
|
|
272
|
+
Đánh dấu tablist bằng `data-leaf-tabs` (opt-in — Tabs của React không có attribute này nên không
|
|
273
|
+
bị `leaf.js` đụng vào). Variant / size đặt trên tablist; từng tab chỉ cần `aria-selected`.
|
|
274
|
+
|
|
275
|
+
| Attribute | Đặt trên | Giá trị | Mặc định |
|
|
276
|
+
| ---------------- | ------------ | -------------------------------------------------- | ------------ |
|
|
277
|
+
| `data-leaf-tabs` | `.leaf-tabs` | (không giá trị) — bật hành vi của `leaf.js` | — |
|
|
278
|
+
| `data-variant` | `.leaf-tabs` | `subcontent` `title` `functional` `buy` `sell` | `subcontent` |
|
|
279
|
+
| `data-size` | `.leaf-tabs` | `xl` `lg` `md` `sm` (chỉ Subcontent đổi theo size) | `xl` |
|
|
280
|
+
| `data-value` | `.leaf-tab` | id của tab, trả về trong event | — |
|
|
281
|
+
| `aria-selected` | `.leaf-tab` | `"true"` cho tab chọn ban đầu | tab đầu tiên |
|
|
282
|
+
| `aria-controls` | `.leaf-tab` | id của panel → panel tự ẩn/hiện | — |
|
|
283
|
+
| `disabled` | `.leaf-tab` | native | — |
|
|
284
|
+
|
|
285
|
+
```html
|
|
286
|
+
<div class="leaf-tabs" data-leaf-tabs data-variant="buy">
|
|
287
|
+
<button class="leaf-tab" data-value="buy" aria-selected="true" aria-controls="panel-buy">
|
|
288
|
+
<span class="leaf-tab__label">Mua</span>
|
|
289
|
+
<span class="leaf-tab__addon">1.2%</span>
|
|
290
|
+
</button>
|
|
291
|
+
<button class="leaf-tab" data-value="idle" aria-controls="panel-idle">Mua</button>
|
|
292
|
+
</div>
|
|
293
|
+
<section id="panel-buy">…</section>
|
|
294
|
+
<section id="panel-idle" hidden>…</section>
|
|
295
|
+
```
|
|
296
|
+
|
|
297
|
+
`leaf.js` lo click, phím ← → Home End, roving `tabindex`, `aria-selected`, `hidden` của panel và
|
|
298
|
+
tự thêm `role` còn thiếu. Click đi qua event delegation nên nội dung chèn động vẫn chạy.
|
|
299
|
+
|
|
300
|
+
```js
|
|
301
|
+
// Event bubble lên document mỗi khi đổi tab
|
|
302
|
+
document.addEventListener("leaf:tabs-change", (event) => {
|
|
303
|
+
console.log(event.detail.value, event.detail.tab);
|
|
304
|
+
});
|
|
305
|
+
|
|
306
|
+
Leaf.tabs.select(tablistElement, "idle"); // chọn tab từ code (false nếu không có / disabled)
|
|
307
|
+
Leaf.tabs.init(container); // chuẩn hoá attribute cho nội dung vừa chèn
|
|
308
|
+
Leaf.version; // "0.1.0"
|
|
309
|
+
```
|
|
310
|
+
|
|
311
|
+
Handler của trang gọi `event.preventDefault()` trong `click` thì tab không đổi — giống `<Tab onClick>`.
|
|
312
|
+
|
|
313
|
+
### Cần biết
|
|
314
|
+
|
|
315
|
+
- **Link gắn theo version.** Mỗi bản phát hành là một link mới; trang cũ giữ link cũ nên không tự
|
|
316
|
+
vỡ. Muốn lên bản mới thì đổi cả link CSS lẫn JS cùng một version, đọc [Changelog](#changelog)
|
|
317
|
+
trước.
|
|
318
|
+
- **Không kèm font và CSS reset.** Tự load Inter (Google Fonts hoặc self-host) và set
|
|
319
|
+
`body { font-family: var(--font-sans) }`.
|
|
320
|
+
- **Trình duyệt tối thiểu** (CSS dùng `@layer`): Chrome / Edge 99+, Safari 15.4+, Firefox 97+.
|
|
321
|
+
- Dark là mặc định; `data-theme="light"` trên `<html>` để chuyển light.
|
|
322
|
+
|
|
323
|
+
### Phát hành bản CDN
|
|
324
|
+
|
|
325
|
+
1. Bump `version` trong `packages/react/package.json`, ghi thay đổi vào [Changelog](#changelog).
|
|
326
|
+
2. `pnpm --filter @finhay-pro/leaf-design-system build` → `dist/cdn/leaf-<version>.min.css` + `.min.js`.
|
|
327
|
+
3. Đổi version trong `examples/static.html`, mở bằng `file://` để kiểm tra nhanh.
|
|
328
|
+
4. Upload 2 file bằng tool admin CDN. **Không xoá / ghi đè** file của version cũ — landing page
|
|
329
|
+
đang trỏ vào.
|
|
330
|
+
5. Cập nhật `leafCdn` trong `apps/docs/config/shared.ts` bằng 2 link tool trả về.
|
|
331
|
+
|
|
332
|
+
## Changelog
|
|
333
|
+
|
|
334
|
+
### Chưa phát hành
|
|
335
|
+
|
|
336
|
+
- Thêm bản CDN cho HTML tĩnh: `leaf-<version>.min.css` + `leaf-<version>.min.js` (`window.Leaf`,
|
|
337
|
+
hành vi Tabs qua `data-leaf-tabs`).
|
|
338
|
+
- Button: typography của label chuyển vào `button.css`, component không còn gắn class
|
|
339
|
+
`body-*-highlight`. Thiếu `data-priority` / `data-size` / `data-status` → primary / lg / normal.
|
|
340
|
+
- Tabs: `data-variant` / `data-size` chỉ đọc từ tablist, `.leaf-tab` không còn mang hai attribute
|
|
341
|
+
này; typography của label chuyển vào `tabs.css`; `<Tab>` thêm `data-value`.
|
|
342
|
+
- Token: `--font-sans` có fallback khi không có `--font-inter` (trang ngoài Next.js).
|
package/dist/button.css
ADDED
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
/* @finhay-pro/leaf-design-system — generated by scripts/build-css.mjs. Do not edit. */
|
|
2
|
+
|
|
3
|
+
/* --- src/components/Button/button.css --- */
|
|
4
|
+
|
|
5
|
+
/*
|
|
6
|
+
* Button — Figma 246:1135.
|
|
7
|
+
*
|
|
8
|
+
* Variant màu qua data-priority / data-status; size qua data-size; icon-only
|
|
9
|
+
* qua data-icon-only. Disabled dùng attribute native `:disabled` (và
|
|
10
|
+
* `aria-disabled`) nên không cần class riêng.
|
|
11
|
+
*
|
|
12
|
+
* Toàn bộ hình thức (kể cả typography của label) nằm ở đây — React chỉ gắn
|
|
13
|
+
* attribute, nên HTML tĩnh viết cùng markup là ra cùng kết quả. Thiếu attribute
|
|
14
|
+
* nào thì lấy mặc định giống prop của React: lg · primary · normal.
|
|
15
|
+
*
|
|
16
|
+
* Variant chỉ đổi custom property `--leaf-button-*`; thuộc tính thật chỉ khai
|
|
17
|
+
* báo một lần ở `.leaf-button`.
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
@layer components {
|
|
21
|
+
.leaf-button {
|
|
22
|
+
/* Mặc định: size lg */
|
|
23
|
+
--leaf-button-height: 56px;
|
|
24
|
+
--leaf-button-padding: 8px 24px;
|
|
25
|
+
--leaf-button-icon-only-padding: 8px;
|
|
26
|
+
--leaf-button-gap: 16px;
|
|
27
|
+
--leaf-button-icon-size: 30px;
|
|
28
|
+
--leaf-button-font-size: var(--body-1-size);
|
|
29
|
+
--leaf-button-line-height: var(--body-1-line-height);
|
|
30
|
+
--leaf-button-font-weight: var(--body-1-highlight-weight);
|
|
31
|
+
|
|
32
|
+
/* Mặc định: priority primary, status normal */
|
|
33
|
+
--leaf-button-bg: var(--button-base-primary);
|
|
34
|
+
--leaf-button-fg: var(--button-content-primary);
|
|
35
|
+
|
|
36
|
+
display: inline-flex;
|
|
37
|
+
align-items: center;
|
|
38
|
+
justify-content: center;
|
|
39
|
+
height: var(--leaf-button-height);
|
|
40
|
+
gap: var(--leaf-button-gap);
|
|
41
|
+
border: none;
|
|
42
|
+
margin: 0;
|
|
43
|
+
padding: var(--leaf-button-padding);
|
|
44
|
+
cursor: pointer;
|
|
45
|
+
border-radius: 1000px;
|
|
46
|
+
background-color: var(--leaf-button-bg);
|
|
47
|
+
color: var(--leaf-button-fg);
|
|
48
|
+
text-align: center;
|
|
49
|
+
white-space: nowrap;
|
|
50
|
+
font: inherit;
|
|
51
|
+
font-size: var(--leaf-button-font-size);
|
|
52
|
+
line-height: var(--leaf-button-line-height);
|
|
53
|
+
font-weight: var(--leaf-button-font-weight);
|
|
54
|
+
text-decoration: none;
|
|
55
|
+
box-sizing: border-box;
|
|
56
|
+
vertical-align: middle;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
.leaf-button__icon {
|
|
60
|
+
display: inline-flex;
|
|
61
|
+
flex-shrink: 0;
|
|
62
|
+
align-items: center;
|
|
63
|
+
justify-content: center;
|
|
64
|
+
width: var(--leaf-button-icon-size);
|
|
65
|
+
height: var(--leaf-button-icon-size);
|
|
66
|
+
font-size: var(--leaf-button-icon-size);
|
|
67
|
+
line-height: 1;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
.leaf-button__icon > svg {
|
|
71
|
+
display: block;
|
|
72
|
+
width: 1em;
|
|
73
|
+
height: 1em;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/* ── Size ────────────────────────────────────────────────────────────── */
|
|
77
|
+
|
|
78
|
+
.leaf-button[data-size="md"] {
|
|
79
|
+
--leaf-button-height: 40px;
|
|
80
|
+
--leaf-button-padding: 8px 16px;
|
|
81
|
+
--leaf-button-gap: 8px;
|
|
82
|
+
--leaf-button-icon-size: 24px;
|
|
83
|
+
--leaf-button-font-size: var(--body-3-size);
|
|
84
|
+
--leaf-button-line-height: var(--body-3-line-height);
|
|
85
|
+
--leaf-button-font-weight: var(--body-3-highlight-weight);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
.leaf-button[data-size="sm"] {
|
|
89
|
+
--leaf-button-height: 28px;
|
|
90
|
+
--leaf-button-padding: 4px 8px;
|
|
91
|
+
--leaf-button-icon-only-padding: 4px;
|
|
92
|
+
--leaf-button-gap: 4px;
|
|
93
|
+
--leaf-button-icon-size: 20px;
|
|
94
|
+
--leaf-button-font-size: var(--body-4-size);
|
|
95
|
+
--leaf-button-line-height: var(--body-4-line-height);
|
|
96
|
+
--leaf-button-font-weight: var(--body-4-highlight-weight);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/* Icon-only: khung vuông (tròn nhờ border-radius) cạnh = height. */
|
|
100
|
+
.leaf-button[data-icon-only="true"] {
|
|
101
|
+
width: var(--leaf-button-height);
|
|
102
|
+
padding: var(--leaf-button-icon-only-padding);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/* Ghost không có khung — bỏ height/padding cố định. Đứng sau size để thắng. */
|
|
106
|
+
.leaf-button[data-priority="ghost"] {
|
|
107
|
+
--leaf-button-height: auto;
|
|
108
|
+
--leaf-button-padding: 0;
|
|
109
|
+
--leaf-button-icon-only-padding: 0;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
.leaf-button[data-priority="ghost"][data-icon-only="true"] {
|
|
113
|
+
border-radius: 0;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/* ── Priority × status ───────────────────────────────────────────────── */
|
|
117
|
+
|
|
118
|
+
/* Không có data-priority = primary. */
|
|
119
|
+
.leaf-button[data-status="destruction"] {
|
|
120
|
+
--leaf-button-bg: var(--button-base-destruction);
|
|
121
|
+
--leaf-button-fg: var(--button-content-primary);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
.leaf-button[data-priority="secondary"] {
|
|
125
|
+
--leaf-button-bg: var(--button-base-secondary);
|
|
126
|
+
--leaf-button-fg: var(--button-content-secondary);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
.leaf-button[data-priority="secondary"][data-status="destruction"] {
|
|
130
|
+
--leaf-button-bg: var(--button-base-secondary-destruction);
|
|
131
|
+
--leaf-button-fg: var(--button-content-destruction);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
.leaf-button[data-priority="tertiary"] {
|
|
135
|
+
--leaf-button-bg: var(--button-base-tertiary);
|
|
136
|
+
--leaf-button-fg: var(--button-content-secondary);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
.leaf-button[data-priority="tertiary"][data-status="destruction"] {
|
|
140
|
+
--leaf-button-bg: var(--button-base-tertiary);
|
|
141
|
+
--leaf-button-fg: var(--button-content-destruction);
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
.leaf-button[data-priority="ghost"] {
|
|
145
|
+
--leaf-button-bg: transparent;
|
|
146
|
+
--leaf-button-fg: var(--button-content-secondary);
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
.leaf-button[data-priority="ghost"][data-status="destruction"] {
|
|
150
|
+
--leaf-button-bg: transparent;
|
|
151
|
+
--leaf-button-fg: var(--button-content-destruction);
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
/*
|
|
155
|
+
* Disabled — Primary / Ghost có trong Figma; Secondary/Tertiary dùng cùng token.
|
|
156
|
+
* Specificity (0,3,0) và đứng cuối để thắng mọi tổ hợp priority × status.
|
|
157
|
+
*/
|
|
158
|
+
.leaf-button:disabled:not([data-priority="ghost"]),
|
|
159
|
+
.leaf-button[aria-disabled="true"]:not([data-priority="ghost"]) {
|
|
160
|
+
--leaf-button-bg: var(--button-base-disable);
|
|
161
|
+
--leaf-button-fg: var(--button-content-disable);
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
.leaf-button[data-priority="ghost"]:disabled,
|
|
165
|
+
.leaf-button[data-priority="ghost"][aria-disabled="true"] {
|
|
166
|
+
--leaf-button-bg: transparent;
|
|
167
|
+
--leaf-button-fg: var(--button-content-disable);
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
.leaf-button:disabled,
|
|
171
|
+
.leaf-button[aria-disabled="true"] {
|
|
172
|
+
cursor: not-allowed;
|
|
173
|
+
}
|
|
174
|
+
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
/*! @finhay-pro/leaf-design-system v0.1.1 — generated by scripts/build-cdn.mjs */
|
|
2
|
+
:root{--neutral-white: #ffffff;--neutral-100: #f8f8f8;--neutral-200: #f0f0f0;--neutral-300: #d9d9d9;--neutral-400: #999999;--neutral-500: #666666;--neutral-600: #313235;--neutral-700: #28292b;--neutral-800: #171719;--neutral-900: #0d0e10;--brand-100: #dbf7d5;--brand-200: #b6efac;--brand-300: #92e882;--brand-400: #6de059;--brand-500: #49d82f;--brand-600: #3aad26;--brand-700: #2c821c;--brand-800: #1d5613;--brand-900: #0f2b09;--purple-100: #f0ddf9;--purple-200: #e1bbf4;--purple-300: #d198ee;--purple-400: #c276e9;--purple-500: #b354e3;--purple-600: #8f43b6;--purple-700: #6b3288;--purple-800: #48225b;--purple-900: #24112d;--red-100: #fbd9d7;--red-200: #f7b4af;--red-300: #f38e87;--red-400: #ef695f;--red-500: #eb4337;--red-600: #bc362c;--red-700: #8d2821;--red-800: #5e1b16;--red-900: #2f0d0b;--orange-100: #fbe8cc;--orange-200: #f6d299;--orange-300: #f2bb66;--orange-400: #eda533;--orange-500: #e98e00;--orange-600: #ba7200;--orange-700: #8c5500;--orange-800: #5d3900;--orange-900: #2f1c00;--yellow-100: #fbf5d7;--yellow-200: #f6eaaf;--yellow-300: #f2e086;--yellow-400: #edd55e;--yellow-500: #e9cb36;--yellow-600: #baa22b;--yellow-700: #8c7a20;--yellow-800: #5d5116;--yellow-900: #2f290b;--green-100: #d8f3de;--green-200: #b0e7be;--green-300: #89dc9d;--green-400: #61d07d;--green-500: #3ac45c;--green-600: #2e9d4a;--green-700: #237637;--green-800: #174e25;--green-900: #0c2712;--blue-100: #d4eaff;--blue-200: #a9d4ff;--blue-300: #7fbfff;--blue-400: #54a9ff;--blue-500: #2994ff;--blue-600: #2176cc;--blue-700: #195999;--blue-800: #103b66;--blue-900: #081e33}:root,[data-theme=dark]{--base-primary: var(--neutral-900);--base-secondary: var(--neutral-800);--base-tertiary: var(--neutral-700);--base-quaternary: var(--neutral-600);--base-quinary: var(--neutral-white);--text-highlight: var(--brand-500);--text-primary: var(--neutral-100);--text-secondary: var(--neutral-300);--text-tertiary: var(--neutral-500);--text-quaternary: var(--neutral-900);--system-blue: var(--blue-500);--system-green: var(--green-500);--system-yellow: var(--yellow-500);--system-orange: var(--orange-500);--system-red: var(--red-500);--system-purple: var(--purple-500);--button-base-primary: var(--brand-500);--button-base-destruction: var(--red-500);--button-base-disable: var(--neutral-600);--button-base-secondary: var(--brand-800);--button-base-secondary-destruction: var(--red-800);--button-base-tertiary: var(--neutral-600);--button-content-primary: var(--neutral-900);--button-content-secondary: var(--brand-500);--button-content-destruction: var(--red-500);--button-content-disable: var(--neutral-500)}[data-theme=light]{--base-primary: var(--neutral-white);--base-secondary: var(--neutral-100);--base-tertiary: var(--neutral-200);--base-quaternary: var(--neutral-300);--base-quinary: var(--neutral-900);--text-highlight: var(--brand-500);--text-primary: var(--neutral-900);--text-secondary: var(--neutral-500);--text-tertiary: var(--neutral-400);--text-quaternary: var(--neutral-white);--system-blue: var(--blue-500);--system-green: var(--green-500);--system-yellow: var(--yellow-500);--system-orange: var(--orange-500);--system-red: var(--red-500);--system-purple: var(--purple-500);--button-base-primary: var(--brand-500);--button-base-destruction: var(--red-500);--button-base-disable: var(--neutral-300);--button-base-secondary: var(--brand-100);--button-base-secondary-destruction: var(--red-100);--button-base-tertiary: var(--neutral-200);--button-content-primary: var(--neutral-900);--button-content-secondary: var(--brand-700);--button-content-destruction: var(--red-600);--button-content-disable: var(--neutral-400)}:root{--font-sans: var(--font-inter, "Inter"), ui-sans-serif, system-ui, sans-serif;--display-1-size: 122px;--display-1-line-height: 134px;--display-1-weight: 700;--display-2-size: 76px;--display-2-line-height: 88px;--display-2-weight: 600;--display-3-size: 60px;--display-3-line-height: 72px;--display-3-weight: 600;--heading-1-size: 36px;--heading-1-line-height: 48px;--heading-1-weight: 600;--heading-2-size: 28px;--heading-2-line-height: 36px;--heading-2-weight: 600;--heading-3-size: 24px;--heading-3-line-height: 32px;--heading-3-weight: 600;--body-1-size: 20px;--body-1-line-height: 30px;--body-1-weight: 400;--body-1-highlight-weight: 600;--body-2-size: 18px;--body-2-line-height: 28px;--body-2-weight: 400;--body-2-highlight-weight: 600;--body-3-size: 16px;--body-3-line-height: 24px;--body-3-weight: 400;--body-3-highlight-weight: 600;--body-4-size: 14px;--body-4-line-height: 20px;--body-4-weight: 400;--body-4-highlight-weight: 600;--body-5-size: 12px;--body-5-line-height: 16px;--body-5-weight: 400;--body-5-highlight-weight: 600}@layer components{.leaf-button{--leaf-button-height: 56px;--leaf-button-padding: 8px 24px;--leaf-button-icon-only-padding: 8px;--leaf-button-gap: 16px;--leaf-button-icon-size: 30px;--leaf-button-font-size: var(--body-1-size);--leaf-button-line-height: var(--body-1-line-height);--leaf-button-font-weight: var(--body-1-highlight-weight);--leaf-button-bg: var(--button-base-primary);--leaf-button-fg: var(--button-content-primary);display:inline-flex;align-items:center;justify-content:center;height:var(--leaf-button-height);gap:var(--leaf-button-gap);border:none;margin:0;padding:var(--leaf-button-padding);cursor:pointer;border-radius:1000px;background-color:var(--leaf-button-bg);color:var(--leaf-button-fg);text-align:center;white-space:nowrap;font:inherit;font-size:var(--leaf-button-font-size);line-height:var(--leaf-button-line-height);font-weight:var(--leaf-button-font-weight);text-decoration:none;box-sizing:border-box;vertical-align:middle}.leaf-button__icon{display:inline-flex;flex-shrink:0;align-items:center;justify-content:center;width:var(--leaf-button-icon-size);height:var(--leaf-button-icon-size);font-size:var(--leaf-button-icon-size);line-height:1}.leaf-button__icon>svg{display:block;width:1em;height:1em}.leaf-button[data-size=md]{--leaf-button-height: 40px;--leaf-button-padding: 8px 16px;--leaf-button-gap: 8px;--leaf-button-icon-size: 24px;--leaf-button-font-size: var(--body-3-size);--leaf-button-line-height: var(--body-3-line-height);--leaf-button-font-weight: var(--body-3-highlight-weight)}.leaf-button[data-size=sm]{--leaf-button-height: 28px;--leaf-button-padding: 4px 8px;--leaf-button-icon-only-padding: 4px;--leaf-button-gap: 4px;--leaf-button-icon-size: 20px;--leaf-button-font-size: var(--body-4-size);--leaf-button-line-height: var(--body-4-line-height);--leaf-button-font-weight: var(--body-4-highlight-weight)}.leaf-button[data-icon-only=true]{width:var(--leaf-button-height);padding:var(--leaf-button-icon-only-padding)}.leaf-button[data-priority=ghost]{--leaf-button-height: auto;--leaf-button-padding: 0;--leaf-button-icon-only-padding: 0}.leaf-button[data-priority=ghost][data-icon-only=true]{border-radius:0}.leaf-button[data-status=destruction]{--leaf-button-bg: var(--button-base-destruction);--leaf-button-fg: var(--button-content-primary)}.leaf-button[data-priority=secondary]{--leaf-button-bg: var(--button-base-secondary);--leaf-button-fg: var(--button-content-secondary)}.leaf-button[data-priority=secondary][data-status=destruction]{--leaf-button-bg: var(--button-base-secondary-destruction);--leaf-button-fg: var(--button-content-destruction)}.leaf-button[data-priority=tertiary]{--leaf-button-bg: var(--button-base-tertiary);--leaf-button-fg: var(--button-content-secondary)}.leaf-button[data-priority=tertiary][data-status=destruction]{--leaf-button-bg: var(--button-base-tertiary);--leaf-button-fg: var(--button-content-destruction)}.leaf-button[data-priority=ghost]{--leaf-button-bg: transparent;--leaf-button-fg: var(--button-content-secondary)}.leaf-button[data-priority=ghost][data-status=destruction]{--leaf-button-bg: transparent;--leaf-button-fg: var(--button-content-destruction)}.leaf-button:disabled:not([data-priority=ghost]),.leaf-button[aria-disabled=true]:not([data-priority=ghost]){--leaf-button-bg: var(--button-base-disable);--leaf-button-fg: var(--button-content-disable)}.leaf-button[data-priority=ghost]:disabled,.leaf-button[data-priority=ghost][aria-disabled=true]{--leaf-button-bg: transparent;--leaf-button-fg: var(--button-content-disable)}.leaf-button:disabled,.leaf-button[aria-disabled=true]{cursor:not-allowed}}@layer components{.leaf-tabs{--leaf-tab-padding: 12px 16px;--leaf-tab-gap: 8px;--leaf-tab-font-size: var(--body-3-size);--leaf-tab-line-height: var(--body-3-line-height);--leaf-tab-font-weight: var(--body-3-highlight-weight);display:flex;flex-wrap:wrap;align-items:center;gap:12px}.leaf-tabs[data-size=lg]{--leaf-tab-padding: 8px 16px;--leaf-tab-gap: 8px;--leaf-tab-font-size: var(--body-4-size);--leaf-tab-line-height: var(--body-4-line-height);--leaf-tab-font-weight: var(--body-4-highlight-weight)}.leaf-tabs[data-size=md]{--leaf-tab-padding: 4px 12px;--leaf-tab-gap: normal;--leaf-tab-font-size: var(--body-4-size);--leaf-tab-line-height: var(--body-4-line-height);--leaf-tab-font-weight: var(--body-4-weight)}.leaf-tabs[data-size=sm]{--leaf-tab-padding: 4px 12px;--leaf-tab-gap: normal;--leaf-tab-font-size: var(--body-5-size);--leaf-tab-line-height: var(--body-5-line-height);--leaf-tab-font-weight: var(--body-5-weight)}.leaf-tab{display:inline-flex;align-items:center;justify-content:center;border:none;margin:0;padding:0;cursor:pointer;background-color:transparent;color:inherit;font:inherit;text-align:center;white-space:nowrap;box-sizing:border-box}.leaf-tab:disabled,.leaf-tab[aria-disabled=true]{cursor:not-allowed}.leaf-tabs:is(:not([data-variant]),[data-variant=subcontent]) .leaf-tab{gap:var(--leaf-tab-gap);padding:var(--leaf-tab-padding);border-radius:1000px;background-color:var(--base-tertiary);color:var(--text-secondary);font-size:var(--leaf-tab-font-size);line-height:var(--leaf-tab-line-height);font-weight:var(--leaf-tab-font-weight)}.leaf-tabs:is(:not([data-variant]),[data-variant=subcontent]) .leaf-tab[aria-selected=true]{background-color:var(--base-quinary);color:var(--text-quaternary)}.leaf-tabs[data-variant=title] .leaf-tab{flex-direction:column;gap:4px;min-width:100px;color:var(--text-secondary);font-size:var(--body-4-size);line-height:var(--body-4-line-height);font-weight:var(--body-4-weight)}.leaf-tabs[data-variant=title] .leaf-tab[aria-selected=true]{color:var(--text-primary);font-weight:var(--body-4-highlight-weight)}.leaf-tabs[data-variant=title] .leaf-tab:after{content:"";display:block;width:100%;height:2px;background-color:var(--text-primary);opacity:0}.leaf-tabs[data-variant=title] .leaf-tab[aria-selected=true]:after{opacity:1}.leaf-tabs[data-variant=functional] .leaf-tab{height:24px;min-width:100px;padding:4px 24px;border-radius:100px;background-color:var(--base-tertiary);color:var(--button-content-disable);font-size:var(--body-5-size);line-height:var(--body-5-line-height);font-weight:var(--body-5-weight)}.leaf-tabs[data-variant=functional] .leaf-tab[aria-selected=true]{background-color:var(--button-base-primary);color:var(--button-content-primary)}.leaf-tabs:is([data-variant=buy],[data-variant=sell]) .leaf-tab{min-width:100px;width:auto;gap:4px;padding:6px 4px;border-radius:100px;color:var(--text-primary);font-size:var(--body-5-size);line-height:var(--body-5-line-height);font-weight:var(--body-5-weight)}.leaf-tabs:is([data-variant=buy],[data-variant=sell]) .leaf-tab[aria-selected=true]{font-weight:var(--body-5-highlight-weight)}.leaf-tabs[data-variant=buy] .leaf-tab[aria-selected=true]{background-color:var(--button-base-secondary);color:var(--text-highlight)}.leaf-tabs[data-variant=sell] .leaf-tab[aria-selected=true]{background-color:var(--button-base-secondary-destruction);color:var(--button-content-destruction)}.leaf-tab__label,.leaf-tab__addon{display:inline-flex;align-items:center;justify-content:center;line-height:inherit}.leaf-tab__addon>svg{display:block;width:1em;height:1em}}@layer utilities{.text-highlight{color:var(--text-highlight)}.text-primary{color:var(--text-primary)}.text-secondary{color:var(--text-secondary)}.text-tertiary{color:var(--text-tertiary)}.text-quaternary{color:var(--text-quaternary)}.text-blue{color:var(--system-blue)}.text-green{color:var(--system-green)}.text-yellow{color:var(--system-yellow)}.text-orange{color:var(--system-orange)}.text-red{color:var(--system-red)}.text-purple{color:var(--system-purple)}.base-highlight{background-color:var(--text-highlight)}.base-primary{background-color:var(--base-primary)}.base-secondary{background-color:var(--base-secondary)}.base-tertiary{background-color:var(--base-tertiary)}.base-quaternary{background-color:var(--base-quaternary)}.base-quinary{background-color:var(--base-quinary)}.base-blue{background-color:var(--system-blue)}.base-green{background-color:var(--system-green)}.base-yellow{background-color:var(--system-yellow)}.base-orange{background-color:var(--system-orange)}.base-red{background-color:var(--system-red)}.base-purple{background-color:var(--system-purple)}.border-highlight{border-color:var(--text-highlight)}.border-primary{border-color:var(--base-primary)}.border-secondary{border-color:var(--base-secondary)}.border-tertiary{border-color:var(--base-tertiary)}.border-quaternary{border-color:var(--base-quaternary)}.border-quinary{border-color:var(--base-quinary)}.border-blue{border-color:var(--system-blue)}.border-green{border-color:var(--system-green)}.border-yellow{border-color:var(--system-yellow)}.border-orange{border-color:var(--system-orange)}.border-red{border-color:var(--system-red)}.border-purple{border-color:var(--system-purple)}}@layer components{.display-1{font-size:var(--display-1-size);line-height:var(--display-1-line-height);font-weight:var(--display-1-weight)}.display-2{font-size:var(--display-2-size);line-height:var(--display-2-line-height);font-weight:var(--display-2-weight)}.display-3{font-size:var(--display-3-size);line-height:var(--display-3-line-height);font-weight:var(--display-3-weight)}.heading-1{font-size:var(--heading-1-size);line-height:var(--heading-1-line-height);font-weight:var(--heading-1-weight)}.heading-2{font-size:var(--heading-2-size);line-height:var(--heading-2-line-height);font-weight:var(--heading-2-weight)}.heading-3{font-size:var(--heading-3-size);line-height:var(--heading-3-line-height);font-weight:var(--heading-3-weight)}.body-1{font-size:var(--body-1-size);line-height:var(--body-1-line-height);font-weight:var(--body-1-weight)}.body-1-highlight{font-size:var(--body-1-size);line-height:var(--body-1-line-height);font-weight:var(--body-1-highlight-weight)}.body-2{font-size:var(--body-2-size);line-height:var(--body-2-line-height);font-weight:var(--body-2-weight)}.body-2-highlight{font-size:var(--body-2-size);line-height:var(--body-2-line-height);font-weight:var(--body-2-highlight-weight)}.body-3{font-size:var(--body-3-size);line-height:var(--body-3-line-height);font-weight:var(--body-3-weight)}.body-3-highlight{font-size:var(--body-3-size);line-height:var(--body-3-line-height);font-weight:var(--body-3-highlight-weight)}.body-4{font-size:var(--body-4-size);line-height:var(--body-4-line-height);font-weight:var(--body-4-weight)}.body-4-highlight{font-size:var(--body-4-size);line-height:var(--body-4-line-height);font-weight:var(--body-4-highlight-weight)}.body-5{font-size:var(--body-5-size);line-height:var(--body-5-line-height);font-weight:var(--body-5-weight)}.body-5-highlight{font-size:var(--body-5-size);line-height:var(--body-5-line-height);font-weight:var(--body-5-highlight-weight)}}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
/*! @finhay-pro/leaf-design-system v0.1.1 — generated by scripts/build-cdn.mjs */
|
|
2
|
+
"use strict";var Leaf=(()=>{var c=Object.defineProperty;var p=Object.getOwnPropertyDescriptor;var v=Object.getOwnPropertyNames;var _=Object.prototype.hasOwnProperty;var H=(e,t)=>{for(var r in t)c(e,r,{get:t[r],enumerable:!0})},y=(e,t,r,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of v(t))!_.call(e,n)&&n!==r&&c(e,n,{get:()=>t[n],enumerable:!(i=p(t,n))||i.enumerable});return e};var M=e=>y(c({},"__esModule",{value:!0}),e);var O={};H(O,{tabs:()=>N,version:()=>C});var o="[data-leaf-tabs]",m=".leaf-tab",d="leaf:tabs-change";function s(e){return Array.from(e.querySelectorAll(m)).filter(t=>t.closest(o)===e)}function a(e){return e.hasAttribute("disabled")||e.getAttribute("aria-disabled")==="true"}function A(e){let t=e.getAttribute("aria-controls");return t?document.getElementById(t):null}function g(e,t){for(let r of s(e)){let i=r===t;r.setAttribute("aria-selected",String(i)),r.tabIndex=i?0:-1;let n=A(r);n&&(n.hidden=!i)}}function f(e,t,r){var n;if(a(t))return;let i=t.getAttribute("aria-selected")!=="true";g(e,t),r&&t.focus(),i&&e.dispatchEvent(new CustomEvent(d,{bubbles:!0,detail:{value:(n=t.dataset.value)!=null?n:"",tab:t}}))}function E(e){var i;e.hasAttribute("role")||e.setAttribute("role","tablist");let t=s(e);for(let n of t){n.hasAttribute("role")||n.setAttribute("role","tab"),n instanceof HTMLButtonElement&&!n.hasAttribute("type")&&(n.type="button");let l=A(n);l&&!l.hasAttribute("role")&&l.setAttribute("role","tabpanel"),l&&n.id&&!l.hasAttribute("aria-labelledby")&&l.setAttribute("aria-labelledby",n.id)}let r=(i=t.find(n=>n.getAttribute("aria-selected")==="true"&&!a(n)))!=null?i:t.find(n=>!a(n));r&&g(e,r)}function u(e=document){e instanceof Element&&e.matches(o)&&E(e),e.querySelectorAll(o).forEach(E)}function T(e,t){let r=s(e).find(i=>i.dataset.value===t);return!r||a(r)?!1:(f(e,r,!1),!0)}function L(e){if(!(e.target instanceof Element))return null;let t=e.target.closest(m),r=t==null?void 0:t.closest(o);return t&&r?{tablist:r,tab:t}:null}function S(e){let t=L(e);!t||e.defaultPrevented||f(t.tablist,t.tab,!1)}function x(e){let t=L(e);if(!t||e.defaultPrevented)return;let r=s(t.tablist).filter(l=>!a(l)),i=r.indexOf(t.tab);if(i===-1)return;let n;switch(e.key){case"ArrowRight":n=r[(i+1)%r.length];break;case"ArrowLeft":n=r[(i-1+r.length)%r.length];break;case"Home":n=r[0];break;case"End":n=r[r.length-1];break;default:return}n&&(e.preventDefault(),f(t.tablist,n,!0))}var b=!1;function h(){b||(b=!0,document.addEventListener("click",S),document.addEventListener("keydown",x))}var C="0.1.1",N={init:u,select:T,CHANGE_EVENT:d};h();document.readyState==="loading"?document.addEventListener("DOMContentLoaded",()=>u(),{once:!0}):u();return M(O);})();
|