@openway/ui 1.0.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/LICENSE +21 -0
- package/README.md +181 -0
- package/dist/index.cjs +3 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +7970 -0
- package/dist/index.d.ts +7970 -0
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -0
- package/package.json +63 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 MAI ANH HOANG from OpenWay VietNam
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
# @openway/ui
|
|
2
|
+
|
|
3
|
+
Bộ thư viện UI components dùng chung, tối ưu hóa cho React 19, Next.js 16+ và Tailwind CSS (hỗ trợ đầy đủ Tailwind CSS v4 & v3).
|
|
4
|
+
|
|
5
|
+
Thư viện được thiết kế theo triết lý **Theme-agnostic (Tùy biến bảng màu linh hoạt)**: Thư viện chỉ cung cấp bộ khung layout và logic WAI-ARIA, còn bảng màu (`primary`, `secondary`, `neutral`...) hoàn toàn do dự án của bạn quyết định thông qua file CSS toàn cục (`globals.css`).
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## 1. Cài đặt
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
pnpm add @openway/ui
|
|
13
|
+
# hoặc
|
|
14
|
+
npm install @openway/ui
|
|
15
|
+
# hoặc
|
|
16
|
+
yarn add @openway/ui
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
---
|
|
20
|
+
|
|
21
|
+
## 2. Cấu hình bảng màu trong dự án của bạn
|
|
22
|
+
|
|
23
|
+
Bạn hoàn toàn tự do lựa chọn bất kỳ mã màu thương hiệu nào bạn thích (xanh lam, tím, cam, đen trắng...).
|
|
24
|
+
|
|
25
|
+
### Cách cấu hình với Tailwind CSS v4 (Khuyên dùng)
|
|
26
|
+
|
|
27
|
+
Trong file `app/globals.css` (hoặc file CSS chính của bạn):
|
|
28
|
+
|
|
29
|
+
```css
|
|
30
|
+
@import "tailwindcss";
|
|
31
|
+
|
|
32
|
+
/* 1. Chỉ định Tailwind quét các components của @openway/ui */
|
|
33
|
+
@source "../node_modules/@openway/ui";
|
|
34
|
+
|
|
35
|
+
/* 2. Tự cung cấp bảng màu bạn thích */
|
|
36
|
+
@theme {
|
|
37
|
+
/* Màu chủ đạo (Primary) */
|
|
38
|
+
--color-primary-50: #f0f7ff;
|
|
39
|
+
--color-primary-100: #e0effe;
|
|
40
|
+
--color-primary-200: #bae0fd;
|
|
41
|
+
--color-primary-300: #7cc5fb;
|
|
42
|
+
--color-primary-400: #36a4f6;
|
|
43
|
+
--color-primary-500: #0284c7; /* Màu chính của nút, checkbox, active tab... */
|
|
44
|
+
--color-primary-600: #0369a1; /* Màu khi hover nút, focus... */
|
|
45
|
+
--color-primary-700: #075985;
|
|
46
|
+
--color-primary-800: #0c4a6e;
|
|
47
|
+
--color-primary-900: #0a3d5b;
|
|
48
|
+
--color-primary-950: #06273c;
|
|
49
|
+
|
|
50
|
+
/* Màu phụ (Secondary) */
|
|
51
|
+
--color-secondary-50: #faf5ff;
|
|
52
|
+
--color-secondary-100: #f3e8ff;
|
|
53
|
+
--color-secondary-500: #a855f7;
|
|
54
|
+
--color-secondary-600: #9333ea;
|
|
55
|
+
--color-secondary-700: #7e22ce;
|
|
56
|
+
|
|
57
|
+
/* Màu trung tính cho nền, viền, chữ (Neutral) */
|
|
58
|
+
--color-neutral-white: #ffffff;
|
|
59
|
+
--color-neutral-50: #f8fafc;
|
|
60
|
+
--color-neutral-100: #f1f5f9;
|
|
61
|
+
--color-neutral-200: #e2e8f0;
|
|
62
|
+
--color-neutral-300: #cbd5e1;
|
|
63
|
+
--color-neutral-400: #94a3b8;
|
|
64
|
+
--color-neutral-500: #64748b;
|
|
65
|
+
--color-neutral-600: #475569;
|
|
66
|
+
--color-neutral-700: #334155;
|
|
67
|
+
--color-neutral-800: #1e293b;
|
|
68
|
+
--color-neutral-900: #0f172a;
|
|
69
|
+
--color-neutral-950: #020617;
|
|
70
|
+
--color-neutral-black: #000000;
|
|
71
|
+
|
|
72
|
+
/* Màu thông báo trạng thái (Error, Warning, Success, Info) */
|
|
73
|
+
--color-error-500: #ef4444;
|
|
74
|
+
--color-error-600: #dc2626;
|
|
75
|
+
|
|
76
|
+
--color-warning-500: #f59e0b;
|
|
77
|
+
--color-warning-600: #d97706;
|
|
78
|
+
|
|
79
|
+
--color-success-500: #10b981;
|
|
80
|
+
--color-success-600: #059669;
|
|
81
|
+
|
|
82
|
+
--color-info-500: #3b82f6;
|
|
83
|
+
--color-info-600: #2563eb;
|
|
84
|
+
}
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
---
|
|
88
|
+
|
|
89
|
+
### Cách cấu hình với Tailwind CSS v3
|
|
90
|
+
|
|
91
|
+
Nếu dự án của bạn đang dùng `tailwind.config.js`:
|
|
92
|
+
|
|
93
|
+
```js
|
|
94
|
+
// tailwind.config.js
|
|
95
|
+
module.exports = {
|
|
96
|
+
content: [
|
|
97
|
+
"./app/**/*.{js,ts,jsx,tsx}",
|
|
98
|
+
"./components/**/*.{js,ts,jsx,tsx}",
|
|
99
|
+
// Thêm dòng này để quét class của @openway/ui:
|
|
100
|
+
"./node_modules/@openway/ui/**/*.{js,cjs,ts,tsx}",
|
|
101
|
+
],
|
|
102
|
+
theme: {
|
|
103
|
+
extend: {
|
|
104
|
+
colors: {
|
|
105
|
+
primary: {
|
|
106
|
+
50: "#f0f7ff",
|
|
107
|
+
100: "#e0effe",
|
|
108
|
+
500: "#0284c7",
|
|
109
|
+
600: "#0369a1",
|
|
110
|
+
700: "#075985",
|
|
111
|
+
},
|
|
112
|
+
neutral: {
|
|
113
|
+
white: "#ffffff",
|
|
114
|
+
50: "#f8fafc",
|
|
115
|
+
100: "#f1f5f9",
|
|
116
|
+
200: "#e2e8f0",
|
|
117
|
+
800: "#1e293b",
|
|
118
|
+
900: "#0f172a",
|
|
119
|
+
},
|
|
120
|
+
// Tương tự cho secondary, error, warning, success...
|
|
121
|
+
},
|
|
122
|
+
},
|
|
123
|
+
},
|
|
124
|
+
};
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
---
|
|
128
|
+
|
|
129
|
+
## 3. Cách sử dụng
|
|
130
|
+
|
|
131
|
+
Trong `app/layout.tsx`:
|
|
132
|
+
```tsx
|
|
133
|
+
import "./globals.css"; // Chỉ cần import file CSS của dự án bạn
|
|
134
|
+
|
|
135
|
+
export default function RootLayout({ children }: { children: React.ReactNode }) {
|
|
136
|
+
return (
|
|
137
|
+
<html lang="vi">
|
|
138
|
+
<body>{children}</body>
|
|
139
|
+
</html>
|
|
140
|
+
);
|
|
141
|
+
}
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
Trong bất kỳ Component / Trang nào:
|
|
145
|
+
```tsx
|
|
146
|
+
import { Button, Input, DatePicker } from "@openway/ui";
|
|
147
|
+
|
|
148
|
+
export default function Page() {
|
|
149
|
+
return (
|
|
150
|
+
<div className="p-6 space-y-4">
|
|
151
|
+
<Input label="Họ và tên" placeholder="Nhập họ và tên..." />
|
|
152
|
+
|
|
153
|
+
<DatePicker label="Ngày sinh" placeholder="Chọn ngày sinh" />
|
|
154
|
+
|
|
155
|
+
<Button color="primary" variant="filled">
|
|
156
|
+
Lưu thông tin
|
|
157
|
+
</Button>
|
|
158
|
+
</div>
|
|
159
|
+
);
|
|
160
|
+
}
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
---
|
|
164
|
+
|
|
165
|
+
## 4. Danh sách các Token màu sắc được hỗ trợ
|
|
166
|
+
|
|
167
|
+
| Tên Token | Mô tả | Các sắc độ khuyên dùng |
|
|
168
|
+
| :--- | :--- | :--- |
|
|
169
|
+
| `primary` | Màu nhận diện thương hiệu chủ đạo (Nút, Tab đang chọn, Viền focus, Checkbox, Radio...) | `50` $\rightarrow$ `950` (Tối thiểu cần `500`, `600`) |
|
|
170
|
+
| `secondary` | Màu phụ, nút thứ cấp | `50` $\rightarrow$ `950` (Tối thiểu cần `500`, `600`) |
|
|
171
|
+
| `neutral` | Màu khung viền, nền xám, nền input, màu chữ tiêu đề và mô tả | `white`, `50` $\rightarrow$ `950`, `black` |
|
|
172
|
+
| `error` | Trạng thái lỗi, thông báo lỗi form, nút xóa nguy hiểm | `50`, `100`, `500`, `600` |
|
|
173
|
+
| `warning` | Cảnh báo, trạng thái chờ | `50`, `100`, `500`, `600` |
|
|
174
|
+
| `success` | Thành công, hoàn thành | `50`, `100`, `500`, `600` |
|
|
175
|
+
| `info` | Thông tin hướng dẫn | `50`, `100`, `500`, `600` |
|
|
176
|
+
|
|
177
|
+
---
|
|
178
|
+
|
|
179
|
+
## 5. Giấy phép
|
|
180
|
+
|
|
181
|
+
Phát hành dưới giấy phép [MIT](LICENSE).
|