@finhay-pro/leaf-design-system 0.1.7 → 0.1.8
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 +291 -196
- package/dist/button.css +19 -12
- package/dist/calendar.css +325 -0
- package/dist/cdn/leaf-0.1.8.min.css +2 -0
- package/dist/cdn/leaf-0.1.8.min.js +2 -0
- package/dist/checkbox.css +132 -0
- package/dist/classes.css +2265 -3152
- package/dist/color.css +1 -1
- package/dist/components/Button/Button.d.ts.map +1 -1
- package/dist/components/Button/Button.js +3 -3
- package/dist/components/Button/Button.js.map +1 -1
- package/dist/components/Calendar/Calendar.d.ts +49 -0
- package/dist/components/Calendar/Calendar.d.ts.map +1 -0
- package/dist/components/Calendar/Calendar.js +167 -0
- package/dist/components/Calendar/Calendar.js.map +1 -0
- package/dist/components/Calendar/index.d.ts +2 -0
- package/dist/components/Calendar/index.d.ts.map +1 -0
- package/dist/components/Calendar/index.js +2 -0
- package/dist/components/Calendar/index.js.map +1 -0
- package/dist/components/Checkbox/Checkbox.d.ts +25 -0
- package/dist/components/Checkbox/Checkbox.d.ts.map +1 -0
- package/dist/components/Checkbox/Checkbox.js +40 -0
- package/dist/components/Checkbox/Checkbox.js.map +1 -0
- package/dist/components/Checkbox/index.d.ts +2 -0
- package/dist/components/Checkbox/index.d.ts.map +1 -0
- package/dist/components/Checkbox/index.js +2 -0
- package/dist/components/Checkbox/index.js.map +1 -0
- package/dist/components/Dialog/Dialog.d.ts.map +1 -1
- package/dist/components/Dialog/Dialog.js +1 -1
- package/dist/components/Dialog/Dialog.js.map +1 -1
- package/dist/components/Dropdown/Dropdown.d.ts +62 -0
- package/dist/components/Dropdown/Dropdown.d.ts.map +1 -0
- package/dist/components/Dropdown/Dropdown.js +197 -0
- package/dist/components/Dropdown/Dropdown.js.map +1 -0
- package/dist/components/Dropdown/LanguageDropdown.d.ts +15 -0
- package/dist/components/Dropdown/LanguageDropdown.d.ts.map +1 -0
- package/dist/components/Dropdown/LanguageDropdown.js +18 -0
- package/dist/components/Dropdown/LanguageDropdown.js.map +1 -0
- package/dist/components/Dropdown/index.d.ts +4 -0
- package/dist/components/Dropdown/index.d.ts.map +1 -0
- package/dist/components/Dropdown/index.js +5 -0
- package/dist/components/Dropdown/index.js.map +1 -0
- package/dist/components/Input/Input.d.ts +57 -0
- package/dist/components/Input/Input.d.ts.map +1 -0
- package/dist/components/Input/Input.js +78 -0
- package/dist/components/Input/Input.js.map +1 -0
- package/dist/components/Input/InputDate.d.ts +56 -0
- package/dist/components/Input/InputDate.d.ts.map +1 -0
- package/dist/components/Input/InputDate.js +119 -0
- package/dist/components/Input/InputDate.js.map +1 -0
- package/dist/components/Input/InputOtp.d.ts +33 -0
- package/dist/components/Input/InputOtp.d.ts.map +1 -0
- package/dist/components/Input/InputOtp.js +96 -0
- package/dist/components/Input/InputOtp.js.map +1 -0
- package/dist/components/Input/InputStepper.d.ts +42 -0
- package/dist/components/Input/InputStepper.d.ts.map +1 -0
- package/dist/components/Input/InputStepper.js +86 -0
- package/dist/components/Input/InputStepper.js.map +1 -0
- package/dist/components/Input/index.d.ts +5 -0
- package/dist/components/Input/index.d.ts.map +1 -0
- package/dist/components/Input/index.js +5 -0
- package/dist/components/Input/index.js.map +1 -0
- package/dist/components/Logo/Logo.d.ts.map +1 -1
- package/dist/components/Logo/Logo.js +2 -2
- package/dist/components/Logo/Logo.js.map +1 -1
- package/dist/components/Radio/Radio.d.ts +39 -0
- package/dist/components/Radio/Radio.d.ts.map +1 -0
- package/dist/components/Radio/Radio.js +50 -0
- package/dist/components/Radio/Radio.js.map +1 -0
- package/dist/components/Radio/index.d.ts +2 -0
- package/dist/components/Radio/index.d.ts.map +1 -0
- package/dist/components/Radio/index.js +2 -0
- package/dist/components/Radio/index.js.map +1 -0
- package/dist/components/Skeleton/Skeleton.js +1 -1
- package/dist/components/Skeleton/Skeleton.js.map +1 -1
- package/dist/components/Slider/Slider.js +2 -2
- package/dist/components/Slider/Slider.js.map +1 -1
- package/dist/components/Spinner/Spinner.d.ts.map +1 -1
- package/dist/components/Spinner/Spinner.js +2 -2
- package/dist/components/Spinner/Spinner.js.map +1 -1
- package/dist/components/Tabs/Tabs.d.ts.map +1 -1
- package/dist/components/Tabs/Tabs.js +3 -3
- package/dist/components/Tabs/Tabs.js.map +1 -1
- package/dist/components/Toast/Toast.d.ts +66 -0
- package/dist/components/Toast/Toast.d.ts.map +1 -0
- package/dist/components/Toast/Toast.js +77 -0
- package/dist/components/Toast/Toast.js.map +1 -0
- package/dist/components/Toast/index.d.ts +2 -0
- package/dist/components/Toast/index.d.ts.map +1 -0
- package/dist/components/Toast/index.js +2 -0
- package/dist/components/Toast/index.js.map +1 -0
- package/dist/components/Toggle/Toggle.d.ts.map +1 -1
- package/dist/components/Toggle/Toggle.js +1 -1
- package/dist/components/Toggle/Toggle.js.map +1 -1
- package/dist/components/Tooltip/Tooltip.d.ts.map +1 -1
- package/dist/components/Tooltip/Tooltip.js +2 -2
- package/dist/components/Tooltip/Tooltip.js.map +1 -1
- package/dist/core/calendar.d.ts +36 -0
- package/dist/core/calendar.d.ts.map +1 -0
- package/dist/core/calendar.js +65 -0
- package/dist/core/calendar.js.map +1 -0
- package/dist/core/dropdown.d.ts +66 -0
- package/dist/core/dropdown.d.ts.map +1 -0
- package/dist/core/dropdown.js +131 -0
- package/dist/core/dropdown.js.map +1 -0
- package/dist/core/language.d.ts +25 -0
- package/dist/core/language.d.ts.map +1 -0
- package/dist/core/language.js +17 -0
- package/dist/core/language.js.map +1 -0
- package/dist/core/otp.d.ts +30 -0
- package/dist/core/otp.d.ts.map +1 -0
- package/dist/core/otp.js +65 -0
- package/dist/core/otp.js.map +1 -0
- package/dist/core/stepper.d.ts +39 -0
- package/dist/core/stepper.d.ts.map +1 -0
- package/dist/core/stepper.js +109 -0
- package/dist/core/stepper.js.map +1 -0
- package/dist/core/toast.d.ts +67 -0
- package/dist/core/toast.d.ts.map +1 -0
- package/dist/core/toast.js +102 -0
- package/dist/core/toast.js.map +1 -0
- package/dist/dialog.css +42 -4
- package/dist/dropdown.css +303 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -0
- package/dist/index.js.map +1 -1
- package/dist/input-date.css +49 -0
- package/dist/input-otp.css +76 -0
- package/dist/input-stepper.css +179 -0
- package/dist/input.css +218 -0
- package/dist/logo.css +7 -2
- package/dist/radio.css +124 -0
- package/dist/skeleton.css +4 -0
- package/dist/slider.css +36 -6
- package/dist/spinner.css +16 -2
- package/dist/styles.css +2265 -3188
- package/dist/tabs.css +15 -3
- package/dist/toast.css +234 -0
- package/dist/toggle.css +11 -2
- package/dist/tokens.css +0 -36
- package/dist/tooltip.css +17 -3
- package/package.json +10 -9
- package/dist/border.css +0 -182
- package/dist/cdn/leaf-0.1.7.min.css +0 -2
- package/dist/cdn/leaf-0.1.7.min.js +0 -2
- package/dist/flex.css +0 -229
- package/dist/grid.css +0 -533
- package/dist/overflow.css +0 -72
- package/dist/position.css +0 -140
- package/dist/sizing.css +0 -377
- package/dist/spacing.css +0 -906
- package/dist/text-layout.css +0 -219
package/README.md
CHANGED
|
@@ -1,14 +1,18 @@
|
|
|
1
1
|
# @finhay-pro/leaf-design-system
|
|
2
2
|
|
|
3
|
-
Design system của Finhay
|
|
4
|
-
[`@finhay/leaf-tokens`](../tokens)
|
|
3
|
+
Design system của Finhay: **2 bộ token — Color và Typography** (CSS variables trong
|
|
4
|
+
[`@finhay/leaf-tokens`](../tokens)), **class typography / màu dùng sẵn** và **component** (React +
|
|
5
|
+
HTML tĩnh dùng chung markup). Màu và chữ luôn đọc từ token; spacing / radius / độ dày viền không
|
|
6
|
+
phải token của Leaf — component tự khai báo trong CSS của nó, app dùng Tailwind hoặc CSS của page.
|
|
5
7
|
|
|
6
|
-
|
|
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.
|
|
8
|
+
Leaf **không** có class layout / spacing / responsive. Phần đó thuộc về app, theo 2 cách dùng:
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
| Loại project | Leaf cung cấp | Layout · spacing · responsive · hover |
|
|
11
|
+
| ------------------- | ------------------------------------------ | ------------------------------------- |
|
|
12
|
+
| Next.js (có bundle) | Token + class typography / màu + component | **Tailwind CSS v4** |
|
|
13
|
+
| Landing page tĩnh | Bản CDN (1 `<link>` + 1 `<script>`) | **CSS riêng của page** |
|
|
14
|
+
|
|
15
|
+
Xem [Dùng với Next.js + Tailwind](#dùng-với-nextjs--tailwind) và [HTML tĩnh (CDN)](#html-tĩnh-cdn).
|
|
12
16
|
|
|
13
17
|
## Cài đặt
|
|
14
18
|
|
|
@@ -21,31 +25,32 @@ pnpm add @finhay-pro/leaf-design-system
|
|
|
21
25
|
Class chỉ đọc `var(--…)`, không tự khai báo giá trị — nên **luôn import `tokens.css` trước**, rồi
|
|
22
26
|
chọn phần class cần dùng.
|
|
23
27
|
|
|
24
|
-
| Import
|
|
25
|
-
|
|
|
26
|
-
| `@finhay-pro/leaf-design-system/tokens.css`
|
|
27
|
-
| `@finhay-pro/leaf-design-system/typography.css`
|
|
28
|
-
| `@finhay-pro/leaf-design-system/color.css`
|
|
29
|
-
| `@finhay-pro/leaf-design-system/
|
|
30
|
-
| `@finhay-pro/leaf-design-system/
|
|
31
|
-
| `@finhay-pro/leaf-design-system/
|
|
32
|
-
| `@finhay-pro/leaf-design-system/
|
|
33
|
-
| `@finhay-pro/leaf-design-system/
|
|
34
|
-
| `@finhay-pro/leaf-design-system/
|
|
35
|
-
| `@finhay-pro/leaf-design-system/
|
|
36
|
-
| `@finhay-pro/leaf-design-system/
|
|
37
|
-
| `@finhay-pro/leaf-design-system/
|
|
38
|
-
| `@finhay-pro/leaf-design-system/
|
|
39
|
-
| `@finhay-pro/leaf-design-system/
|
|
40
|
-
| `@finhay-pro/leaf-design-system/
|
|
41
|
-
| `@finhay-pro/leaf-design-system/
|
|
42
|
-
| `@finhay-pro/leaf-design-system/
|
|
43
|
-
| `@finhay-pro/leaf-design-system/
|
|
44
|
-
| `@finhay-pro/leaf-design-system/
|
|
45
|
-
| `@finhay-pro/leaf-design-system/
|
|
46
|
-
| `@finhay-pro/leaf-design-system/
|
|
47
|
-
| `@finhay-pro/leaf-design-system/
|
|
48
|
-
| `@finhay-pro/leaf-design-system/
|
|
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` cho footer). |
|
|
49
|
+
| `@finhay-pro/leaf-design-system/input-date.css` | Popover của `InputDate` (cần kèm `input.css` + `calendar.css` + `button.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à đủ. |
|
|
49
54
|
|
|
50
55
|
Import bằng CSS:
|
|
51
56
|
|
|
@@ -53,17 +58,9 @@ Import bằng CSS:
|
|
|
53
58
|
/* 1. Token — luôn đứng đầu */
|
|
54
59
|
@import "@finhay-pro/leaf-design-system/tokens.css";
|
|
55
60
|
|
|
56
|
-
/* 2.
|
|
61
|
+
/* 2. Class typography + màu */
|
|
57
62
|
@import "@finhay-pro/leaf-design-system/typography.css";
|
|
58
63
|
@import "@finhay-pro/leaf-design-system/color.css";
|
|
59
|
-
@import "@finhay-pro/leaf-design-system/spacing.css";
|
|
60
|
-
@import "@finhay-pro/leaf-design-system/border.css";
|
|
61
|
-
@import "@finhay-pro/leaf-design-system/flex.css";
|
|
62
|
-
@import "@finhay-pro/leaf-design-system/grid.css";
|
|
63
|
-
@import "@finhay-pro/leaf-design-system/sizing.css";
|
|
64
|
-
@import "@finhay-pro/leaf-design-system/overflow.css";
|
|
65
|
-
@import "@finhay-pro/leaf-design-system/position.css";
|
|
66
|
-
@import "@finhay-pro/leaf-design-system/text-layout.css";
|
|
67
64
|
|
|
68
65
|
/* 3. Component nào dùng thì import cái đó */
|
|
69
66
|
@import "@finhay-pro/leaf-design-system/button.css";
|
|
@@ -75,13 +72,67 @@ Import bằng CSS:
|
|
|
75
72
|
@import "@finhay-pro/leaf-design-system/toggle.css";
|
|
76
73
|
@import "@finhay-pro/leaf-design-system/slider.css";
|
|
77
74
|
@import "@finhay-pro/leaf-design-system/tooltip.css";
|
|
75
|
+
@import "@finhay-pro/leaf-design-system/radio.css";
|
|
76
|
+
@import "@finhay-pro/leaf-design-system/checkbox.css";
|
|
77
|
+
@import "@finhay-pro/leaf-design-system/input.css";
|
|
78
|
+
@import "@finhay-pro/leaf-design-system/input-otp.css";
|
|
79
|
+
@import "@finhay-pro/leaf-design-system/input-stepper.css";
|
|
80
|
+
@import "@finhay-pro/leaf-design-system/calendar.css";
|
|
81
|
+
@import "@finhay-pro/leaf-design-system/input-date.css";
|
|
82
|
+
@import "@finhay-pro/leaf-design-system/toast.css";
|
|
83
|
+
@import "@finhay-pro/leaf-design-system/dropdown.css";
|
|
78
84
|
```
|
|
79
85
|
|
|
80
86
|
Muốn gọn thì một dòng `@import "@finhay-pro/leaf-design-system/styles.css";` thay cho cả khối trên.
|
|
81
87
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
88
|
+
CSS của component **tự đủ** về layout (display, flex, gap, padding, radius, viền…): chỉ cần
|
|
89
|
+
`tokens.css` + `typography.css` + CSS của component là component hiển thị đúng. Riêng `Calendar`
|
|
90
|
+
gắn thêm class màu (`bg-secondary`, `border-tertiary`…) nên cần cả `color.css`. App đang giữ bộ màu
|
|
91
|
+
riêng có thể bỏ `color.css` (trừ khi dùng `Calendar`).
|
|
92
|
+
|
|
93
|
+
## Dùng với Next.js + Tailwind
|
|
94
|
+
|
|
95
|
+
Leaf lo token, typography, màu và component; Tailwind CSS v4 lo layout, spacing, radius, độ dày
|
|
96
|
+
viền, responsive và state (`hover:`, `md:`…). Cấu hình mẫu trong `globals.css` (site docs
|
|
97
|
+
`apps/docs` dùng đúng cấu hình này):
|
|
98
|
+
|
|
99
|
+
```css
|
|
100
|
+
@layer theme, base, components, utilities;
|
|
101
|
+
|
|
102
|
+
/* Leaf trước Tailwind utilities → class Tailwind override được class màu Leaf khi cần */
|
|
103
|
+
@import "@finhay-pro/leaf-design-system/styles.css";
|
|
104
|
+
@import "tailwindcss";
|
|
105
|
+
|
|
106
|
+
/* Màu và cỡ chữ chỉ lấy từ Leaf — tắt palette và thang font-size của Tailwind */
|
|
107
|
+
@theme {
|
|
108
|
+
--color-*: initial;
|
|
109
|
+
--text-*: initial;
|
|
110
|
+
}
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
```tsx
|
|
114
|
+
import { Button } from "@finhay-pro/leaf-design-system";
|
|
115
|
+
|
|
116
|
+
<section className="bg-secondary border-quaternary flex flex-col gap-3 rounded-xl border p-4 md:p-6">
|
|
117
|
+
<h3 className="heading-3 text-primary">Tích luỹ</h3>
|
|
118
|
+
<p className="body-4 text-secondary hover:text-(color:--text-highlight)">Lợi nhuận 8.5%/năm</p>
|
|
119
|
+
<Button className="w-full md:w-auto">Đầu tư</Button>
|
|
120
|
+
</section>;
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
- Class typography / màu Leaf giữ nguyên tên (`body-3`, `text-secondary`, `bg-secondary`,
|
|
124
|
+
`border-quaternary`…). Giá trị lẻ dùng token qua cú pháp biến của Tailwind:
|
|
125
|
+
`bg-(--base-tertiary)`, `text-(color:--text-highlight)`.
|
|
126
|
+
- Spacing / radius / độ dày viền dùng thang của Tailwind (base 4px). Thang px theo Figma:
|
|
127
|
+
|
|
128
|
+
| Figma | px | Tailwind |
|
|
129
|
+
| ----------------- | -------------------------------------------------------- | ------------------------------------------------------------------------ |
|
|
130
|
+
| Spacing 2XS…7XL | 2 · 4 · 8 · 12 · 16 · 24 · 36 · 48 · 60 · 84 · 120 · 240 | `0.5` `1` `2` `3` `4` `6` `9` `12` `15` `21` `30` `60` (`p-4`, `gap-3`…) |
|
|
131
|
+
| Radius S/M/L/Full | 4 · 8 · 12 · full | `rounded-sm` / `rounded-lg` / `rounded-xl` / `rounded-full` |
|
|
132
|
+
| Border S/M/L/XL | 0.5 · 1 · 1.5 · 2 | `border-[0.5px]` / `border` / `border-[1.5px]` / `border-2` |
|
|
133
|
+
|
|
134
|
+
- Override CSS của component bằng `className` Tailwind: utility (`@layer utilities`) luôn thắng CSS
|
|
135
|
+
component (`@layer components`), không cần `!important`.
|
|
85
136
|
|
|
86
137
|
## Typography class
|
|
87
138
|
|
|
@@ -128,8 +179,8 @@ Trong React / Next.js, class đi thẳng vào `className` của bất kỳ eleme
|
|
|
128
179
|
```tsx
|
|
129
180
|
<h2 className="heading-2">Tài sản của bạn</h2>
|
|
130
181
|
|
|
131
|
-
// Class typography lo cỡ chữ, color lo màu
|
|
132
|
-
<p className="body-3 text-secondary mt-
|
|
182
|
+
// Class typography lo cỡ chữ, color lo màu; khoảng cách là của app (Tailwind `mt-2`)
|
|
183
|
+
<p className="body-3 text-secondary mt-2">Lợi nhuận kỳ vọng 8.5%/năm</p>
|
|
133
184
|
|
|
134
185
|
// Gắn vào component của thư viện khác cũng chỉ là một chuỗi class
|
|
135
186
|
<Link href="/tai-khoan" className="body-3-highlight">
|
|
@@ -154,7 +205,8 @@ viết thêm gì cho light mode.
|
|
|
154
205
|
| System (đủ 3 bộ) | `text-*`, `bg-*`, `border-*` với `red`, `green`, `yellow`, `orange`, `blue`, `purple` (+ `-secondary`) |
|
|
155
206
|
|
|
156
207
|
```html
|
|
157
|
-
|
|
208
|
+
<!-- Viền: class màu chỉ set border-color — độ dày / padding do app (Tailwind hoặc CSS của page) -->
|
|
209
|
+
<div class="bg-secondary border-quaternary card">
|
|
158
210
|
<h3 class="heading-3 text-primary">Tích luỹ</h3>
|
|
159
211
|
<p class="body-4 text-secondary">Lợi nhuận kỳ vọng 8.5%/năm</p>
|
|
160
212
|
<p class="body-4 text-red">Số dư không đủ</p>
|
|
@@ -164,122 +216,31 @@ viết thêm gì cho light mode.
|
|
|
164
216
|
<html data-theme="light"></html>
|
|
165
217
|
```
|
|
166
218
|
|
|
167
|
-
## Spacing class
|
|
168
|
-
|
|
169
|
-
Token `--spacing-*` (Figma Application) áp dụng cho **margin · padding · gap**. Tiền tố = thuộc
|
|
170
|
-
tính, hậu tố = bậc: `0` · `2xs` · `xs` · `s` · `m` · `l` · `xl` · `2xl` … `7xl`.
|
|
171
|
-
|
|
172
|
-
| Prefix | Property |
|
|
173
|
-
| -------------------------------- | -------------------------------------------- |
|
|
174
|
-
| `p-*` `px-*` `py-*` `pt/r/b/l-*` | padding / padding-inline / block / từng cạnh |
|
|
175
|
-
| `m-*` `mx-*` `my-*` `mt/r/b/l-*` | margin tương tự |
|
|
176
|
-
| `gap-*` `gap-x-*` `gap-y-*` | gap / column-gap / row-gap |
|
|
177
|
-
|
|
178
|
-
| Hậu tố | Token | px |
|
|
179
|
-
| ------ | --------------- | --- |
|
|
180
|
-
| `0` | `--spacing-0` | 0 |
|
|
181
|
-
| `2xs` | `--spacing-2xs` | 2 |
|
|
182
|
-
| `xs` | `--spacing-xs` | 4 |
|
|
183
|
-
| `s` | `--spacing-s` | 8 |
|
|
184
|
-
| `m` | `--spacing-m` | 12 |
|
|
185
|
-
| `l` | `--spacing-l` | 16 |
|
|
186
|
-
| `xl` | `--spacing-xl` | 24 |
|
|
187
|
-
| `2xl` | `--spacing-2xl` | 36 |
|
|
188
|
-
| `3xl` | `--spacing-3xl` | 48 |
|
|
189
|
-
| `4xl` | `--spacing-4xl` | 60 |
|
|
190
|
-
| `5xl` | `--spacing-5xl` | 84 |
|
|
191
|
-
| `6xl` | `--spacing-6xl` | 120 |
|
|
192
|
-
| `7xl` | `--spacing-7xl` | 240 |
|
|
193
|
-
|
|
194
|
-
```html
|
|
195
|
-
<div class="gap-m p-l flex flex-col">
|
|
196
|
-
<h3 class="heading-3">Danh mục</h3>
|
|
197
|
-
<p class="body-4 mt-s text-secondary">Cập nhật 5 phút trước</p>
|
|
198
|
-
</div>
|
|
199
|
-
```
|
|
200
|
-
|
|
201
|
-
## Border width & radius class
|
|
202
|
-
|
|
203
|
-
Token `--border-width-*` — độ dày viền 0.5 · 1 · 1.5 · 2 px. Class `border-s|m|l|xl` (và biến thể
|
|
204
|
-
cạnh) set width + `border-style: solid` để một class là thấy viền. Token `--radius-*` — bo góc
|
|
205
|
-
4 · 8 · 12 · full; class `radius-s|m|l|full`. Màu viền vẫn dùng `border-primary`… (hậu tố vai trò).
|
|
206
|
-
|
|
207
|
-
| Prefix | Property |
|
|
208
|
-
| --------------------------------------------------------------------------------- | ----------------------------------- |
|
|
209
|
-
| `border-s` / `border-m` / `border-l` / `border-xl` | border-width + border-style: solid |
|
|
210
|
-
| `border-top-s` / `border-right-s` / `border-bottom-s` / `border-left-s` (…m/l/xl) | width + style từng cạnh |
|
|
211
|
-
| `border-inline-s` / `border-block-s` (…m/l/xl) | border-inline / block width + style |
|
|
212
|
-
| `radius-s` / `radius-m` / `radius-l` / `radius-full` | border-radius |
|
|
213
|
-
|
|
214
|
-
| Hậu tố | Token | px |
|
|
215
|
-
| ------ | ------------------- | --- |
|
|
216
|
-
| `s` | `--border-width-s` | 0.5 |
|
|
217
|
-
| `m` | `--border-width-m` | 1 |
|
|
218
|
-
| `l` | `--border-width-l` | 1.5 |
|
|
219
|
-
| `xl` | `--border-width-xl` | 2 |
|
|
220
|
-
|
|
221
|
-
| Hậu tố | Token | Value |
|
|
222
|
-
| ------ | --------------- | ----- |
|
|
223
|
-
| `s` | `--radius-s` | 4px |
|
|
224
|
-
| `m` | `--radius-m` | 8px |
|
|
225
|
-
| `l` | `--radius-l` | 12px |
|
|
226
|
-
| `full` | `--radius-full` | full |
|
|
227
|
-
|
|
228
|
-
```html
|
|
229
|
-
<div class="bg-secondary border-quaternary radius-l p-l border-s">Card</div>
|
|
230
|
-
```
|
|
231
|
-
|
|
232
|
-
## Layout class
|
|
233
|
-
|
|
234
|
-
Nằm trong `@layer components` để utility (layer cao hơn) thắng; SCSS module (ngoài layer)
|
|
235
|
-
luôn đè được. Leaf **không** có class responsive — media query viết trong SCSS module
|
|
236
|
-
của component/page. Size cố định (`w-80`…) cũng để app tự viết.
|
|
237
|
-
|
|
238
|
-
| Import | Nội dung chính |
|
|
239
|
-
| ----------------- | -------------------------------------------------------------------------- |
|
|
240
|
-
| `flex.css` | `flex`, hướng, wrap, grow/shrink/basis, `justify-*` / `items-*` / `self-*` |
|
|
241
|
-
| `grid.css` | `grid`, `grid-cols-*`, `col-span-*`, flow, place/justify-items/self |
|
|
242
|
-
| `sizing.css` | `w-*` / `h-*` keyword + phân số, `size-*`, min/max |
|
|
243
|
-
| `overflow.css` | `overflow` / `overflow-x` / `overflow-y` |
|
|
244
|
-
| `position.css` | position, inset, z-index scale |
|
|
245
|
-
| `text-layout.css` | căn chữ, truncate, line-clamp, whitespace, transform, decoration |
|
|
246
|
-
|
|
247
|
-
```html
|
|
248
|
-
<div class="gap-m p-l flex items-center justify-between">
|
|
249
|
-
<h3 class="heading-3">Danh mục</h3>
|
|
250
|
-
<span class="body-4 text-secondary truncate">Tên rất dài…</span>
|
|
251
|
-
</div>
|
|
252
|
-
|
|
253
|
-
<div class="gap-m grid grid-cols-3">
|
|
254
|
-
<div class="col-span-2">Chính</div>
|
|
255
|
-
<div>Phụ</div>
|
|
256
|
-
</div>
|
|
257
|
-
```
|
|
258
|
-
|
|
259
219
|
## Cần biết
|
|
260
220
|
|
|
261
221
|
- **Class typography chỉ set đúng 3 thuộc tính** (`font-size`, `line-height`, `font-weight`);
|
|
262
|
-
**class color chỉ set đúng 1** (`color` / `background-color` / `border-color`)
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
- **
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
222
|
+
**class color chỉ set đúng 1** (`color` / `background-color` / `border-color`). Font family,
|
|
223
|
+
letter spacing… nằm ngoài phạm vi — app tự setup ở tầng global
|
|
224
|
+
(`body { font-family: var(--font-sans) }`, CSS reset…).
|
|
225
|
+
- **Leaf không có class layout / spacing / radius / border width / responsive.** Next.js dùng
|
|
226
|
+
Tailwind, landing page dùng CSS của page. Leaf cũng **không** có token spacing / radius / độ dày
|
|
227
|
+
viền — chỉ có token màu và typography.
|
|
228
|
+
- **Typography và CSS component nằm trong `@layer components`**; **class màu nằm trong
|
|
229
|
+
`@layer utilities`** (đè được CSS component, vd. `leaf-spinner text-highlight`). Utility của app
|
|
230
|
+
(Tailwind) và CSS không layer (CSS / SCSS module của app) đều override được, không cần
|
|
231
|
+
`!important`.
|
|
232
|
+
- **Mỗi file CSS mở đầu bằng `@layer theme, base, components, utilities;`** — trùng thứ tự layer của
|
|
233
|
+
Tailwind v4, nên import file theo thứ tự nào thì class màu vẫn đứng trên CSS component. Component
|
|
234
|
+
không trông vào CSS reset: tự reset `button`, tự xử lý `[hidden]`.
|
|
235
|
+
- **Class không có biến thể `hover:` / `focus:` / opacity** — nó là CSS thuần. Cần state thì dùng
|
|
236
|
+
Tailwind (`hover:text-(color:--text-highlight)`) hoặc CSS của page với cùng token.
|
|
275
237
|
- **Chỉ semantic token mới có class màu.** Primitive (`--neutral-500`, `--brand-300`…) là nguồn nội
|
|
276
|
-
bộ, dùng thẳng trong UI là mất khả năng đổi theme. Spacing / border-width là thang kích
|
|
277
|
-
định, không đổi theo theme.
|
|
238
|
+
bộ, dùng thẳng trong UI là mất khả năng đổi theme. Spacing / border-width / radius là thang kích
|
|
239
|
+
thước cố định, không đổi theo theme.
|
|
278
240
|
- **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ỹ
|
|
279
|
-
nếu load kèm CSS framework khác (Bootstrap cũng định nghĩa `.display-1`–`.display-6`).
|
|
280
|
-
|
|
281
|
-
của
|
|
282
|
-
(`border-primary`) — cùng tiền tố `border-` nhưng không trùng class.
|
|
241
|
+
nếu load kèm CSS framework khác (Bootstrap cũng định nghĩa `.display-1`–`.display-6`). Với
|
|
242
|
+
Tailwind v4: tắt palette (`--color-*: initial`) để `text-*` / `bg-*` / `border-*` chỉ còn class
|
|
243
|
+
màu của Leaf.
|
|
283
244
|
- Typography token hiện chỉ có **bộ Desktop**. Chưa có responsive type set, nên các style Display
|
|
284
245
|
cần app tự xử lý ở breakpoint nhỏ.
|
|
285
246
|
|
|
@@ -304,30 +265,44 @@ khi chạy docs: xoá `apps/docs/.next/dev` rồi chạy lại `pnpm dev`.
|
|
|
304
265
|
typography của label. Component React chỉ gắn attribute, không gắn class theo prop — nhờ vậy HTML
|
|
305
266
|
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.
|
|
306
267
|
|
|
307
|
-
|
|
308
|
-
|
|
268
|
+
**CSS component tự đủ**: layout (display / flex / grid / gap / padding / radius / viền…) nằm trong
|
|
269
|
+
`<tên>.css` của component; markup chỉ gắn class `leaf-*` (+ class typography / màu khi cần). Phần tử
|
|
270
|
+
nào CSS set `display` thì kèm rule `[hidden] { display: none }`.
|
|
271
|
+
|
|
272
|
+
Thêm bộ class mới (typography / màu): tạo `src/styles/<tên>.css` — script tự sinh `dist/<tên>.css`
|
|
273
|
+
và gom vào `classes.css` + `styles.css`; chỉ cần thêm một dòng `"./<tên>.css"` vào `exports` của
|
|
309
274
|
`package.json`.
|
|
310
275
|
Thêm component React (khi thật sự cần state/behavior, không phải để bọc style): tạo
|
|
311
276
|
`src/components/<Tên>/` (kèm `<tên>.css` nếu cần) rồi re-export trong `src/index.ts`. CSS của
|
|
312
277
|
component cũng ra `dist/<tên>.css` và được gom vào `classes.css` / `styles.css` — nhớ thêm dòng
|
|
313
278
|
`"./<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).
|
|
314
|
-
Component có hành vi (Tabs · Toggle · Dialog · Slider · Tooltip) cần thêm bản vanilla cho HTML
|
|
279
|
+
Component có hành vi (Tabs · Toggle · Dialog · Slider · Tooltip · InputOtp · InputStepper · Toast · Dropdown) cần thêm bản vanilla cho HTML
|
|
315
280
|
tĩnh trong `src/vanilla/` và gắn vào `window.Leaf` qua `src/vanilla/index.ts`. `src/vanilla` chỉ
|
|
316
281
|
vào bản CDN, không vào bản npm.
|
|
317
282
|
|
|
318
283
|
## Components
|
|
319
284
|
|
|
320
|
-
| Export
|
|
321
|
-
|
|
|
322
|
-
| `Button`
|
|
323
|
-
| `Tabs`
|
|
324
|
-
| `Dialog`
|
|
325
|
-
| `Logo`
|
|
326
|
-
| `Skeleton`
|
|
327
|
-
| `Spinner`
|
|
328
|
-
| `Toggle`
|
|
329
|
-
| `Slider`
|
|
330
|
-
| `Tooltip`
|
|
285
|
+
| Export | Mô tả |
|
|
286
|
+
| ---------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
287
|
+
| `Button` | Khung icon · label · icon — bật/tắt từng phần; `width` / `height`; `onClick` trả Promise → tự loading (spinner thay leading icon, khoá click), `loading` controlled |
|
|
288
|
+
| `Tabs` | Tabs Items — `items[]` (`value` · `label: ReactNode` · `disabled`); phím ← → Home End |
|
|
289
|
+
| `Dialog` | Panel + backdrop blur — `open` (controlled), `title` / `onBack` / `onClose(reason)`, `dismissible`, `closeLabel` / `backLabel`, `theme`, `maxWidth` / `height` / `maxHeight` |
|
|
290
|
+
| `Logo` | Wordmark FHSC · Finhay · FHC — `brand` / `mode` / `side` / `size` |
|
|
291
|
+
| `Skeleton` | Placeholder shimmer — `width` / `height` / `border` (radius), nền `--base-tertiary` |
|
|
292
|
+
| `Spinner` | Indicator 8 nan — `animation` (`spin` · `fade` · `pulse` · `breathe`), `size` |
|
|
293
|
+
| `Toggle` | Công tắc On/Off — `size` md/sm, `checked`, `disabled` (Figma Active Off); `name` / `value` → input ẩn cho form |
|
|
294
|
+
| `Slider` | Kéo từng `step` trong `min`–`max` (mặc định 0–100, bước 1) · mốc `steps` · `labels`; `name` → input ẩn |
|
|
295
|
+
| `Tooltip` | Hover/focus/Escape — `size`, `position`, `align`, `onOpenChange`; `trigger="click"`, `openDelay` / `closeDelay`, tự lật phía khi thiếu chỗ, `theme`; kèm `TooltipContent` |
|
|
296
|
+
| `Radio` / `RadioGroup` | Radio đơn + nhóm — `value` / `defaultValue` / `onValueChange`, `name` cho form, `disabled`, `orientation` |
|
|
297
|
+
| `Checkbox` | Checkbox — `checked` / `defaultChecked` / `onCheckedChange` (`checked="indeterminate"` cho trạng thái lưng chừng), `label`, `disabled`; input native nên đi thẳng vào `FormData` |
|
|
298
|
+
| `Input` | Input dynamic — `variant` field/inline, `shape` default/pill, slot `label` · `leadingIcon` · `trailingIcon` · `action` · `message`, `invalid`, `revealPassword`; `as="button"` làm trigger |
|
|
299
|
+
| `InputOtp` | Ô OTP — `length`, `mask`, dán cả mã, `onComplete`; `name` → input ẩn |
|
|
300
|
+
| `InputStepper` | Nhập số với −/+ — `tone` buy/sell, `step` / `min` / `max` / `precision`, `locale`, `unit`; phím ↑ ↓, chốt khi blur/Enter |
|
|
301
|
+
| `Calendar` | Lịch tháng (port từ vnsc) — chọn ngày / giờ (`showTime`, `timeOnly`), `minDate` / `maxDate` / `disablePast` / `disableFuture` / `disableDate`, luật giờ (`minHour` / `maxHour` / `minuteStep`…), `weekStartsOn`, `labels`; dùng độc lập được |
|
|
302
|
+
| `InputDate` | `Input` trigger + popover `Calendar` — `value` chốt khi bấm "Chọn" (hoặc `confirmOnSelect`), `formatDisplay`, `align`, tự lật phía; `name` → input ẩn ISO |
|
|
303
|
+
| `Toaster` / `toast` | Toast success / error / warning — `toast.success(title, { description, duration })`, `duration: -1` không tự đóng, dừng khi hover / focus, `toast.dismiss(id)`; `<Toaster position closeLabel theme />` đặt một lần; kèm `ToastContent` |
|
|
304
|
+
| `Dropdown` | Chọn một giá trị — `variant` list / radio, `trigger` field / text, `appearance` filled / outlined, `size` md / sm, `openOn` click / hover, `align`, `readOnly`, `maxHeight`; option `leading` / `disabled`; phím ↑ ↓ Home End + typeahead |
|
|
305
|
+
| `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"` |
|
|
331
306
|
|
|
332
307
|
```css
|
|
333
308
|
/* Ngoài tokens.css + typography.css, mỗi component cần CSS riêng của nó */
|
|
@@ -378,19 +353,51 @@ import {
|
|
|
378
353
|
|
|
379
354
|
## HTML tĩnh (CDN)
|
|
380
355
|
|
|
381
|
-
Cho landing page / trang dựng tay không có bundler
|
|
382
|
-
dùng được toàn bộ class typography, color và mọi component (CSS). Script chỉ cần
|
|
383
|
-
Tabs · Toggle · Dialog · Slider · Tooltip (`data-leaf-*`).
|
|
356
|
+
Cho landing page / trang dựng tay không có bundler: **Leaf CDN + CSS riêng của page**. 1 `<link>` +
|
|
357
|
+
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-*`).
|
|
359
|
+
Layout, spacing, responsive của page viết trong CSS của page, dùng token Leaf.
|
|
384
360
|
|
|
385
361
|
```html
|
|
386
|
-
<link rel="stylesheet" href="https://<cdn>/leaf-0.1.
|
|
387
|
-
<script src="https://<cdn>/leaf-0.1.
|
|
362
|
+
<link rel="stylesheet" href="https://<cdn>/leaf-0.1.8.min.css" />
|
|
363
|
+
<script src="https://<cdn>/leaf-0.1.8.min.js" defer></script>
|
|
364
|
+
|
|
365
|
+
<style>
|
|
366
|
+
/* CSS của page — bọc trong @layer để không đè nhầm CSS component (xem "Cần biết") */
|
|
367
|
+
@layer base {
|
|
368
|
+
body {
|
|
369
|
+
margin: 0;
|
|
370
|
+
font-family: var(--font-sans);
|
|
371
|
+
background: var(--base-primary);
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
@layer page {
|
|
376
|
+
.hero {
|
|
377
|
+
display: flex;
|
|
378
|
+
flex-direction: column;
|
|
379
|
+
gap: 16px;
|
|
380
|
+
padding: 48px 16px;
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
@media (min-width: 768px) {
|
|
384
|
+
.hero {
|
|
385
|
+
flex-direction: row;
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
</style>
|
|
390
|
+
|
|
391
|
+
<section class="hero">
|
|
392
|
+
<h1 class="display-3 text-primary">Finhay</h1>
|
|
393
|
+
<button class="leaf-button" data-size="md">Mở tài khoản</button>
|
|
394
|
+
</section>
|
|
388
395
|
```
|
|
389
396
|
|
|
390
|
-
| File | Nội dung
|
|
391
|
-
| ------------------------ |
|
|
392
|
-
| `leaf-<version>.min.css` | `styles.css` đã minify: token + typography + color + CSS của mọi component.
|
|
393
|
-
| `leaf-<version>.min.js` | Hành vi Tabs · Toggle · Dialog · Slider · Tooltip → `window.Leaf`. Trang CSS-only có thể bỏ. |
|
|
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ỏ. |
|
|
394
401
|
|
|
395
402
|
Link thật (do tool admin CDN trả về) nằm ở trang docs **Develop → Web**. Trang demo đủ mọi biến thể:
|
|
396
403
|
[`examples/static.html`](examples/static.html) (mở bằng `file://` sau khi build).
|
|
@@ -409,18 +416,8 @@ Không cần JS. Thiếu attribute nào thì lấy mặc định giống prop Re
|
|
|
409
416
|
| `data-loading` | `true` — `Leaf.button.setLoading` / `run` gắn | — |
|
|
410
417
|
|
|
411
418
|
```html
|
|
412
|
-
<button
|
|
413
|
-
|
|
414
|
-
>
|
|
415
|
-
Tiếp tục
|
|
416
|
-
</button>
|
|
417
|
-
<button
|
|
418
|
-
class="leaf-button inline-flex items-center justify-center text-center whitespace-nowrap align-middle"
|
|
419
|
-
data-priority="secondary"
|
|
420
|
-
data-size="md"
|
|
421
|
-
>
|
|
422
|
-
Secondary
|
|
423
|
-
</button>
|
|
419
|
+
<button class="leaf-button">Tiếp tục</button>
|
|
420
|
+
<button class="leaf-button" data-priority="secondary" data-size="md">Secondary</button>
|
|
424
421
|
```
|
|
425
422
|
|
|
426
423
|
Loading (cần `leaf.js`): `Leaf.button.run(el, promise)` bật loading tới khi promise settle,
|
|
@@ -468,6 +465,41 @@ Span rỗng `.leaf-logo` + `data-brand` / `data-mode` / `data-side` + `--leaf-lo
|
|
|
468
465
|
SVG data-URI — không cần JS. Bản CDN đã gộp sẵn data-URI; dùng qua npm thì import thêm
|
|
469
466
|
`logo-assets.css` (không nằm trong `classes.css` / `styles.css` vì component React không cần).
|
|
470
467
|
|
|
468
|
+
### Radio / Checkbox / Input
|
|
469
|
+
|
|
470
|
+
Chỉ CSS — markup như tab **Code → HTML tĩnh**. Input đọc `data-variant` / `data-shape` /
|
|
471
|
+
`data-invalid` / `data-disabled` trên `.leaf-input`.
|
|
472
|
+
|
|
473
|
+
### InputOtp
|
|
474
|
+
|
|
475
|
+
`data-leaf-input-otp` trên `.leaf-input-otp` (các ô `.leaf-input-otp__cell`). leaf.js lo nhảy ô,
|
|
476
|
+
dán, Backspace; `Leaf.inputOtp.set` / `get` · `leaf:input-otp-change` · `leaf:input-otp-complete`.
|
|
477
|
+
Có `input[type=hidden]` trong markup thì leaf.js ghi mã vào đó.
|
|
478
|
+
|
|
479
|
+
### InputStepper
|
|
480
|
+
|
|
481
|
+
`data-leaf-input-stepper` trên `.leaf-input-stepper` + `data-step` / `data-precision` /
|
|
482
|
+
`data-locale`; min / max đọc từ `aria-valuemin` / `aria-valuemax` của input. Nút `data-action="decrement|increment"`.
|
|
483
|
+
`Leaf.inputStepper.set` / `get` · `leaf:input-stepper-change`.
|
|
484
|
+
|
|
485
|
+
### Toast
|
|
486
|
+
|
|
487
|
+
`Leaf.toast.success | error | warning(title, { description, duration, id })` (hoặc
|
|
488
|
+
`Leaf.toast.show({ status, title, … })`) trả id; `Leaf.toast.dismiss(id?)` đóng (không truyền → đóng
|
|
489
|
+
hết); `Leaf.toast.configure({ position, closeLabel, label, theme })`. Vùng chứa
|
|
490
|
+
`.leaf-toaster[data-leaf-toaster]` có sẵn trong trang thì dùng, không thì leaf.js tự tạo. Toast viết
|
|
491
|
+
tay: `.leaf-toast[data-leaf-toast]` + `data-status` — nút `.leaf-toast__close` và thanh progress
|
|
492
|
+
chạy hết đều đóng toast. Event `leaf:toast-show` / `leaf:toast-dismiss`.
|
|
493
|
+
|
|
494
|
+
### Dropdown
|
|
495
|
+
|
|
496
|
+
`data-leaf-dropdown` trên `.leaf-dropdown` (markup như tab **Code → HTML tĩnh**) + `data-variant` /
|
|
497
|
+
`data-trigger` / `data-appearance` / `data-size` / `data-align`; `data-open-on="hover"` để rê chuột
|
|
498
|
+
mở. Option `.leaf-dropdown__option[data-value]`, mục chọn `aria-selected="true"`, disabled
|
|
499
|
+
`aria-disabled="true"`. `Leaf.dropdown.open` / `close` / `select(el, value)` ·
|
|
500
|
+
`leaf:dropdown-change`. Có `input.leaf-dropdown__input` thì leaf.js ghi value vào đó. Panel nằm ngay
|
|
501
|
+
dưới trigger (không portal) — tránh đặt trong khung `overflow: hidden / auto` thấp hơn panel.
|
|
502
|
+
|
|
471
503
|
### Skeleton / Spinner
|
|
472
504
|
|
|
473
505
|
Chỉ CSS. Skeleton: `--leaf-skeleton-width` / `height` / `radius`. Spinner: `data-animation` /
|
|
@@ -483,11 +515,15 @@ Chỉ CSS. Skeleton: `--leaf-skeleton-width` / `height` / `radius`. Spinner: `da
|
|
|
483
515
|
- **CSS của trang phải nằm trong `@layer` nếu đụng vào element của component.** Style component
|
|
484
516
|
nằm trong `@layer components`, mà CSS không layer luôn thắng CSS có layer bất kể specificity —
|
|
485
517
|
reset kiểu `* { padding: 0 }` hay `button { background: none }` đặt trần sẽ xoá padding / nền
|
|
486
|
-
của `.leaf-button`. Bọc reset trong `@layer base { … }
|
|
518
|
+
của `.leaf-button`. Bọc reset trong `@layer base { … }`, layout của page trong một layer riêng
|
|
519
|
+
(vd. `@layer page`, khai báo sau `utilities` nếu muốn đè cả class màu).
|
|
520
|
+
- **Leaf không có class layout / spacing** (`flex`, `gap-*`, `p-*`… đã bỏ từ 0.1.8). Markup component
|
|
521
|
+
chỉ cần class `leaf-*` (+ typography / màu); markup cũ còn class layout vẫn hiển thị y hệt — các
|
|
522
|
+
class đó giờ không có tác dụng.
|
|
487
523
|
- **Trình duyệt tối thiểu** (CSS dùng `@layer`): Chrome / Edge 99+, Safari 15.4+, Firefox 97+.
|
|
488
524
|
- Dark là mặc định; `data-theme="light"` trên `<html>` để chuyển light.
|
|
489
|
-
- z-index của lớp phủ đọc `--leaf-z-
|
|
490
|
-
`--leaf-z-tooltip` (110) — override trên `:root` để chèn lớp của trang vào giữa.
|
|
525
|
+
- z-index của lớp phủ đọc `--leaf-z-dropdown` (30) / `--leaf-z-dialog` (50) /
|
|
526
|
+
`--leaf-z-spinner-overlay` (100) / `--leaf-z-tooltip` (110) / `--leaf-z-toast` (120) — override trên `:root` để chèn lớp của trang vào giữa.
|
|
491
527
|
- Chi tiết attribute / markup từng component: tab **Code → HTML tĩnh** trên docs.
|
|
492
528
|
|
|
493
529
|
### Phát hành bản CDN
|
|
@@ -502,6 +538,65 @@ Chỉ CSS. Skeleton: `--leaf-skeleton-width` / `height` / `radius`. Spinner: `da
|
|
|
502
538
|
|
|
503
539
|
## Changelog
|
|
504
540
|
|
|
541
|
+
### 0.1.8
|
|
542
|
+
|
|
543
|
+
**Breaking**
|
|
544
|
+
|
|
545
|
+
- Bỏ class layout / spacing / border width / radius khỏi Leaf: xoá `spacing.css`, `border.css`,
|
|
546
|
+
`flex.css`, `grid.css`, `sizing.css`, `overflow.css`, `position.css`, `text-layout.css` (cả
|
|
547
|
+
export npm lẫn trong `classes.css` / `styles.css` / CDN). Next.js dùng Tailwind (xem
|
|
548
|
+
[Dùng với Next.js + Tailwind](#dùng-với-nextjs--tailwind)), landing page dùng CSS của page. Trang
|
|
549
|
+
dựng layout bằng các class này (`flex`, `gap-m`, `p-l`, `radius-l`…) phải giữ link CDN 0.1.7 hoặc
|
|
550
|
+
chuyển sang CSS riêng trước khi lên 0.1.8.
|
|
551
|
+
- Bỏ token `--spacing-*`, `--border-width-*`, `--radius-*` (file `spacing.css` / `border.css` của
|
|
552
|
+
`@finhay/leaf-tokens`). Leaf chỉ còn 2 bộ token: **Color** và **Typography**. CSS component khai
|
|
553
|
+
báo giá trị px trực tiếp (giá trị không đổi); app đang đọc các biến này phải tự khai báo lại hoặc
|
|
554
|
+
chuyển sang Tailwind.
|
|
555
|
+
|
|
556
|
+
**Thay đổi**
|
|
557
|
+
|
|
558
|
+
- CSS component tự đủ trở lại: layout nằm trong `<component>.css`, markup React / leaf.js chỉ gắn
|
|
559
|
+
class `leaf-*` (+ typography / màu). Import riêng `tokens.css` + `typography.css` +
|
|
560
|
+
`<component>.css` là đủ (`Calendar` cần thêm `color.css`). Giao diện không đổi; markup HTML tĩnh
|
|
561
|
+
cũ (còn class layout) vẫn hiển thị y hệt.
|
|
562
|
+
- `Calendar`: thêm class BEM cho các khối trước đây chỉ có class layout (`__heading`,
|
|
563
|
+
`__months-header`, `__months-grid`, `__weekdays`, `__weekday`, `__time-group`, `__select-wrap`,
|
|
564
|
+
`__footer`).
|
|
565
|
+
- `Dialog`: truncate của title nằm trong `dialog.css` (`.leaf-dialog__start > h2 | p`) — markup
|
|
566
|
+
không cần class `min-w-0 truncate`.
|
|
567
|
+
- Docs: dùng Leaf + Tailwind v4 (bỏ SCSS module); bỏ trang Spacing, Border, Flex, Grid, Sizing,
|
|
568
|
+
Overflow, Position, Text.
|
|
569
|
+
|
|
570
|
+
**Mới**
|
|
571
|
+
|
|
572
|
+
- `Toaster` / `toast` / `ToastContent` — toast success · error · warning (port từ vnsc). Màu từ
|
|
573
|
+
token có sẵn: nền `--system-green|red|yellow-secondary`, viền / icon / progress
|
|
574
|
+
`--text-highlight` · `--system-red` · `--system-yellow`. Toast gắn `data-theme="dark"` mặc định
|
|
575
|
+
(nền thang 800 ở cả hai theme). Tự đóng sau `duration` (mặc định 4000ms, `-1` không tự đóng), dừng
|
|
576
|
+
khi hover / focus. CSS `toast.css`; leaf.js `Leaf.toast`.
|
|
577
|
+
- `Dropdown` — chọn một giá trị, gom các dropdown của vnsc: `variant="radio"` (dropdown kèm radio ở
|
|
578
|
+
màn thị trường) và `variant="list"` (SubAccounts, chọn lệnh) với trigger `field` filled / outlined,
|
|
579
|
+
size md / sm, `readOnly`, `openOn="hover"`. Bàn phím theo WAI-ARIA select-only combobox. CSS
|
|
580
|
+
`dropdown.css`; leaf.js `data-leaf-dropdown` / `Leaf.dropdown`.
|
|
581
|
+
- `LanguageDropdown` — Tiếng Việt / English kèm cờ từ CDN Finhay (`.leaf-dropdown__flag`). Danh sách
|
|
582
|
+
ngôn ngữ nằm ở `LEAF_LANGUAGES`; thêm ngôn ngữ mới thì bổ sung trong Leaf.
|
|
583
|
+
- Docs: `/components/dropdown`, `/components/toast`.
|
|
584
|
+
- `Radio` / `RadioGroup` (Figma 1146:2081) và `Checkbox` (Figma 891:10191) — input native, đi
|
|
585
|
+
thẳng vào `FormData`. CSS: `radio.css`, `checkbox.css`.
|
|
586
|
+
- Họ Input (Figma 1146:2159), export chung từ `components/Input`:
|
|
587
|
+
- `Input` — field dynamic: bật/tắt từng slot label · icon · action · message; variant
|
|
588
|
+
field / inline, shape pill, `revealPassword`, `as="button"` làm trigger. CSS `input.css`.
|
|
589
|
+
- `InputOtp` — nhảy ô, dán cả mã, `mask`, `onComplete`. CSS `input-otp.css`; leaf.js
|
|
590
|
+
`data-leaf-input-otp` / `Leaf.inputOtp`.
|
|
591
|
+
- `InputStepper` — −/+ tone buy / sell, `step` / `min` / `max` / `precision`, format theo
|
|
592
|
+
`locale`. CSS `input-stepper.css`; leaf.js `data-leaf-input-stepper` / `Leaf.inputStepper`.
|
|
593
|
+
- `InputDate` — `Input` + popover `Calendar`, chốt khi bấm "Chọn". CSS `input-date.css` (cần
|
|
594
|
+
kèm `input.css` + `calendar.css` + `button.css`).
|
|
595
|
+
- `Calendar` — port từ vnsc, chọn ngày / giờ, dùng độc lập được. CSS `calendar.css` (footer
|
|
596
|
+
dùng `Button` → cần `button.css`).
|
|
597
|
+
- Docs: `/components/radio`, `/components/checkbox`, `/components/input` (đủ 4 dạng, React + HTML
|
|
598
|
+
tĩnh), `/components/calendar`.
|
|
599
|
+
|
|
505
600
|
### 0.1.7
|
|
506
601
|
|
|
507
602
|
**Breaking**
|