@finhay-pro/leaf-design-system 0.2.2 → 0.2.3
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 +217 -205
- package/dist/cdn/leaf-0.2.3.min.css +8 -0
- package/dist/cdn/leaf-0.2.3.min.js +204 -0
- package/dist/components/Carousel/Carousel.d.ts.map +1 -1
- package/dist/components/Carousel/Carousel.js +3 -1
- package/dist/components/Carousel/Carousel.js.map +1 -1
- package/dist/components/Empty/Empty.d.ts.map +1 -1
- package/dist/components/Empty/Empty.js.map +1 -1
- package/dist/components/Form/adapters.d.ts.map +1 -1
- package/dist/components/Form/adapters.js +1 -1
- package/dist/components/Form/adapters.js.map +1 -1
- package/dist/components/QrCode/QrCode.d.ts.map +1 -1
- package/dist/components/QrCode/QrCode.js.map +1 -1
- package/dist/components/Table/Table.d.ts +59 -0
- package/dist/components/Table/Table.d.ts.map +1 -0
- package/dist/components/Table/Table.js +274 -0
- package/dist/components/Table/Table.js.map +1 -0
- package/dist/components/Table/TableHeader.d.ts +19 -0
- package/dist/components/Table/TableHeader.d.ts.map +1 -0
- package/dist/components/Table/TableHeader.js +16 -0
- package/dist/components/Table/TableHeader.js.map +1 -0
- package/dist/components/Table/TableRow.d.ts +27 -0
- package/dist/components/Table/TableRow.d.ts.map +1 -0
- package/dist/components/Table/TableRow.js +30 -0
- package/dist/components/Table/TableRow.js.map +1 -0
- package/dist/components/Table/dom.d.ts +9 -0
- package/dist/components/Table/dom.d.ts.map +1 -0
- package/dist/components/Table/dom.js +17 -0
- package/dist/components/Table/dom.js.map +1 -0
- package/dist/components/Table/index.d.ts +2 -0
- package/dist/components/Table/index.d.ts.map +1 -0
- package/dist/components/Table/index.js +2 -0
- package/dist/components/Table/index.js.map +1 -0
- package/dist/core/carousel.d.ts.map +1 -1
- package/dist/core/carousel.js +4 -3
- package/dist/core/carousel.js.map +1 -1
- package/dist/core/icons.d.ts +2 -0
- package/dist/core/icons.d.ts.map +1 -1
- package/dist/core/icons.js +2 -0
- package/dist/core/icons.js.map +1 -1
- package/dist/core/qr-code.d.ts.map +1 -1
- package/dist/core/qr-code.js.map +1 -1
- package/dist/core/table/attrs.d.ts +65 -0
- package/dist/core/table/attrs.d.ts.map +1 -0
- package/dist/core/table/attrs.js +202 -0
- package/dist/core/table/attrs.js.map +1 -0
- package/dist/core/table/columns.d.ts +156 -0
- package/dist/core/table/columns.d.ts.map +1 -0
- package/dist/core/table/columns.js +147 -0
- package/dist/core/table/columns.js.map +1 -0
- package/dist/core/table/flash.d.ts +26 -0
- package/dist/core/table/flash.d.ts.map +1 -0
- package/dist/core/table/flash.js +84 -0
- package/dist/core/table/flash.js.map +1 -0
- package/dist/core/table/index.d.ts +10 -0
- package/dist/core/table/index.d.ts.map +1 -0
- package/dist/core/table/index.js +10 -0
- package/dist/core/table/index.js.map +1 -0
- package/dist/core/table/measure.d.ts +23 -0
- package/dist/core/table/measure.d.ts.map +1 -0
- package/dist/core/table/measure.js +54 -0
- package/dist/core/table/measure.js.map +1 -0
- package/dist/core/table/resize.d.ts +13 -0
- package/dist/core/table/resize.d.ts.map +1 -0
- package/dist/core/table/resize.js +34 -0
- package/dist/core/table/resize.js.map +1 -0
- package/dist/core/table/sort.d.ts +23 -0
- package/dist/core/table/sort.d.ts.map +1 -0
- package/dist/core/table/sort.js +71 -0
- package/dist/core/table/sort.js.map +1 -0
- package/dist/core/table/span.d.ts +31 -0
- package/dist/core/table/span.d.ts.map +1 -0
- package/dist/core/table/span.js +84 -0
- package/dist/core/table/span.js.map +1 -0
- package/dist/core/table/virtual.d.ts +29 -0
- package/dist/core/table/virtual.d.ts.map +1 -0
- package/dist/core/table/virtual.js +24 -0
- package/dist/core/table/virtual.js.map +1 -0
- package/dist/engine/assets.json +1 -0
- package/dist/engine/chunk-X2H56OKG.js +4854 -0
- package/dist/engine/cli.js +8 -0
- package/dist/engine/postcss.d.ts +3 -0
- package/dist/engine/postcss.js +7 -0
- package/dist/engine/vite.d.ts +3 -0
- package/dist/engine/vite.js +7 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/{styles.css → leaf.css} +436 -10
- package/dist/skill/leaf-design-system-0.2.3.zip +0 -0
- package/dist/utils/colorClass.d.ts +2 -0
- package/dist/utils/colorClass.d.ts.map +1 -1
- package/dist/utils/colorClass.js +14 -0
- package/dist/utils/colorClass.js.map +1 -1
- package/package.json +18 -40
- package/dist/button.css +0 -221
- package/dist/calendar.css +0 -337
- package/dist/carousel.css +0 -144
- package/dist/cdn/leaf-0.2.2.min.css +0 -2
- package/dist/cdn/leaf-0.2.2.min.js +0 -165
- package/dist/checkbox.css +0 -132
- package/dist/classes.css +0 -5031
- package/dist/color.css +0 -260
- package/dist/date.css +0 -19
- package/dist/dialog.css +0 -176
- package/dist/dropdown.css +0 -420
- package/dist/empty.css +0 -74
- package/dist/file-viewer.css +0 -502
- package/dist/focus.css +0 -18
- package/dist/form.css +0 -64
- package/dist/input-date.css +0 -49
- package/dist/input-otp.css +0 -76
- package/dist/input-stepper.css +0 -179
- package/dist/input.css +0 -218
- package/dist/logo-assets.css +0 -81
- package/dist/logo.css +0 -52
- package/dist/multiselect.css +0 -147
- package/dist/number.css +0 -53
- package/dist/qr-code.css +0 -21
- package/dist/radio.css +0 -124
- package/dist/skeleton.css +0 -57
- package/dist/skill/leaf-design-system-0.2.2.zip +0 -0
- package/dist/slider.css +0 -303
- package/dist/spinner.css +0 -125
- package/dist/tabs.css +0 -260
- package/dist/textarea.css +0 -28
- package/dist/toast.css +0 -236
- package/dist/toggle.css +0 -116
- package/dist/tokens.css +0 -264
- package/dist/tooltip.css +0 -213
- package/dist/typography.css +0 -150
- package/dist/upload.css +0 -317
package/README.md
CHANGED
|
@@ -1,18 +1,19 @@
|
|
|
1
1
|
# @finhay-pro/leaf-design-system
|
|
2
2
|
|
|
3
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
|
|
5
|
-
HTML tĩnh dùng chung markup)
|
|
6
|
-
|
|
4
|
+
[`@finhay/leaf-tokens`](../tokens)), **class typography / màu dùng sẵn**, **component** (React +
|
|
5
|
+
HTML tĩnh dùng chung markup) và **utility layout** do engine CSS riêng của Leaf sinh ra (không
|
|
6
|
+
dependency, không cần Tailwind). Màu và chữ luôn đọc từ token; spacing / radius / độ dày viền không
|
|
7
|
+
phải token — component tự khai báo trong CSS của nó, app dùng utility px (`p-[16px]`,
|
|
8
|
+
`rounded-xl`, `border-[0.5px]`).
|
|
7
9
|
|
|
8
|
-
|
|
10
|
+
| Loại project | Cách dùng |
|
|
11
|
+
| -------------------------- | ---------------------------------------------------------------------------------------- |
|
|
12
|
+
| Next.js / Vite (có bundle) | Plugin Leaf (PostCSS / Vite) + một dòng `@import` |
|
|
13
|
+
| HTML tĩnh có bước build | CLI `leaf-css` sinh một file CSS |
|
|
14
|
+
| Landing page (CDN) | 1 `<link>` + 1 `<script>` — script sinh utility từ class trên DOM ngay trong trình duyệt |
|
|
9
15
|
|
|
10
|
-
|
|
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).
|
|
16
|
+
Xem [Cài đặt](#cài-đặt), [Utility layout](#utility-layout) và [HTML tĩnh (CDN)](#html-tĩnh-cdn).
|
|
16
17
|
|
|
17
18
|
## Cài đặt
|
|
18
19
|
|
|
@@ -20,128 +21,98 @@ Xem [Dùng với Next.js + Tailwind](#dùng-với-nextjs--tailwind) và [HTML t
|
|
|
20
21
|
pnpm add @finhay-pro/leaf-design-system
|
|
21
22
|
```
|
|
22
23
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
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/empty.css` | Style của component `Empty`. |
|
|
40
|
-
| `@finhay-pro/leaf-design-system/qr-code.css` | Style của component `QrCode`. |
|
|
41
|
-
| `@finhay-pro/leaf-design-system/carousel.css` | Style của component `Carousel`. |
|
|
42
|
-
| `@finhay-pro/leaf-design-system/spinner.css` | Style của component `Spinner`. |
|
|
43
|
-
| `@finhay-pro/leaf-design-system/toggle.css` | Style của component `Toggle`. |
|
|
44
|
-
| `@finhay-pro/leaf-design-system/slider.css` | Style của component `Slider`. |
|
|
45
|
-
| `@finhay-pro/leaf-design-system/tooltip.css` | Style của component `Tooltip`. |
|
|
46
|
-
| `@finhay-pro/leaf-design-system/radio.css` | Style của component `Radio` / `RadioGroup`. |
|
|
47
|
-
| `@finhay-pro/leaf-design-system/checkbox.css` | Style của component `Checkbox`. |
|
|
48
|
-
| `@finhay-pro/leaf-design-system/input.css` | Style của component `Input` (field / inline, dùng chung cho `InputDate`). |
|
|
49
|
-
| `@finhay-pro/leaf-design-system/input-otp.css` | Style của component `InputOtp`. |
|
|
50
|
-
| `@finhay-pro/leaf-design-system/input-stepper.css` | Style của component `InputStepper`. |
|
|
51
|
-
| `@finhay-pro/leaf-design-system/calendar.css` | Style của component `Calendar` (cần kèm `button.css` + `color.css`). |
|
|
52
|
-
| `@finhay-pro/leaf-design-system/input-date.css` | Popover của `InputDate` (kèm `input.css` + `calendar.css` + `button.css` + `color.css`). |
|
|
53
|
-
| `@finhay-pro/leaf-design-system/toast.css` | Style của `Toaster` / `ToastContent`. |
|
|
54
|
-
| `@finhay-pro/leaf-design-system/dropdown.css` | Style của component `Dropdown`. |
|
|
55
|
-
| `@finhay-pro/leaf-design-system/file-viewer.css` | Style của `FileViewer` (kèm `button.css` + `spinner.css` + `empty.css`). |
|
|
56
|
-
| `@finhay-pro/leaf-design-system/classes.css` | Tất cả class + component, không token. |
|
|
57
|
-
| `@finhay-pro/leaf-design-system/styles.css` | Token + tất cả class + component. Một dòng là đủ. |
|
|
58
|
-
|
|
59
|
-
Import bằng CSS:
|
|
24
|
+
Khai báo plugin, rồi đặt **đúng một dòng** `@import` ở file CSS gốc. Plugin thay dòng đó bằng
|
|
25
|
+
stylesheet đã tree-shake: token + reset + class typography / màu + CSS của component đang dùng
|
|
26
|
+
(nhận diện qua named import từ package hoặc class `leaf-*` trong markup) + utility layout có trong
|
|
27
|
+
source. Không còn file CSS lẻ nào khác để import.
|
|
60
28
|
|
|
61
29
|
```css
|
|
62
|
-
/*
|
|
63
|
-
@import "@finhay-pro/leaf-design-system/
|
|
64
|
-
|
|
65
|
-
/* 2. Class typography + màu */
|
|
66
|
-
@import "@finhay-pro/leaf-design-system/typography.css";
|
|
67
|
-
@import "@finhay-pro/leaf-design-system/color.css";
|
|
68
|
-
|
|
69
|
-
/* 3. Component nào dùng thì import cái đó */
|
|
70
|
-
@import "@finhay-pro/leaf-design-system/button.css";
|
|
71
|
-
@import "@finhay-pro/leaf-design-system/tabs.css";
|
|
72
|
-
@import "@finhay-pro/leaf-design-system/dialog.css";
|
|
73
|
-
@import "@finhay-pro/leaf-design-system/logo.css";
|
|
74
|
-
@import "@finhay-pro/leaf-design-system/skeleton.css";
|
|
75
|
-
@import "@finhay-pro/leaf-design-system/empty.css";
|
|
76
|
-
@import "@finhay-pro/leaf-design-system/qr-code.css";
|
|
77
|
-
@import "@finhay-pro/leaf-design-system/carousel.css";
|
|
78
|
-
@import "@finhay-pro/leaf-design-system/spinner.css";
|
|
79
|
-
@import "@finhay-pro/leaf-design-system/toggle.css";
|
|
80
|
-
@import "@finhay-pro/leaf-design-system/slider.css";
|
|
81
|
-
@import "@finhay-pro/leaf-design-system/tooltip.css";
|
|
82
|
-
@import "@finhay-pro/leaf-design-system/radio.css";
|
|
83
|
-
@import "@finhay-pro/leaf-design-system/checkbox.css";
|
|
84
|
-
@import "@finhay-pro/leaf-design-system/input.css";
|
|
85
|
-
@import "@finhay-pro/leaf-design-system/input-otp.css";
|
|
86
|
-
@import "@finhay-pro/leaf-design-system/input-stepper.css";
|
|
87
|
-
@import "@finhay-pro/leaf-design-system/calendar.css";
|
|
88
|
-
@import "@finhay-pro/leaf-design-system/input-date.css";
|
|
89
|
-
@import "@finhay-pro/leaf-design-system/toast.css";
|
|
90
|
-
@import "@finhay-pro/leaf-design-system/dropdown.css";
|
|
91
|
-
@import "@finhay-pro/leaf-design-system/file-viewer.css";
|
|
30
|
+
/* app/globals.css (Next.js) · src/index.css (Vite) */
|
|
31
|
+
@import "@finhay-pro/leaf-design-system/css";
|
|
92
32
|
```
|
|
93
33
|
|
|
94
|
-
|
|
34
|
+
Next.js — `postcss.config.mjs`:
|
|
95
35
|
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
36
|
+
```js
|
|
37
|
+
export default {
|
|
38
|
+
plugins: { "@finhay-pro/leaf-design-system/postcss": {} },
|
|
39
|
+
};
|
|
40
|
+
```
|
|
100
41
|
|
|
101
|
-
|
|
42
|
+
Vite — `vite.config.ts` (file CSS chứa `@import` được import từ `src/main.tsx`):
|
|
102
43
|
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
44
|
+
```ts
|
|
45
|
+
import leaf from "@finhay-pro/leaf-design-system/vite";
|
|
46
|
+
import react from "@vitejs/plugin-react";
|
|
47
|
+
import { defineConfig } from "vite";
|
|
106
48
|
|
|
107
|
-
|
|
108
|
-
|
|
49
|
+
export default defineConfig({ plugins: [react(), leaf()] });
|
|
50
|
+
```
|
|
109
51
|
|
|
110
|
-
|
|
111
|
-
@import "@finhay-pro/leaf-design-system/styles.css";
|
|
112
|
-
@import "tailwindcss";
|
|
52
|
+
HTML tĩnh không bundler — file input chứa cùng dòng `@import`:
|
|
113
53
|
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
54
|
+
```bash
|
|
55
|
+
npx leaf-css -i src/input.css -o dist/leaf.css [--watch] [--minify]
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
Engine tự quét source từ gốc project (CLI: thư mục chạy lệnh), bỏ qua file trong `.gitignore`.
|
|
59
|
+
**Không có cấu hình**: `@theme`, `@utility`, `@variant`, `@custom-variant`, `@plugin`, `@config`,
|
|
60
|
+
`@apply`, `@source`, `@import "tailwindcss"` trong CSS của app → build báo lỗi.
|
|
61
|
+
|
|
62
|
+
## Utility layout
|
|
63
|
+
|
|
64
|
+
Cú pháp kiểu Tailwind v4, luật của Leaf (trang docs **Layout utilities** có đủ chi tiết):
|
|
65
|
+
|
|
66
|
+
- **Đơn vị luôn là px.** `rem` / `em` trong giá trị tuỳ ý bị chặn.
|
|
67
|
+
- **Không có thang số** cho padding, margin, gap, space, w / h / size, min / max, basis, inset /
|
|
68
|
+
top / left…, translate, indent, scroll-m / p, border-spacing — chỉ nhận px tuỳ ý: `p-[16px]`,
|
|
69
|
+
`gap-[24px]`, `-mt-[4px]`, `w-[300px]`, `max-w-[448px]`. Từ khoá vẫn dùng: `0`, `px`, `auto`,
|
|
70
|
+
`full`, `screen`, `dvh` / `svh` / `lvh`, `min` / `max` / `fit`, phân số `w-1/2`.
|
|
71
|
+
- **Thang có tên giữ lại (quy ra px):** `rounded-sm` (4px) / `md` (6) / `lg` (8) / `xl` (12) /
|
|
72
|
+
`2xl` (16) / `full`, `border` / `border-2`, `shadow-*`, `blur-*`, `opacity-N`, `z-N`,
|
|
73
|
+
`duration-N`, `grid-cols-N`, `order-N`, `line-clamp-N`, `aspect-*`.
|
|
74
|
+
- **Breakpoint:** `xs:` ≤ 767px (max-width), `sm:` ≥ 768, `md:` ≥ 1024, `lg:` ≥ 1280, `xl:` ≥ 1600,
|
|
75
|
+
`2xl:` ≥ 1920; kèm `max-sm:`…, `min-[640px]:`, `max-[..]:`, container query `@container` +
|
|
76
|
+
`@sm:`….
|
|
77
|
+
- **Variant:** `hover:` (`:hover` thuần), `focus:`, `focus-visible:`, `active:`, `disabled:`,
|
|
78
|
+
`group-*`, `peer-*`, `has-*`, `not-*`, `in-*`, `aria-*`, `data-*`, `first:` / `last:` / `odd:` /
|
|
79
|
+
`even:`, `before:` / `after:`, `placeholder:`, `*:`, selector tuỳ ý `[&>svg]:`, `!` important.
|
|
80
|
+
Không có `dark:` / `light:` — theme đi theo token + `data-theme`.
|
|
81
|
+
- **Chữ và màu chỉ từ class Leaf** (`display-*`, `heading-*`, `body-*`, `body-*-highlight`,
|
|
82
|
+
`text-*`, `bg-*`, `border-*`). Không có `font-*`, `text-sm`, `leading-*`, `tracking-*`,
|
|
83
|
+
`italic`, palette (`bg-red-500`, `text-white`), màu tuỳ ý (`bg-[#fff]`), cú pháp `(--biến)`,
|
|
84
|
+
utility SVG `fill-*` / `stroke-*`. Class Leaf nhận variant và độ mờ: `md:heading-1`,
|
|
85
|
+
`hover:bg-tertiary`, `bg-primary/50`, `placeholder:text-tertiary`. Utility khác cần màu nhận hậu
|
|
86
|
+
tố Leaf: `ring-*` / `outline-*` / `divide-*` / `shadow-*` / `from-*` / `via-*` / `to-*` theo
|
|
87
|
+
thang nền, `decoration-*` / `accent-*` / `caret-*` theo thang chữ.
|
|
88
|
+
|
|
89
|
+
Class không hợp luật không sinh CSS; plugin / CLI in cảnh báo kèm gợi ý:
|
|
90
|
+
|
|
91
|
+
```text
|
|
92
|
+
[leaf-css] `m-4`: Leaf không có thang số cho `m-*` — ghi giá trị px: `m-[16px]`
|
|
119
93
|
```
|
|
120
94
|
|
|
121
95
|
```tsx
|
|
122
96
|
import { Button } from "@finhay-pro/leaf-design-system";
|
|
123
97
|
|
|
124
|
-
<section className="bg-secondary border-quaternary flex flex-col gap-
|
|
125
|
-
<h3 className="heading-3 text-primary">Tích luỹ</h3>
|
|
126
|
-
<p className="body-4 text-secondary hover:text-
|
|
98
|
+
<section className="bg-secondary border-quaternary flex flex-col gap-[12px] rounded-xl border p-[16px] md:p-[24px]">
|
|
99
|
+
<h3 className="heading-3 md:heading-2 text-primary">Tích luỹ</h3>
|
|
100
|
+
<p className="body-4 text-secondary hover:text-highlight">Lợi nhuận 8.5%/năm</p>
|
|
127
101
|
<div className="w-full md:w-auto">
|
|
128
102
|
<Button width="100%">Đầu tư</Button>
|
|
129
103
|
</div>
|
|
130
104
|
</section>;
|
|
131
105
|
```
|
|
132
106
|
|
|
133
|
-
|
|
134
|
-
`border-quaternary`…). Giá trị lẻ dùng token qua cú pháp biến của Tailwind:
|
|
135
|
-
`bg-(--base-tertiary)`, `text-(color:--text-highlight)`.
|
|
136
|
-
- Spacing / radius / độ dày viền dùng thang của Tailwind (base 4px). Thang px theo Figma:
|
|
107
|
+
Thang Figma quy ra utility:
|
|
137
108
|
|
|
138
|
-
| Figma | px |
|
|
139
|
-
| ----------------- | -------------------------------------------------------- |
|
|
140
|
-
| Spacing 2XS…7XL | 2 · 4 · 8 · 12 · 16 · 24 · 36 · 48 · 60 · 84 · 120 · 240 | `
|
|
141
|
-
| Radius S/M/L/Full | 4 · 8 · 12 · full | `rounded-sm` / `rounded-lg` / `rounded-xl` / `rounded-full`
|
|
142
|
-
| Border S/M/L/XL | 0.5 · 1 · 1.5 · 2 | `border-[0.5px]` / `border` / `border-[1.5px]` / `border-2`
|
|
109
|
+
| Figma | px | Utility |
|
|
110
|
+
| ----------------- | -------------------------------------------------------- | ----------------------------------------------------------- |
|
|
111
|
+
| Spacing 2XS…7XL | 2 · 4 · 8 · 12 · 16 · 24 · 36 · 48 · 60 · 84 · 120 · 240 | `p-[2px]` … `p-[240px]` (`gap-[12px]`, `mt-[8px]`…) |
|
|
112
|
+
| Radius S/M/L/Full | 4 · 8 · 12 · full | `rounded-sm` / `rounded-lg` / `rounded-xl` / `rounded-full` |
|
|
113
|
+
| Border S/M/L/XL | 0.5 · 1 · 1.5 · 2 | `border-[0.5px]` / `border` / `border-[1.5px]` / `border-2` |
|
|
143
114
|
|
|
144
|
-
- Component React **không nhận `className`**. Layout / spacing: bọc `div`
|
|
115
|
+
- Component React **không nhận `className`**. Layout / spacing: bọc `div` dùng utility. Màu / chữ:
|
|
145
116
|
prop token (`color`, `background`, `typography`). Size: prop `width` / `height` nếu component
|
|
146
117
|
có. HTML tĩnh gắn class Leaf (`text-*`, `bg-*`) trên markup `.leaf-*`.
|
|
147
118
|
|
|
@@ -191,8 +162,8 @@ truyền `className` vào component Leaf (dùng prop token / bọc `div`):
|
|
|
191
162
|
```tsx
|
|
192
163
|
<h2 className="heading-2">Tài sản của bạn</h2>
|
|
193
164
|
|
|
194
|
-
// Class typography lo cỡ chữ, color lo màu; khoảng cách là
|
|
195
|
-
<p className="body-3 text-secondary mt-
|
|
165
|
+
// Class typography lo cỡ chữ, color lo màu; khoảng cách là utility (`mt-[8px]`)
|
|
166
|
+
<p className="body-3 text-secondary mt-[8px]">Lợi nhuận kỳ vọng 8.5%/năm</p>
|
|
196
167
|
|
|
197
168
|
// Gắn vào component của thư viện khác cũng chỉ là một chuỗi class
|
|
198
169
|
<Link href="/tai-khoan" className="body-3-highlight">
|
|
@@ -217,8 +188,8 @@ viết thêm gì cho light mode.
|
|
|
217
188
|
| System (đủ 3 bộ) | `text-*`, `bg-*`, `border-*` với `red`, `green`, `yellow`, `orange`, `blue`, `purple` (+ `-secondary`) |
|
|
218
189
|
|
|
219
190
|
```html
|
|
220
|
-
<!-- Viền: class màu chỉ set border-color — độ dày / padding
|
|
221
|
-
<div class="bg-secondary border-quaternary
|
|
191
|
+
<!-- Viền: class màu chỉ set border-color — độ dày / padding là utility -->
|
|
192
|
+
<div class="bg-secondary border-quaternary rounded-xl border p-[16px]">
|
|
222
193
|
<h3 class="heading-3 text-primary">Tích luỹ</h3>
|
|
223
194
|
<p class="body-4 text-secondary">Lợi nhuận kỳ vọng 8.5%/năm</p>
|
|
224
195
|
<p class="body-4 text-red">Số dư không đủ</p>
|
|
@@ -260,46 +231,44 @@ Không dùng thư viện icon khác hay tự vẽ SVG icon. Icons by [Remix Icon
|
|
|
260
231
|
## Cần biết
|
|
261
232
|
|
|
262
233
|
- **Class typography chỉ set đúng 3 thuộc tính** (`font-size`, `line-height`, `font-weight`);
|
|
263
|
-
**class color chỉ set đúng 1** (`color` / `background-color` / `border-color`). Font family
|
|
264
|
-
|
|
265
|
-
(
|
|
266
|
-
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
`@layer utilities
|
|
271
|
-
|
|
272
|
-
`!important`.
|
|
273
|
-
- **Mỗi file CSS mở đầu bằng `@layer theme, base, components, utilities;`** — trùng thứ tự layer của
|
|
274
|
-
Tailwind v4, nên import file theo thứ tự nào thì class màu vẫn đứng trên CSS component. Component
|
|
275
|
-
không trông vào CSS reset: tự reset `button`, tự xử lý `[hidden]`.
|
|
276
|
-
- **Class không có biến thể `hover:` / `focus:` / opacity** — nó là CSS thuần. Cần state thì dùng
|
|
277
|
-
Tailwind (`hover:text-(color:--text-highlight)`) hoặc CSS của page với cùng token.
|
|
234
|
+
**class color chỉ set đúng 1** (`color` / `background-color` / `border-color`). Font family nằm
|
|
235
|
+
ngoài phạm vi — app tự set `body { font-family: var(--font-sans) }`. Reset tối thiểu
|
|
236
|
+
(box-sizing, margin, list, form control) có sẵn trong `@layer base`.
|
|
237
|
+
- Leaf **không** có token spacing / radius / độ dày viền — chỉ có token màu và typography; layout
|
|
238
|
+
dùng utility px.
|
|
239
|
+
- **Thứ tự layer cố định:** stylesheet sinh ra mở đầu bằng
|
|
240
|
+
`@layer properties, theme, base, components, utilities;`. Typography và CSS component nằm trong
|
|
241
|
+
`@layer components`; class màu và utility nằm trong `@layer utilities` (đè được CSS component, vd.
|
|
242
|
+
`leaf-spinner text-highlight`). CSS không layer của app override được tất cả, không cần
|
|
243
|
+
`!important`. Component không trông vào CSS reset: tự reset `button`, tự xử lý `[hidden]`.
|
|
278
244
|
- **Chỉ semantic token mới có class màu.** Primitive (`--neutral-500`, `--brand-300`…) là nguồn nội
|
|
279
|
-
bộ, dùng thẳng trong UI là mất khả năng đổi theme.
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
màu của Leaf.
|
|
285
|
-
- Typography token hiện chỉ có **bộ Desktop**. Chưa có responsive type set, nên các style Display
|
|
286
|
-
cần app tự xử lý ở breakpoint nhỏ.
|
|
245
|
+
bộ, dùng thẳng trong UI là mất khả năng đổi theme.
|
|
246
|
+
- **Tên class không có prefix.** App dùng Leaf cần cân nhắc kỹ nếu load kèm CSS framework khác
|
|
247
|
+
(Bootstrap cũng định nghĩa `.display-1`–`.display-6`).
|
|
248
|
+
- Typography token hiện chỉ có **bộ Desktop**. Display / heading lớn trên mobile: đặt class nhỏ
|
|
249
|
+
làm mặc định rồi đổi theo breakpoint (`heading-2 md:display-3`).
|
|
287
250
|
|
|
288
251
|
## Phát triển
|
|
289
252
|
|
|
290
253
|
```bash
|
|
291
|
-
pnpm --filter @finhay-pro/leaf-design-system build # tsc → dist/ + gom CSS +
|
|
292
|
-
pnpm --filter @finhay-pro/leaf-design-system dev # gom CSS + tsc --watch
|
|
254
|
+
pnpm --filter @finhay-pro/leaf-design-system build # tsc → dist/ + gom CSS + engine + CDN + skill
|
|
255
|
+
pnpm --filter @finhay-pro/leaf-design-system dev # gom CSS + engine + tsc --watch
|
|
293
256
|
pnpm --filter @finhay-pro/leaf-design-system typecheck
|
|
294
257
|
```
|
|
295
258
|
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
259
|
+
- `scripts/build-css.mjs` — gom token + reset + class Leaf + CSS từng component thành
|
|
260
|
+
`dist/engine/assets.json` (kèm bảng export → CSS component) và `dist/leaf.css` (đích của
|
|
261
|
+
`@finhay-pro/leaf-design-system/css`; bản dự phòng không utility).
|
|
262
|
+
- `scripts/build-engine.mjs` — bundle engine (`packages/css` = `@finhay/leaf-css`, chỉ `node:*`)
|
|
263
|
+
thành `dist/engine/vite.js`, `postcss.js`, `cli.js` (bin `leaf-css`).
|
|
264
|
+
- `scripts/build-cdn.mjs` — `dist/cdn/leaf-<version>.min.{css,js}`, minify bằng minifier của engine;
|
|
265
|
+
JS = `window.Leaf` + runtime sinh utility từ class trên DOM.
|
|
266
|
+
|
|
267
|
+
Không sửa file trong `dist`. Engine có test riêng ở `packages/css/test`.
|
|
299
268
|
|
|
300
269
|
`build` ghi đè `dist` tại chỗ, **không xoá `dist` trước** (chỉ `prepublishOnly` mới `clean`):
|
|
301
270
|
`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
|
|
302
|
-
của docs lỗi resolve `@finhay-pro/leaf-design-system
|
|
271
|
+
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
|
|
303
272
|
thì xoá `apps/docs/node_modules/.vite`).
|
|
304
273
|
|
|
305
274
|
**Mọi hình thức nằm trong CSS** và chỉ đọc attribute (`data-*`, `aria-*`, `:disabled`), kể cả
|
|
@@ -310,13 +279,11 @@ tĩnh viết cùng markup là ra cùng kết quả. Attribute thiếu → CSS l
|
|
|
310
279
|
`<tên>.css` của component; markup chỉ gắn class `leaf-*` (+ class typography / màu khi cần). Phần tử
|
|
311
280
|
nào CSS set `display` thì kèm rule `[hidden] { display: none }`.
|
|
312
281
|
|
|
313
|
-
Thêm bộ class mới (typography / màu): tạo `src/styles/<tên>.css` — script tự sinh `dist/<tên>.css`
|
|
314
|
-
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
|
|
315
|
-
`package.json`.
|
|
316
282
|
Thêm component React (khi thật sự cần state/behavior, không phải để bọc style): tạo
|
|
317
283
|
`src/components/<Tên>/` (kèm `<tên>.css` nếu cần) rồi re-export trong `src/index.ts`. CSS của
|
|
318
|
-
component
|
|
319
|
-
|
|
284
|
+
component được `build-css.mjs` tự gom vào `assets.json` và engine tự thêm khi app import component
|
|
285
|
+
— không khai báo gì trong `exports`. Tên file CSS phải duy nhất trong cả `src/` (script báo lỗi nếu
|
|
286
|
+
trùng).
|
|
320
287
|
Component có hành vi (Button loading · Tabs · Toggle · Dialog · Slider · Tooltip · InputOtp · InputStepper · Toast · Dropdown · Carousel · QrCode · Upload · Calendar · InputDate · MultiSelect · Form) cần thêm bản vanilla cho HTML
|
|
321
288
|
tĩnh trong `src/vanilla/` và gắn vào `window.Leaf` qua `src/vanilla/index.ts`. `src/vanilla` chỉ
|
|
322
289
|
vào bản CDN, không vào bản npm.
|
|
@@ -330,7 +297,7 @@ vào bản CDN, không vào bản npm.
|
|
|
330
297
|
| `Dialog` | Panel + backdrop blur — `open` (controlled), `title` / `onBack` / `onClose(reason)`, `dismissible`, `closeLabel` / `backLabel`, `theme`, `maxWidth` / `height` / `maxHeight` |
|
|
331
298
|
| `Logo` | Wordmark FHSC · Finhay · FHC — `brand` / `mode` / `side` / `size` |
|
|
332
299
|
| `Skeleton` | Placeholder shimmer — `width` / `height` / `border` (radius), nền `--base-tertiary` |
|
|
333
|
-
| `Empty` | Trạng thái không có dữ liệu — `image` (string URL; không truyền = ẩn, `""` = CDN mặc định) · `size` sm/md · `description` (mặc định “Không có dữ liệu”)
|
|
300
|
+
| `Empty` | Trạng thái không có dữ liệu — `image` (string URL; không truyền = ẩn, `""` = CDN mặc định) · `size` sm/md · `description` (mặc định “Không có dữ liệu”) |
|
|
334
301
|
| `Spinner` | Indicator 8 nan — `animation` (`spin` · `fade` · `pulse` · `breathe`), `size` |
|
|
335
302
|
| `Toggle` | Công tắc On/Off — `size` md/sm, `checked`, `disabled` (Figma Active Off); `name` / `value` → input ẩn cho form |
|
|
336
303
|
| `Slider` | Kéo từng `step` trong `min`–`max` (mặc định 0–100, bước 1) · mốc `steps` · `labels`; `name` → input ẩn |
|
|
@@ -347,18 +314,8 @@ vào bản CDN, không vào bản npm.
|
|
|
347
314
|
| `FileViewer` | Xem file (PDF native, XLSX / CSV, DOCX, ảnh, video / audio, text) không thư viện ngoài — `source` URL (+`fetchInit`) / Blob / base64, toolbar, `ref`; kèm `FileViewerDialog` |
|
|
348
315
|
| `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"` |
|
|
349
316
|
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
(bảng đầy đủ ở mục Import CSS) — hoặc một dòng styles.css cho tất cả */
|
|
353
|
-
@import "@finhay-pro/leaf-design-system/button.css";
|
|
354
|
-
@import "@finhay-pro/leaf-design-system/tabs.css";
|
|
355
|
-
@import "@finhay-pro/leaf-design-system/dialog.css";
|
|
356
|
-
@import "@finhay-pro/leaf-design-system/toast.css";
|
|
357
|
-
@import "@finhay-pro/leaf-design-system/input.css";
|
|
358
|
-
@import "@finhay-pro/leaf-design-system/dropdown.css";
|
|
359
|
-
/* … skeleton / empty / spinner / toggle / slider / tooltip / radio / checkbox / input-otp /
|
|
360
|
-
input-stepper / calendar / input-date / logo */
|
|
361
|
-
```
|
|
317
|
+
CSS của component không cần import riêng: plugin Leaf tự thêm CSS của component được import (kèm
|
|
318
|
+
component nó dùng bên trong, vd. `InputDate` → `Input` + `Calendar` + `Button`).
|
|
362
319
|
|
|
363
320
|
```tsx
|
|
364
321
|
import {
|
|
@@ -482,53 +439,37 @@ Mở tab mới / Tải xuống).
|
|
|
482
439
|
|
|
483
440
|
## HTML tĩnh (CDN)
|
|
484
441
|
|
|
485
|
-
Cho landing page / trang dựng tay không có bundler:
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
442
|
+
Cho landing page / trang dựng tay không có bundler: 1 `<link>` + 1 `<script>`. CSS gồm token +
|
|
443
|
+
reset + class typography / color + CSS của mọi component. Script gồm hành vi Button loading · Tabs ·
|
|
444
|
+
Toggle · Dialog · Slider · Tooltip · InputOtp · InputStepper · Toast · Dropdown · Carousel · QrCode ·
|
|
445
|
+
Upload · Calendar · InputDate · MultiSelect · Form (`data-leaf-*` / `window.Leaf`) **và runtime sinh
|
|
446
|
+
utility layout** từ class trên DOM (theo dõi DOM thay đổi) — trang dùng cùng utility như app
|
|
447
|
+
(`flex`, `gap-[16px]`, `md:grid-cols-3`), không cần CSS riêng cho layout.
|
|
489
448
|
|
|
490
449
|
```html
|
|
491
|
-
<link rel="stylesheet" href="https://<cdn>/leaf-0.2.
|
|
492
|
-
<script src="https://<cdn>/leaf-0.2.
|
|
450
|
+
<link rel="stylesheet" href="https://<cdn>/leaf-0.2.3.min.css" />
|
|
451
|
+
<script src="https://<cdn>/leaf-0.2.3.min.js" defer></script>
|
|
493
452
|
<!-- Icon: Remix Icon (xem mục Icon) -->
|
|
494
453
|
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/remixicon@4.9.1/fonts/remixicon.css" />
|
|
495
454
|
|
|
496
455
|
<style>
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
body {
|
|
500
|
-
margin: 0;
|
|
501
|
-
font-family: var(--font-sans);
|
|
502
|
-
background: var(--base-primary);
|
|
503
|
-
}
|
|
504
|
-
}
|
|
505
|
-
|
|
506
|
-
@layer page {
|
|
507
|
-
.hero {
|
|
508
|
-
display: flex;
|
|
509
|
-
flex-direction: column;
|
|
510
|
-
gap: 16px;
|
|
511
|
-
padding: 48px 16px;
|
|
512
|
-
}
|
|
513
|
-
|
|
514
|
-
@media (min-width: 768px) {
|
|
515
|
-
.hero {
|
|
516
|
-
flex-direction: row;
|
|
517
|
-
}
|
|
518
|
-
}
|
|
456
|
+
body {
|
|
457
|
+
font-family: var(--font-sans);
|
|
519
458
|
}
|
|
520
459
|
</style>
|
|
521
460
|
|
|
522
|
-
<
|
|
523
|
-
<
|
|
524
|
-
|
|
525
|
-
</
|
|
461
|
+
<body class="bg-primary">
|
|
462
|
+
<section class="flex flex-col gap-[16px] px-[16px] py-[48px] sm:flex-row">
|
|
463
|
+
<h1 class="display-3 text-primary">Finhay</h1>
|
|
464
|
+
<button class="leaf-button" data-size="md">Mở tài khoản</button>
|
|
465
|
+
</section>
|
|
466
|
+
</body>
|
|
526
467
|
```
|
|
527
468
|
|
|
528
|
-
| File | Nội dung
|
|
529
|
-
| ------------------------ |
|
|
530
|
-
| `leaf-<version>.min.css` |
|
|
531
|
-
| `leaf-<version>.min.js` | Hành vi Button loading · Tabs · Toggle · Dialog · Slider · Tooltip · InputOtp · InputStepper · Toast · Dropdown · Carousel · QrCode · Upload · Calendar · InputDate · MultiSelect · Form → `window.Leaf
|
|
469
|
+
| File | Nội dung |
|
|
470
|
+
| ------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
471
|
+
| `leaf-<version>.min.css` | Đã minify: token + reset + typography + color + CSS của mọi component. |
|
|
472
|
+
| `leaf-<version>.min.js` | Hành vi Button loading · Tabs · Toggle · Dialog · Slider · Tooltip · InputOtp · InputStepper · Toast · Dropdown · Carousel · QrCode · Upload · Calendar · InputDate · MultiSelect · Form → `window.Leaf` + runtime utility layout. |
|
|
532
473
|
|
|
533
474
|
Bản CDN nằm trong package npm (`dist/cdn/`), nên jsDelivr phục vụ trực tiếp theo version:
|
|
534
475
|
`https://cdn.jsdelivr.net/npm/@finhay-pro/leaf-design-system@<version>/dist/cdn/leaf-<version>.min.css`
|
|
@@ -609,8 +550,8 @@ thì đọc lại mỗi lần đặt vị trí). Bubble `pointer-events: none`
|
|
|
609
550
|
Span rỗng `.leaf-logo` + `data-brand` / `data-mode` / `data-side` + `--leaf-logo-size`. CSS gắn
|
|
610
551
|
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
|
|
611
552
|
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 ô
|
|
612
|
-
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ì
|
|
613
|
-
`logo
|
|
553
|
+
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ì plugin Leaf tự thêm data-URI khi thấy class
|
|
554
|
+
`leaf-logo` trong markup (component React render `<img>` nên không cần).
|
|
614
555
|
|
|
615
556
|
### Radio / Checkbox / Input
|
|
616
557
|
|
|
@@ -683,16 +624,16 @@ overlay = `.leaf-spinner-overlay` (app tự `hidden`/mount).
|
|
|
683
624
|
- **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ự
|
|
684
625
|
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)
|
|
685
626
|
trước.
|
|
686
|
-
- **Không kèm font
|
|
687
|
-
`body { font-family: var(--font-sans) }`.
|
|
627
|
+
- **Không kèm font.** Tự load Inter (Google Fonts hoặc self-host) và set
|
|
628
|
+
`body { font-family: var(--font-sans) }`. Reset tối thiểu đã có trong `@layer base`.
|
|
688
629
|
- **CSS của trang phải nằm trong `@layer` nếu đụng vào element của component.** Style component
|
|
689
630
|
nằm trong `@layer components`, mà CSS không layer luôn thắng CSS có layer bất kể specificity —
|
|
690
631
|
reset kiểu `* { padding: 0 }` hay `button { background: none }` đặt trần sẽ xoá padding / nền
|
|
691
632
|
của `.leaf-button`. Bọc reset trong `@layer base { … }`, layout của page trong một layer riêng
|
|
692
633
|
(vd. `@layer page`, khai báo sau `utilities` nếu muốn đè cả class màu).
|
|
693
|
-
- **
|
|
694
|
-
|
|
695
|
-
|
|
634
|
+
- **Utility layout cần `leaf.js`.** Runtime trong script sinh CSS cho `flex`, `gap-[16px]`,
|
|
635
|
+
`md:grid-cols-3`… từ class trên trang; thiếu script thì chỉ còn token, class Leaf và CSS
|
|
636
|
+
component. Luật utility giống bản npm (px, không thang số, chữ / màu chỉ từ class Leaf).
|
|
696
637
|
- **Trình duyệt tối thiểu** (CSS dùng `@layer`): Chrome / Edge 99+, Safari 15.4+, Firefox 97+.
|
|
697
638
|
- Dark là mặc định; `data-theme="light"` trên `<html>` để chuyển light.
|
|
698
639
|
- z-index của lớp phủ đọc `--leaf-z-dropdown` (30) / `--leaf-z-dialog` (50) /
|
|
@@ -711,6 +652,78 @@ overlay = `.leaf-spinner-overlay` (app tự `hidden`/mount).
|
|
|
711
652
|
|
|
712
653
|
## Changelog
|
|
713
654
|
|
|
655
|
+
### 0.2.3
|
|
656
|
+
|
|
657
|
+
> ⚠️ **Breaking** — Leaf tự sinh utility layout, không còn dùng Tailwind. Xem **Nâng cấp từ 0.2.2**
|
|
658
|
+
> bên dưới trước khi nâng.
|
|
659
|
+
|
|
660
|
+
**Engine CSS của Leaf thay Tailwind (không third party)**
|
|
661
|
+
|
|
662
|
+
- Một dòng `@import "@finhay-pro/leaf-design-system/css";` + plugin `@finhay-pro/leaf-design-system/vite`
|
|
663
|
+
hoặc `/postcss`; HTML tĩnh có build dùng CLI `npx leaf-css -i input.css -o leaf.css [--watch]
|
|
664
|
+
[--minify]`. Engine bundle trong `dist/engine`, chỉ import `node:*`; package không có
|
|
665
|
+
`dependencies`.
|
|
666
|
+
- Thứ tự output: token (`@layer theme`) + reset (`@layer base`) → **CSS của component đang dùng**
|
|
667
|
+
(nhận qua named import, kể cả phụ thuộc bắc cầu, hoặc class `leaf-*` trong markup) → class typo /
|
|
668
|
+
màu Leaf → **utility có trong source** (tree-shaking, quét gốc project theo `.gitignore`).
|
|
669
|
+
- Utility cú pháp kiểu Tailwind v4: layout, flex / grid, spacing, sizing, background (trừ màu),
|
|
670
|
+
border (trừ màu), effect, filter, transform, transition, interactivity…; variant state,
|
|
671
|
+
`group-*` / `peer-*` / `has-*` / `not-*`, `aria-*` / `data-*`, arbitrary `[&>svg]:`, `!`, container
|
|
672
|
+
query. Class màu / typo Leaf nhận variant và opacity (`md:heading-1`, `hover:bg-tertiary`,
|
|
673
|
+
`bg-primary/50`).
|
|
674
|
+
- Luật Leaf: chỉ px (từ chối `rem` / `em`); spacing / size / inset không có thang số
|
|
675
|
+
(`p-[16px]`, không `p-4`); không font / cỡ chữ / `leading-*` / palette / màu tuỳ ý / `dark:`;
|
|
676
|
+
không cấu hình (`@theme`, `@utility`, `@apply`, `@source`, `@import "tailwindcss"`… → lỗi
|
|
677
|
+
build). Class bị từ chối có cảnh báo kèm gợi ý.
|
|
678
|
+
- Breakpoint mới: `xs` ≤ 767 · `sm` ≥ 768 · `md` ≥ 1024 · `lg` ≥ 1280 · `xl` ≥ 1600 · `2xl` ≥ 1920;
|
|
679
|
+
thêm `max-*`, `min-[..]`, `max-[..]`.
|
|
680
|
+
- CDN: `leaf-<ver>.min.js` kèm runtime sinh utility từ class trên DOM (thay `@tailwindcss/browser`);
|
|
681
|
+
`leaf-<ver>.min.css` minify bằng minifier của engine.
|
|
682
|
+
- Hiệu năng (docs, 276 file): build lần đầu ~37ms, HMR ~2ms, runtime CDN ~0,6ms / 500 class.
|
|
683
|
+
|
|
684
|
+
**Table — bảng dữ liệu (React + leaf.js)**
|
|
685
|
+
|
|
686
|
+
- `Table` + `Leaf.table.create(root, options)` (data mode) và `data-leaf-table` (static mode: sort +
|
|
687
|
+
resize trên markup render sẵn) — cùng markup, logic dùng chung `core/table/`.
|
|
688
|
+
- Header luôn sticky, group header nhiều tầng (`children`); pin cột (`stickyColumns`,
|
|
689
|
+
`pin: "left" | "right"`), mép vùng pin có đường kẻ; nền theo cột `background` (`LeafBgColor`).
|
|
690
|
+
- Sort 3 trạng thái (none → asc → desc), `sortDescFirst`, `sortFn`, `manualSort`; width / `minWidth`
|
|
691
|
+
/ `maxWidth` / `grow`, resize bằng kéo (Pointer Events), phím ← → (Shift ×5), double-click về mặc
|
|
692
|
+
định; text không bao giờ bị cắt.
|
|
693
|
+
- Rowspan / colspan (`span`, `mergeRows`), virtual theo hàng (`rowHeight`, `overscan`), realtime
|
|
694
|
+
`column.flash` (một timer cho cả bảng, dòng memo), `bordered`, `striped`, `size`, loading, rỗng,
|
|
695
|
+
`onRowClick`; ref `TableHandle` (`scrollToRow`, `scrollToTop`).
|
|
696
|
+
- leaf.js: `setOptions`, `setRows`, `update({ [rowId]: patch })` (gộp theo frame), `getSort` /
|
|
697
|
+
`setSort`, `getColumnWidths` / `setColumnWidths`, `scrollToRow`, `destroy`; event
|
|
698
|
+
`leaf:table-sort-change`, `leaf:table-resize`.
|
|
699
|
+
- Icon mới `arrow-up-line` / `arrow-down-line`; `bgColorToken` trong `utils/colorClass.ts`.
|
|
700
|
+
|
|
701
|
+
**Bảo mật**
|
|
702
|
+
|
|
703
|
+
- leaf.js MultiSelect: chip dựng bằng DOM API (`createElement` / `textContent`), `leading` dùng
|
|
704
|
+
`cloneNode` — label chứa HTML (kể cả đã escape từ server) không còn thành thẻ thật. DOM output
|
|
705
|
+
không đổi.
|
|
706
|
+
- Ghi rõ `data-tooltip` (Tooltip) và mẫu `renderTabs` chỉ nhận markup tin cậy.
|
|
707
|
+
- Dev / CI (không vào bản publish): vitest 5.0.5 (vá `@vitest/mocker`), override `undici` ^8.12.2,
|
|
708
|
+
GitHub Actions chạy Node 24, CI chạy `format:check`; site docs thêm header bảo mật nginx.
|
|
709
|
+
|
|
710
|
+
**Nâng cấp từ 0.2.2**
|
|
711
|
+
|
|
712
|
+
| 0.2.2 | 0.2.3 |
|
|
713
|
+
| ------------------------------------------------------------------------------------------ | -------------------------------------------------------------------------- |
|
|
714
|
+
| `@import ".../styles.css"` / `tokens.css` / `typography.css` / `color.css` / `classes.css` | `@import "@finhay-pro/leaf-design-system/css";` + plugin Vite / PostCSS |
|
|
715
|
+
| CSS lẻ từng component (`button.css`, `tabs.css`, `logo-assets.css`…) | Đã xoá — engine tự lấy CSS của component đang dùng |
|
|
716
|
+
| `tailwindcss`, `@tailwindcss/vite` / `postcss` / `browser` | `leaf()` / plugin PostCSS / CLI `leaf-css` / JS CDN — gỡ Tailwind khỏi app |
|
|
717
|
+
| `p-4`, `gap-6`, `w-40`, `max-w-md` | `p-[16px]`, `gap-[24px]`, `w-[160px]`, `max-w-[448px]` |
|
|
718
|
+
| `sm:` 640 · `md:` 768 · `lg:` 1024 · `xl:` 1280 | `sm:` 768 · `md:` 1024 · `lg:` 1280 · `xl:` 1600 (`xs:` ≤ 767) |
|
|
719
|
+
| `bg-(--base-tertiary)`, `text-(color:--x)` | `bg-tertiary`, `text-*` (có variant: `hover:bg-tertiary`) |
|
|
720
|
+
| `font-*`, `text-[24px]`, `leading-*`, `rem` / `em` | class typo Leaf (`md:heading-1`), px |
|
|
721
|
+
| Token không layer | Token trong `@layer theme` — CSS không layer của app luôn đè được |
|
|
722
|
+
|
|
723
|
+
`exports` chỉ còn `.`, `./css`, `./vite`, `./postcss`; thêm bin `leaf-css`. Giữ nguyên điểm gãy
|
|
724
|
+
cũ khi migrate: `md:` → `sm:`, `lg:` → `md:`, `sm:` → `min-[640px]:`. API React / `window.Leaf`
|
|
725
|
+
của component có sẵn không đổi.
|
|
726
|
+
|
|
714
727
|
### 0.2.2
|
|
715
728
|
|
|
716
729
|
**Đọc file — không thư viện ngoài**
|
|
@@ -879,8 +892,7 @@ formats, dropLabel, onReject }`.
|
|
|
879
892
|
|
|
880
893
|
- Bỏ class layout / spacing / border width / radius khỏi Leaf: xoá `spacing.css`, `border.css`,
|
|
881
894
|
`flex.css`, `grid.css`, `sizing.css`, `overflow.css`, `position.css`, `text-layout.css` (cả
|
|
882
|
-
export npm lẫn trong `classes.css` / `styles.css` / CDN). Next.js dùng Tailwind
|
|
883
|
-
[Dùng với Next.js + Tailwind](#dùng-với-nextjs--tailwind)), landing page dùng CSS của page. Trang
|
|
895
|
+
export npm lẫn trong `classes.css` / `styles.css` / CDN). Next.js dùng Tailwind, landing page dùng CSS của page. Trang
|
|
884
896
|
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
|
|
885
897
|
chuyển sang CSS riêng trước khi lên 0.1.8.
|
|
886
898
|
- Bỏ token `--spacing-*`, `--border-width-*`, `--radius-*` (file `spacing.css` / `border.css` của
|