@finhay-pro/leaf-design-system 0.1.8 → 0.2.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/README.md +190 -61
- package/dist/button.css +2 -1
- package/dist/cdn/leaf-0.2.0.min.css +2 -0
- package/dist/cdn/leaf-0.2.0.min.js +2 -0
- package/dist/checkbox.css +2 -2
- package/dist/classes.css +24 -18
- package/dist/components/Calendar/Calendar.d.ts.map +1 -1
- package/dist/components/Calendar/Calendar.js +7 -2
- package/dist/components/Calendar/Calendar.js.map +1 -1
- package/dist/components/Checkbox/Checkbox.d.ts.map +1 -1
- package/dist/components/Checkbox/Checkbox.js +2 -1
- package/dist/components/Checkbox/Checkbox.js.map +1 -1
- package/dist/components/Dialog/Dialog.d.ts.map +1 -1
- package/dist/components/Dialog/Dialog.js +3 -2
- package/dist/components/Dialog/Dialog.js.map +1 -1
- package/dist/components/Dropdown/Dropdown.d.ts +1 -1
- package/dist/components/Dropdown/Dropdown.d.ts.map +1 -1
- package/dist/components/Dropdown/Dropdown.js +7 -4
- package/dist/components/Dropdown/Dropdown.js.map +1 -1
- package/dist/components/Input/Input.d.ts.map +1 -1
- package/dist/components/Input/Input.js +3 -2
- package/dist/components/Input/Input.js.map +1 -1
- package/dist/components/Input/InputDate.d.ts +14 -5
- package/dist/components/Input/InputDate.d.ts.map +1 -1
- package/dist/components/Input/InputDate.js +15 -4
- package/dist/components/Input/InputDate.js.map +1 -1
- package/dist/components/Input/InputStepper.d.ts.map +1 -1
- package/dist/components/Input/InputStepper.js +3 -2
- package/dist/components/Input/InputStepper.js.map +1 -1
- package/dist/components/Slider/Slider.d.ts +1 -1
- package/dist/components/Slider/Slider.d.ts.map +1 -1
- package/dist/components/Slider/Slider.js +7 -4
- package/dist/components/Slider/Slider.js.map +1 -1
- package/dist/components/Toast/Toast.d.ts.map +1 -1
- package/dist/components/Toast/Toast.js +3 -2
- package/dist/components/Toast/Toast.js.map +1 -1
- package/dist/components/Toggle/Toggle.d.ts +2 -1
- package/dist/components/Toggle/Toggle.d.ts.map +1 -1
- package/dist/components/Toggle/Toggle.js +7 -3
- package/dist/components/Toggle/Toggle.js.map +1 -1
- package/dist/components/Tooltip/Tooltip.d.ts +13 -1
- package/dist/components/Tooltip/Tooltip.d.ts.map +1 -1
- package/dist/components/Tooltip/Tooltip.js.map +1 -1
- package/dist/core/icons.d.ts +27 -0
- package/dist/core/icons.d.ts.map +1 -0
- package/dist/core/icons.js +29 -0
- package/dist/core/icons.js.map +1 -0
- package/dist/core/toast.d.ts +3 -13
- package/dist/core/toast.d.ts.map +1 -1
- package/dist/core/toast.js +6 -17
- package/dist/core/toast.js.map +1 -1
- package/dist/core/tooltip.d.ts +4 -0
- package/dist/core/tooltip.d.ts.map +1 -1
- package/dist/core/tooltip.js.map +1 -1
- package/dist/skill/leaf-design-system-0.2.0.zip +0 -0
- package/dist/styles.css +24 -18
- package/dist/toast.css +8 -6
- package/dist/toggle.css +12 -9
- package/dist/utils/RemixGlyph.d.ts +7 -0
- package/dist/utils/RemixGlyph.d.ts.map +1 -0
- package/dist/utils/RemixGlyph.js +7 -0
- package/dist/utils/RemixGlyph.js.map +1 -0
- package/package.json +3 -2
- package/dist/cdn/leaf-0.1.8.min.css +0 -2
- package/dist/cdn/leaf-0.1.8.min.js +0 -2
package/README.md
CHANGED
|
@@ -25,32 +25,32 @@ pnpm add @finhay-pro/leaf-design-system
|
|
|
25
25
|
Class chỉ đọc `var(--…)`, không tự khai báo giá trị — nên **luôn import `tokens.css` trước**, rồi
|
|
26
26
|
chọn phần class cần dùng.
|
|
27
27
|
|
|
28
|
-
| Import | Nội dung
|
|
29
|
-
| -------------------------------------------------- |
|
|
30
|
-
| `@finhay-pro/leaf-design-system/tokens.css` | Chỉ token (primitive + semantic màu + typography), không class.
|
|
31
|
-
| `@finhay-pro/leaf-design-system/typography.css` | Chỉ class typography.
|
|
32
|
-
| `@finhay-pro/leaf-design-system/color.css` | Chỉ class color.
|
|
33
|
-
| `@finhay-pro/leaf-design-system/button.css` | Style của component `Button`.
|
|
34
|
-
| `@finhay-pro/leaf-design-system/tabs.css` | Style của component `Tabs`.
|
|
35
|
-
| `@finhay-pro/leaf-design-system/dialog.css` | Style của component `Dialog`.
|
|
36
|
-
| `@finhay-pro/leaf-design-system/logo.css` | Style của component `Logo`.
|
|
37
|
-
| `@finhay-pro/leaf-design-system/logo-assets.css` | SVG data-URI cho Logo HTML tĩnh — không nằm trong `classes.css` / `styles.css`.
|
|
38
|
-
| `@finhay-pro/leaf-design-system/skeleton.css` | Style của component `Skeleton`.
|
|
39
|
-
| `@finhay-pro/leaf-design-system/spinner.css` | Style của component `Spinner`.
|
|
40
|
-
| `@finhay-pro/leaf-design-system/toggle.css` | Style của component `Toggle`.
|
|
41
|
-
| `@finhay-pro/leaf-design-system/slider.css` | Style của component `Slider`.
|
|
42
|
-
| `@finhay-pro/leaf-design-system/tooltip.css` | Style của component `Tooltip`.
|
|
43
|
-
| `@finhay-pro/leaf-design-system/radio.css` | Style của component `Radio` / `RadioGroup`.
|
|
44
|
-
| `@finhay-pro/leaf-design-system/checkbox.css` | Style của component `Checkbox`.
|
|
45
|
-
| `@finhay-pro/leaf-design-system/input.css` | Style của component `Input` (field / inline, dùng chung cho `InputDate`).
|
|
46
|
-
| `@finhay-pro/leaf-design-system/input-otp.css` | Style của component `InputOtp`.
|
|
47
|
-
| `@finhay-pro/leaf-design-system/input-stepper.css` | Style của component `InputStepper`.
|
|
48
|
-
| `@finhay-pro/leaf-design-system/calendar.css` | Style của component `Calendar` (cần kèm `button.css`
|
|
49
|
-
| `@finhay-pro/leaf-design-system/input-date.css` | Popover của `InputDate` (
|
|
50
|
-
| `@finhay-pro/leaf-design-system/toast.css` | Style của `Toaster` / `ToastContent`.
|
|
51
|
-
| `@finhay-pro/leaf-design-system/dropdown.css` | Style của component `Dropdown`.
|
|
52
|
-
| `@finhay-pro/leaf-design-system/classes.css` | Tất cả class + component, không token.
|
|
53
|
-
| `@finhay-pro/leaf-design-system/styles.css` | Token + tất cả class + component. Một dòng là đủ.
|
|
28
|
+
| Import | Nội dung |
|
|
29
|
+
| -------------------------------------------------- | ---------------------------------------------------------------------------------------- |
|
|
30
|
+
| `@finhay-pro/leaf-design-system/tokens.css` | Chỉ token (primitive + semantic màu + typography), không class. |
|
|
31
|
+
| `@finhay-pro/leaf-design-system/typography.css` | Chỉ class typography. |
|
|
32
|
+
| `@finhay-pro/leaf-design-system/color.css` | Chỉ class color. |
|
|
33
|
+
| `@finhay-pro/leaf-design-system/button.css` | Style của component `Button`. |
|
|
34
|
+
| `@finhay-pro/leaf-design-system/tabs.css` | Style của component `Tabs`. |
|
|
35
|
+
| `@finhay-pro/leaf-design-system/dialog.css` | Style của component `Dialog`. |
|
|
36
|
+
| `@finhay-pro/leaf-design-system/logo.css` | Style của component `Logo`. |
|
|
37
|
+
| `@finhay-pro/leaf-design-system/logo-assets.css` | SVG data-URI cho Logo HTML tĩnh — không nằm trong `classes.css` / `styles.css`. |
|
|
38
|
+
| `@finhay-pro/leaf-design-system/skeleton.css` | Style của component `Skeleton`. |
|
|
39
|
+
| `@finhay-pro/leaf-design-system/spinner.css` | Style của component `Spinner`. |
|
|
40
|
+
| `@finhay-pro/leaf-design-system/toggle.css` | Style của component `Toggle`. |
|
|
41
|
+
| `@finhay-pro/leaf-design-system/slider.css` | Style của component `Slider`. |
|
|
42
|
+
| `@finhay-pro/leaf-design-system/tooltip.css` | Style của component `Tooltip`. |
|
|
43
|
+
| `@finhay-pro/leaf-design-system/radio.css` | Style của component `Radio` / `RadioGroup`. |
|
|
44
|
+
| `@finhay-pro/leaf-design-system/checkbox.css` | Style của component `Checkbox`. |
|
|
45
|
+
| `@finhay-pro/leaf-design-system/input.css` | Style của component `Input` (field / inline, dùng chung cho `InputDate`). |
|
|
46
|
+
| `@finhay-pro/leaf-design-system/input-otp.css` | Style của component `InputOtp`. |
|
|
47
|
+
| `@finhay-pro/leaf-design-system/input-stepper.css` | Style của component `InputStepper`. |
|
|
48
|
+
| `@finhay-pro/leaf-design-system/calendar.css` | Style của component `Calendar` (cần kèm `button.css` + `color.css`). |
|
|
49
|
+
| `@finhay-pro/leaf-design-system/input-date.css` | Popover của `InputDate` (kèm `input.css` + `calendar.css` + `button.css` + `color.css`). |
|
|
50
|
+
| `@finhay-pro/leaf-design-system/toast.css` | Style của `Toaster` / `ToastContent`. |
|
|
51
|
+
| `@finhay-pro/leaf-design-system/dropdown.css` | Style của component `Dropdown`. |
|
|
52
|
+
| `@finhay-pro/leaf-design-system/classes.css` | Tất cả class + component, không token. |
|
|
53
|
+
| `@finhay-pro/leaf-design-system/styles.css` | Token + tất cả class + component. Một dòng là đủ. |
|
|
54
54
|
|
|
55
55
|
Import bằng CSS:
|
|
56
56
|
|
|
@@ -216,6 +216,35 @@ viết thêm gì cho light mode.
|
|
|
216
216
|
<html data-theme="light"></html>
|
|
217
217
|
```
|
|
218
218
|
|
|
219
|
+
## Icon
|
|
220
|
+
|
|
221
|
+
Mọi icon của Leaf là **Remix Icon** (https://remixicon.com, lưới 24px, bản `-line` / `-fill`) —
|
|
222
|
+
cả icon dựng sẵn trong component (chevron Dropdown / Calendar, check Checkbox / Toggle, close /
|
|
223
|
+
back Dialog, icon Toast…) lẫn icon app tự thêm. Leaf **không** đóng gói lại bộ icon: app dùng thẳng
|
|
224
|
+
package / CDN của Remix. Tra tên icon trên https://remixicon.com.
|
|
225
|
+
|
|
226
|
+
```bash
|
|
227
|
+
pnpm add @remixicon/react
|
|
228
|
+
```
|
|
229
|
+
|
|
230
|
+
```tsx
|
|
231
|
+
import { Button } from "@finhay-pro/leaf-design-system";
|
|
232
|
+
import { RiAddLine, RiHomeLine } from "@remixicon/react";
|
|
233
|
+
|
|
234
|
+
<RiHomeLine size={24} />
|
|
235
|
+
<RiHomeLine size={20} className="text-secondary" /> {/* màu = currentColor → class màu Leaf */}
|
|
236
|
+
<Button leadingIcon={<RiAddLine />}>Thêm</Button> {/* slot icon tự set size */}
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
```html
|
|
240
|
+
<!-- HTML tĩnh: font CSS của Remix, size theo font-size, màu theo color -->
|
|
241
|
+
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/remixicon@4.9.1/fonts/remixicon.css" />
|
|
242
|
+
<i class="ri-home-line text-secondary"></i>
|
|
243
|
+
```
|
|
244
|
+
|
|
245
|
+
Không dùng thư viện icon khác hay tự vẽ SVG icon. Icons by [Remix Icon](https://remixicon.com)
|
|
246
|
+
(Remix Icon License v1.0 — không dùng icon làm logo / nhận diện thương hiệu).
|
|
247
|
+
|
|
219
248
|
## Cần biết
|
|
220
249
|
|
|
221
250
|
- **Class typography chỉ set đúng 3 thuộc tính** (`font-size`, `line-height`, `font-weight`);
|
|
@@ -257,9 +286,9 @@ tuyến token vào `tokens.css` / `styles.css`). Sau đó `scripts/build-cdn.mjs
|
|
|
257
286
|
`dist/cdn/leaf-<version>.min.{css,js}`. Không sửa file trong `dist`.
|
|
258
287
|
|
|
259
288
|
`build` ghi đè `dist` tại chỗ, **không xoá `dist` trước** (chỉ `prepublishOnly` mới `clean`):
|
|
260
|
-
`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ì
|
|
261
|
-
|
|
262
|
-
|
|
289
|
+
`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ì dev server
|
|
290
|
+
của docs lỗi resolve `@finhay-pro/leaf-design-system/…css`. Gặp lỗi đó: chạy lại `pnpm dev` (vẫn lỗi
|
|
291
|
+
thì xoá `apps/docs/node_modules/.vite`).
|
|
263
292
|
|
|
264
293
|
**Mọi hình thức nằm trong CSS** và chỉ đọc attribute (`data-*`, `aria-*`, `:disabled`), kể cả
|
|
265
294
|
typography của label. Component React chỉ gắn attribute, không gắn class theo prop — nhờ vậy HTML
|
|
@@ -276,7 +305,7 @@ Thêm component React (khi thật sự cần state/behavior, không phải để
|
|
|
276
305
|
`src/components/<Tên>/` (kèm `<tên>.css` nếu cần) rồi re-export trong `src/index.ts`. CSS của
|
|
277
306
|
component cũng ra `dist/<tên>.css` và được gom vào `classes.css` / `styles.css` — nhớ thêm dòng
|
|
278
307
|
`"./<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).
|
|
279
|
-
Component có hành vi (Tabs · Toggle · Dialog · Slider · Tooltip · InputOtp · InputStepper · Toast · Dropdown) cần thêm bản vanilla cho HTML
|
|
308
|
+
Component có hành vi (Button loading · Tabs · Toggle · Dialog · Slider · Tooltip · InputOtp · InputStepper · Toast · Dropdown) cần thêm bản vanilla cho HTML
|
|
280
309
|
tĩnh trong `src/vanilla/` và gắn vào `window.Leaf` qua `src/vanilla/index.ts`. `src/vanilla` chỉ
|
|
281
310
|
vào bản CDN, không vào bản npm.
|
|
282
311
|
|
|
@@ -305,16 +334,16 @@ vào bản CDN, không vào bản npm.
|
|
|
305
334
|
| `LanguageDropdown` | Chọn ngôn ngữ Tiếng Việt / English kèm cờ (CDN Finhay) — danh sách ở `LEAF_LANGUAGES`, `value` kiểu `LeafLanguageCode`; mặc định `size="sm"`, `openOn="hover"`, `align="end"` |
|
|
306
335
|
|
|
307
336
|
```css
|
|
308
|
-
/* Ngoài tokens.css + typography.css, mỗi component cần CSS riêng của nó
|
|
337
|
+
/* Ngoài tokens.css + typography.css, mỗi component cần CSS riêng của nó
|
|
338
|
+
(bảng đầy đủ ở mục Import CSS) — hoặc một dòng styles.css cho tất cả */
|
|
309
339
|
@import "@finhay-pro/leaf-design-system/button.css";
|
|
310
340
|
@import "@finhay-pro/leaf-design-system/tabs.css";
|
|
311
341
|
@import "@finhay-pro/leaf-design-system/dialog.css";
|
|
312
|
-
@import "@finhay-pro/leaf-design-system/
|
|
313
|
-
@import "@finhay-pro/leaf-design-system/
|
|
314
|
-
@import "@finhay-pro/leaf-design-system/
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
@import "@finhay-pro/leaf-design-system/tooltip.css";
|
|
342
|
+
@import "@finhay-pro/leaf-design-system/toast.css";
|
|
343
|
+
@import "@finhay-pro/leaf-design-system/input.css";
|
|
344
|
+
@import "@finhay-pro/leaf-design-system/dropdown.css";
|
|
345
|
+
/* … skeleton / spinner / toggle / slider / tooltip / radio / checkbox / input-otp /
|
|
346
|
+
input-stepper / calendar / input-date / logo */
|
|
318
347
|
```
|
|
319
348
|
|
|
320
349
|
```tsx
|
|
@@ -328,14 +357,29 @@ import {
|
|
|
328
357
|
Toggle,
|
|
329
358
|
Slider,
|
|
330
359
|
Tooltip,
|
|
360
|
+
Radio,
|
|
361
|
+
RadioGroup,
|
|
362
|
+
Checkbox,
|
|
363
|
+
Input,
|
|
364
|
+
InputOtp,
|
|
365
|
+
InputStepper,
|
|
366
|
+
InputDate,
|
|
367
|
+
Calendar,
|
|
368
|
+
Dropdown,
|
|
369
|
+
LanguageDropdown,
|
|
370
|
+
Toaster,
|
|
371
|
+
toast,
|
|
331
372
|
} from "@finhay-pro/leaf-design-system";
|
|
373
|
+
import { RiAddLine, RiArrowRightLine } from "@remixicon/react";
|
|
332
374
|
|
|
333
|
-
<Button priority="primary" size="md" leadingIcon={<
|
|
375
|
+
<Button priority="primary" size="md" leadingIcon={<RiAddLine />} trailingIcon={<RiArrowRightLine />}>
|
|
334
376
|
Label
|
|
335
377
|
</Button>
|
|
336
|
-
{/* Chỉ icon → layout tròn */}
|
|
337
|
-
<Button aria-label="Thêm" leadingIcon={<
|
|
338
|
-
|
|
378
|
+
{/* Chỉ icon → layout tròn, bắt buộc aria-label */}
|
|
379
|
+
<Button aria-label="Thêm" leadingIcon={<RiAddLine />} />
|
|
380
|
+
{/* Loading: onClick trả Promise (tự loading tới khi settle) hoặc controlled `loading` —
|
|
381
|
+
không tự nhét <Spinner> vào leadingIcon (Spinner ép màu --base-quinary, không theo màu nút) */}
|
|
382
|
+
<Button size="md" onClick={() => placeOrder()}>
|
|
339
383
|
Mua AAA
|
|
340
384
|
</Button>
|
|
341
385
|
|
|
@@ -349,18 +393,25 @@ import {
|
|
|
349
393
|
{ value: "idle", label: "Mua" },
|
|
350
394
|
]}
|
|
351
395
|
/>
|
|
396
|
+
|
|
397
|
+
{/* Toast: đặt <Toaster /> một lần ở root layout, gọi toast.* ở client */}
|
|
398
|
+
<Toaster />;
|
|
399
|
+
toast.success("Đặt lệnh thành công", { description: "Mua 100 AAA" });
|
|
352
400
|
```
|
|
353
401
|
|
|
354
402
|
## HTML tĩnh (CDN)
|
|
355
403
|
|
|
356
404
|
Cho landing page / trang dựng tay không có bundler: **Leaf CDN + CSS riêng của page**. 1 `<link>` +
|
|
357
405
|
1 `<script>` là dùng được toàn bộ class typography, color và mọi component (CSS). Script chỉ cần
|
|
358
|
-
khi dùng hành vi Tabs · Toggle · Dialog · Slider · Tooltip · InputOtp · InputStepper · Toast · Dropdown (`data-leaf-*`).
|
|
406
|
+
khi dùng hành vi Button loading · Tabs · Toggle · Dialog · Slider · Tooltip · InputOtp · InputStepper · Toast · Dropdown (`data-leaf-*` / `window.Leaf`).
|
|
407
|
+
Calendar / InputDate chưa có bản HTML tĩnh (chỉ React).
|
|
359
408
|
Layout, spacing, responsive của page viết trong CSS của page, dùng token Leaf.
|
|
360
409
|
|
|
361
410
|
```html
|
|
362
|
-
<link rel="stylesheet" href="https://<cdn>/leaf-0.
|
|
363
|
-
<script src="https://<cdn>/leaf-0.
|
|
411
|
+
<link rel="stylesheet" href="https://<cdn>/leaf-0.2.0.min.css" />
|
|
412
|
+
<script src="https://<cdn>/leaf-0.2.0.min.js" defer></script>
|
|
413
|
+
<!-- Icon: Remix Icon (xem mục Icon) -->
|
|
414
|
+
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/remixicon@4.9.1/fonts/remixicon.css" />
|
|
364
415
|
|
|
365
416
|
<style>
|
|
366
417
|
/* CSS của page — bọc trong @layer để không đè nhầm CSS component (xem "Cần biết") */
|
|
@@ -394,17 +445,25 @@ Layout, spacing, responsive của page viết trong CSS của page, dùng token
|
|
|
394
445
|
</section>
|
|
395
446
|
```
|
|
396
447
|
|
|
397
|
-
| File | Nội dung
|
|
398
|
-
| ------------------------ |
|
|
399
|
-
| `leaf-<version>.min.css` | `styles.css` đã minify: token + typography + color + CSS của mọi component.
|
|
400
|
-
| `leaf-<version>.min.js` | Hành vi Tabs · Toggle · Dialog · Slider · Tooltip · InputOtp · InputStepper · Toast · Dropdown → `window.Leaf`. Trang CSS-only có thể bỏ. |
|
|
448
|
+
| File | Nội dung |
|
|
449
|
+
| ------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
450
|
+
| `leaf-<version>.min.css` | `styles.css` đã minify: token + typography + color + CSS của mọi component. |
|
|
451
|
+
| `leaf-<version>.min.js` | Hành vi Button loading · Tabs · Toggle · Dialog · Slider · Tooltip · InputOtp · InputStepper · Toast · Dropdown → `window.Leaf`. Trang CSS-only có thể bỏ. |
|
|
401
452
|
|
|
402
|
-
|
|
453
|
+
Bản CDN nằm trong package npm (`dist/cdn/`), nên jsDelivr phục vụ trực tiếp theo version:
|
|
454
|
+
`https://cdn.jsdelivr.net/npm/@finhay-pro/leaf-design-system@<version>/dist/cdn/leaf-<version>.min.css`
|
|
455
|
+
(và `.min.js`) — cũng là link trên trang docs **Develop → Web** (`apps/docs/config/shared.ts` →
|
|
456
|
+
`leafCdn`). Trang demo đủ mọi component có bản HTML tĩnh:
|
|
403
457
|
[`examples/static.html`](examples/static.html) (mở bằng `file://` sau khi build).
|
|
404
458
|
|
|
459
|
+
`leaf.js` nạp bằng `defer` — code gọi `Leaf.*` ngay khi tải trang phải đặt trong
|
|
460
|
+
`document.addEventListener("DOMContentLoaded", …)` (handler click / event thì không cần).
|
|
461
|
+
|
|
405
462
|
### Button
|
|
406
463
|
|
|
407
|
-
Không cần JS. Thiếu attribute nào thì lấy mặc định giống prop React.
|
|
464
|
+
Không cần JS, trừ trạng thái loading. Thiếu attribute nào thì lấy mặc định giống prop React. Nút
|
|
465
|
+
có icon thì bọc chữ trong `span.leaf-button__label` — `Leaf.button.setLoading` dựa vào nó để biết
|
|
466
|
+
icon nào là leading. CTA điều hướng dùng được `<a class="leaf-button" href="…">`.
|
|
408
467
|
|
|
409
468
|
| Attribute | Giá trị | Mặc định |
|
|
410
469
|
| ---------------------------- | --------------------------------------------- | --------- |
|
|
@@ -438,13 +497,16 @@ khoá `min-width`, nút đang loading không nhận click (kể cả handler c
|
|
|
438
497
|
`Leaf.dialog.open`. Đóng: Escape / backdrop / `data-leaf-dialog-close` /
|
|
439
498
|
`Leaf.dialog.close(el, reason?)` — `leaf:dialog-close` mang `detail.reason`
|
|
440
499
|
(`close` · `backdrop` · `escape` · `api`). `data-leaf-dialog-dismissible="false"` tắt đóng bằng
|
|
441
|
-
backdrop / Escape. Back: `data-leaf-dialog-back` → `leaf:dialog-back` (không tự
|
|
442
|
-
con khác của `<body>` được đặt `inert` — đặt dialog tĩnh là con trực tiếp của
|
|
500
|
+
backdrop / Escape (nút X vẫn đóng). Back: `data-leaf-dialog-back` → `leaf:dialog-back` (không tự
|
|
501
|
+
đóng). Khi mở, các con khác của `<body>` được đặt `inert` — đặt dialog tĩnh là **con trực tiếp của
|
|
502
|
+
`<body>`** và luôn bắt đầu bằng `hidden` (dialog hiện sẵn lúc load không được khoá cuộn / focus
|
|
503
|
+
trap / `inert`).
|
|
443
504
|
|
|
444
505
|
### Slider
|
|
445
506
|
|
|
446
507
|
`data-leaf-slider` trên `.leaf-slider` + `data-min` / `data-max` / `data-step` / `data-value`
|
|
447
|
-
(mặc định 0 / 100 / 1 / min).
|
|
508
|
+
(mặc định 0 / 100 / 1 / min). Slider tĩnh **cần leaf.js cả để hiển thị đúng**: vị trí mốc / label
|
|
509
|
+
và `--leaf-slider-fill` do leaf.js tính. `Leaf.slider.set(el, value)` · `leaf:slider-input` (liên tục khi kéo)
|
|
448
510
|
· `leaf:slider-change` (khi chốt). Sync `--leaf-slider-fill` (fill + thumb) / `data-state` mốc;
|
|
449
511
|
thiếu `.leaf-slider__thumb` thì leaf.js tự tạo. Có `input.leaf-slider__input[type=hidden]` trong
|
|
450
512
|
markup thì leaf.js ghi giá trị đã chốt vào đó (form). Toggle tương tự với
|
|
@@ -457,18 +519,24 @@ Hover/focus: `.leaf-tooltip-trigger` + `data-leaf-tooltip` + `data-content` (ho
|
|
|
457
519
|
`data-leaf-tooltip-trigger="click"` để bấm mở/đóng, `data-focusable` khi trigger là icon thuần
|
|
458
520
|
(không có phần tử focus được — leaf.js gắn `tabindex` / `role="button"`), `data-open-delay` /
|
|
459
521
|
`data-close-delay` (ms), `data-flip="false"` tắt tự lật phía khi thiếu chỗ. Bubble kế thừa
|
|
460
|
-
`data-theme` của khối bọc trigger.
|
|
522
|
+
`data-theme` của khối bọc trigger. leaf.js dựng bubble một lần ở lần hiện đầu tiên — đổi
|
|
523
|
+
`data-content` / `data-size` sau đó không có tác dụng (`data-position` / `data-align` / `data-flip`
|
|
524
|
+
thì đọc lại mỗi lần đặt vị trí). Bubble `pointer-events: none` — không đặt link / nút bên trong.
|
|
461
525
|
|
|
462
526
|
### Logo
|
|
463
527
|
|
|
464
528
|
Span rỗng `.leaf-logo` + `data-brand` / `data-mode` / `data-side` + `--leaf-logo-size`. CSS gắn
|
|
465
|
-
SVG data-URI — không cần JS.
|
|
529
|
+
SVG data-URI — không cần JS. Khác React, HTML tĩnh **không có mặc định**: wordmark phải đủ cả ba
|
|
530
|
+
attribute, và span phải rỗng tuyệt đối (`:empty` — không có khoảng trắng bên trong), thiếu là ra ô
|
|
531
|
+
trống. `data-mode` theo nền phía sau (`dark` = nền tối), không tự đổi theo `data-theme`. Bản CDN đã gộp sẵn data-URI; dùng qua npm thì import thêm
|
|
466
532
|
`logo-assets.css` (không nằm trong `classes.css` / `styles.css` vì component React không cần).
|
|
467
533
|
|
|
468
534
|
### Radio / Checkbox / Input
|
|
469
535
|
|
|
470
536
|
Chỉ CSS — markup như tab **Code → HTML tĩnh**. Input đọc `data-variant` / `data-shape` /
|
|
471
|
-
`data-invalid` / `data-disabled` trên `.leaf-input`.
|
|
537
|
+
`data-invalid` / `data-disabled` / `data-filled` trên `.leaf-input`. Không có JS nào tự set
|
|
538
|
+
`data-filled` (label đổi màu khi có giá trị) hay ẩn/hiện mật khẩu ở HTML tĩnh — cần thì trang tự
|
|
539
|
+
viết. Checkbox là một `<label>` bọc cả hàng: không đặt link bên trong.
|
|
472
540
|
|
|
473
541
|
### InputOtp
|
|
474
542
|
|
|
@@ -495,7 +563,9 @@ chạy hết đều đóng toast. Event `leaf:toast-show` / `leaf:toast-dismiss`
|
|
|
495
563
|
|
|
496
564
|
`data-leaf-dropdown` trên `.leaf-dropdown` (markup như tab **Code → HTML tĩnh**) + `data-variant` /
|
|
497
565
|
`data-trigger` / `data-appearance` / `data-size` / `data-align`; `data-open-on="hover"` để rê chuột
|
|
498
|
-
mở.
|
|
566
|
+
mở. CSS không suy trigger từ variant: `data-variant="radio"` cần kèm `data-trigger="text"` mới
|
|
567
|
+
giống React. Trigger `filled` có nền `--base-secondary` — đặt trên card `bg-secondary` thì dùng
|
|
568
|
+
`data-appearance="outlined"`. Option `.leaf-dropdown__option[data-value]`, mục chọn `aria-selected="true"`, disabled
|
|
499
569
|
`aria-disabled="true"`. `Leaf.dropdown.open` / `close` / `select(el, value)` ·
|
|
500
570
|
`leaf:dropdown-change`. Có `input.leaf-dropdown__input` thì leaf.js ghi value vào đó. Panel nằm ngay
|
|
501
571
|
dưới trigger (không portal) — tránh đặt trong khung `overflow: hidden / auto` thấp hơn panel.
|
|
@@ -531,13 +601,72 @@ Chỉ CSS. Skeleton: `--leaf-skeleton-width` / `height` / `radius`. Spinner: `da
|
|
|
531
601
|
1. Bump `version` trong `packages/react/package.json`, ghi thay đổi vào [Changelog](#changelog).
|
|
532
602
|
2. `pnpm --filter @finhay-pro/leaf-design-system build` → `dist/cdn/leaf-<version>.min.css` + `.min.js`.
|
|
533
603
|
3. Đổi version trong `examples/static.html`, mở bằng `file://` để kiểm tra nhanh.
|
|
534
|
-
4.
|
|
535
|
-
|
|
536
|
-
5.
|
|
537
|
-
|
|
604
|
+
4. Publish lên npm (`pnpm publish` trong `packages/react`) — link jsDelivr của version mới chỉ
|
|
605
|
+
chạy sau bước này.
|
|
606
|
+
5. Cập nhật `leafCdnVersion` trong `apps/docs/config/shared.ts` (cùng version) và version trong
|
|
607
|
+
link CDN của `skills/leaf-design-system`. Landing đang dùng link version cũ vẫn chạy bình thường.
|
|
538
608
|
|
|
539
609
|
## Changelog
|
|
540
610
|
|
|
611
|
+
### 0.2.0
|
|
612
|
+
|
|
613
|
+
**Icon — Remix Icon**
|
|
614
|
+
|
|
615
|
+
- Mọi icon dựng sẵn trong component chuyển sang Remix Icon (svg 24×24, `fill="currentColor"`):
|
|
616
|
+
chevron `Dropdown` / `Calendar` (`arrow-down-s-line`, `arrow-left-s-line`, `arrow-right-s-line`),
|
|
617
|
+
check `Checkbox` / `Toggle` (`check-line`, `subtract-line`), `Dialog` (`arrow-left-line`,
|
|
618
|
+
`close-line`), `Input` password (`eye-line` / `eye-off-line`), `InputStepper` (`subtract-line` /
|
|
619
|
+
`add-line`), `InputDate` (`calendar-line`). React và leaf.js dùng chung path
|
|
620
|
+
(`src/core/icons.ts`).
|
|
621
|
+
- `Toast`: icon status là `checkbox-circle-fill` / `close-circle-fill` / `error-warning-fill`
|
|
622
|
+
tô màu accent, **bỏ nền tròn** quanh icon (`.leaf-toast__icon` không còn padding / background).
|
|
623
|
+
Nút đóng `close-line`.
|
|
624
|
+
- Markup HTML tĩnh viết tay theo bản cũ (svg stroke) vẫn chạy, nhưng nên đổi sang svg Remix như
|
|
625
|
+
snippet trên docs để khớp nét.
|
|
626
|
+
- Icon app tự thêm: dùng `@remixicon/react` (React) / font `ri-*` (HTML tĩnh) — xem mục Icon.
|
|
627
|
+
Leaf không phụ thuộc và không đóng gói lại Remix Icon.
|
|
628
|
+
- Docs: icon của docs dùng `@remixicon/react`; snippet HTML tĩnh kèm link CSS của Remix. Claude
|
|
629
|
+
skill thêm `references/icons.md`, `check-leaf` cảnh báo thư viện icon khác / svg viết tay.
|
|
630
|
+
|
|
631
|
+
### 0.1.9
|
|
632
|
+
|
|
633
|
+
**Thay đổi hành vi** (kiểm tra nếu app đang dựa vào hành vi cũ)
|
|
634
|
+
|
|
635
|
+
- `Dropdown` disabled: input ẩn (`name`) cũng `disabled` → **không còn gửi giá trị** trong
|
|
636
|
+
`FormData`, giống input native. React đổi ngay; leaf.js đồng bộ theo trigger `disabled` lúc
|
|
637
|
+
`init`.
|
|
638
|
+
- `Slider`: `aria-label` / `aria-labelledby` truyền vào `<Slider>` chuyển từ div gốc xuống control
|
|
639
|
+
`role="slider"` (trước đây control không có tên khi không có `title`). Có cả `title` lẫn
|
|
640
|
+
`aria-label` thì `aria-label` thắng.
|
|
641
|
+
- `Slider`: `style` của app giờ thắng biến lấy từ prop (`--leaf-slider-active` / `-mark` /
|
|
642
|
+
`-mark-active`); `--leaf-slider-fill` vẫn do component tính.
|
|
643
|
+
|
|
644
|
+
**Sửa lỗi**
|
|
645
|
+
|
|
646
|
+
- `Dropdown` (React): `aria-describedby` gắn lên trigger (combobox) thay vì div gốc — nối được text
|
|
647
|
+
lỗi với ô chọn.
|
|
648
|
+
- `Toggle`: `aria-disabled="true"` ra giao diện disabled (`toggle.css` đọc thêm
|
|
649
|
+
`[aria-disabled="true"]`) và React chặn đổi trạng thái như leaf.js; nút vẫn focus được.
|
|
650
|
+
- `InputDate`: `onValueChange` khai báo đúng `(value: Date) => void` (chưa bao giờ nhận `null`;
|
|
651
|
+
handler kiểu `(value: Date | null) => void` vẫn tương thích). Prop còn lại của `<button>`
|
|
652
|
+
(`aria-label`, `aria-labelledby`, `onBlur`, `onFocus`, `data-*`…) đi xuống nút trigger; `onClick`
|
|
653
|
+
của app chạy trước, `preventDefault()` thì không mở popover.
|
|
654
|
+
|
|
655
|
+
**Docs**
|
|
656
|
+
|
|
657
|
+
- Sửa tên token trong bảng docs (`$bg-*` → `$base-*` — biến thật là `--base-*`), snippet HTML gọi
|
|
658
|
+
`Leaf.*` trước khi leaf.js (`defer`) nạp xong, id không tồn tại trong markup (Checkbox, Dropdown,
|
|
659
|
+
Tabs, Tooltip), mô tả `position` của Tooltip, `data-filled` của Input, phụ thuộc `color.css` của
|
|
660
|
+
Calendar / InputDate, Spinner lồng trong Button (dùng `loading`).
|
|
661
|
+
- Ghi rõ: Button đang loading mang màu disabled (tạm khoá, có chủ đích); Dialog tĩnh phải là con
|
|
662
|
+
trực tiếp của `<body>` và bắt đầu bằng `hidden`; Logo tĩnh bắt buộc đủ `data-brand` /
|
|
663
|
+
`data-mode` / `data-side`; Slider tĩnh cần leaf.js để hiển thị đúng; khác biệt API Toast React ↔
|
|
664
|
+
leaf.js; link CDN dự phòng qua jsDelivr.
|
|
665
|
+
- `examples/static.html` đủ mọi component có bản HTML tĩnh (thêm Radio, Checkbox, Input, InputOtp,
|
|
666
|
+
InputStepper, Dropdown, Toast).
|
|
667
|
+
- Thêm Claude skill `skills/leaf-design-system` (dựng UI bằng Leaf + Tailwind cho Next.js / React /
|
|
668
|
+
landing page).
|
|
669
|
+
|
|
541
670
|
### 0.1.8
|
|
542
671
|
|
|
543
672
|
**Breaking**
|
package/dist/button.css
CHANGED
|
@@ -194,7 +194,8 @@
|
|
|
194
194
|
/*
|
|
195
195
|
* Loading — `data-loading="true"` (React: `loading` / onClick trả Promise; HTML tĩnh:
|
|
196
196
|
* `Leaf.button.setLoading`). Spinner thay leading icon, ăn --leaf-button-icon-size và
|
|
197
|
-
* màu ch
|
|
197
|
+
* màu chữ. Nút gắn `aria-disabled="true"` (không dùng `:disabled` để vẫn giữ focus) nên
|
|
198
|
+
* mang màu disabled như rule ở trên — có chủ đích: đang xử lý = tạm khoá.
|
|
198
199
|
*/
|
|
199
200
|
.leaf-button[data-loading="true"] {
|
|
200
201
|
cursor: progress;
|