@nhatdev94/common-ui 1.1.7 → 1.1.9
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 +210 -0
- package/package.json +49 -49
package/README.md
CHANGED
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
# 📦 Common UI Library
|
|
2
|
+
|
|
3
|
+
**Package Name:** `@nhatdev94/common-ui`\
|
|
4
|
+
**Document Version:** 1.1\
|
|
5
|
+
**Last Updated:**
|
|
6
|
+
**Owner:**
|
|
7
|
+
**Status:**
|
|
8
|
+
|
|
9
|
+
------------------------------------------------------------------------
|
|
10
|
+
|
|
11
|
+
## Requirements
|
|
12
|
+
|
|
13
|
+
This package requires:
|
|
14
|
+
|
|
15
|
+
- React 18+
|
|
16
|
+
- Tailwind CSS v4
|
|
17
|
+
|
|
18
|
+
------------------------------------------------------------------------
|
|
19
|
+
|
|
20
|
+
## Installation
|
|
21
|
+
|
|
22
|
+
Để sử dụng các thành phần UI, bạn cần cài đặt thư viện và cấu hình Tailwind CSS v4 để nhận diện các lớp tiện ích (utility classes) từ gói package này.
|
|
23
|
+
|
|
24
|
+
1. Cài đặt package
|
|
25
|
+
|
|
26
|
+
``` bash
|
|
27
|
+
npm install @nhatdev94/common-ui
|
|
28
|
+
```
|
|
29
|
+
or
|
|
30
|
+
|
|
31
|
+
``` bash
|
|
32
|
+
pnpm add @nhatdev94/common-ui
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
2. Import Theme
|
|
36
|
+
Thư viện cung cấp các bộ giao diện (themes) khác nhau. Bạn cần import file CSS của theme vào file CSS chính (ví dụ index.css hoặc globals.css) để áp dụng các biến màu sắc và kiểu dáng:
|
|
37
|
+
|
|
38
|
+
``` bash
|
|
39
|
+
/* Trong file CSS chính của bạn */
|
|
40
|
+
@import "tailwindcss";
|
|
41
|
+
@import "@nhatdev94/common-ui/themes/default.css";
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
Bạn có thể thay đổi default.css bằng các theme khác nếu thư viện có hỗ trợ (ví dụ: emerald.css).
|
|
45
|
+
|
|
46
|
+
3. Cấu hình Tailwind v4 (Nếu thiếu Style)
|
|
47
|
+
Nếu bạn nhận thấy các Component hiển thị nhưng bị mất các class tiện ích của Tailwind (như padding, margin, màu sắc động), đó là do Tailwind v4 chưa quét qua mã nguồn của thư viện.
|
|
48
|
+
|
|
49
|
+
Hãy thêm dòng @source bên dưới phần import trong file CSS:
|
|
50
|
+
``` bash
|
|
51
|
+
@import "tailwindcss";
|
|
52
|
+
@import "@nhatdev94/common-ui/themes/emerald.css";
|
|
53
|
+
|
|
54
|
+
/* Thêm dòng này nếu Component không hiển thị đúng Style */
|
|
55
|
+
@source "../node_modules/@nhatdev94/common-ui/dist/**/*.js";
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
------------------------------------------------------------------------
|
|
59
|
+
|
|
60
|
+
# 1. Executive Summary
|
|
61
|
+
|
|
62
|
+
`@nhatdev94/common-ui` là thư viện UI component dùng chung cho toàn bộ hệ
|
|
63
|
+
sinh thái frontend của công ty.
|
|
64
|
+
|
|
65
|
+
Mục tiêu:
|
|
66
|
+
|
|
67
|
+
- Chuẩn hóa giao diện giữa các hệ thống
|
|
68
|
+
- Giảm duplication code
|
|
69
|
+
- Tăng tốc độ phát triển
|
|
70
|
+
- Đảm bảo tính nhất quán (consistency)
|
|
71
|
+
- Tăng khả năng maintain và scale
|
|
72
|
+
|
|
73
|
+
------------------------------------------------------------------------
|
|
74
|
+
|
|
75
|
+
# 2. Scope
|
|
76
|
+
|
|
77
|
+
## 2.1 In Scope
|
|
78
|
+
|
|
79
|
+
- Atomic UI Components (Button, Input, Modal, Table, etc.)
|
|
80
|
+
- Design tokens (color, spacing, typography)
|
|
81
|
+
- Accessibility compliant components
|
|
82
|
+
|
|
83
|
+
## 2.2 Out of Scope
|
|
84
|
+
|
|
85
|
+
- Business logic
|
|
86
|
+
- API integration
|
|
87
|
+
- Global state management
|
|
88
|
+
- Application routing
|
|
89
|
+
- Domain-specific UI
|
|
90
|
+
|
|
91
|
+
------------------------------------------------------------------------
|
|
92
|
+
|
|
93
|
+
# 3. Architecture Overview
|
|
94
|
+
|
|
95
|
+
## 3.1 Design Principles
|
|
96
|
+
|
|
97
|
+
1. Component-driven development
|
|
98
|
+
2. Stateless by default
|
|
99
|
+
3. Business-agnostic
|
|
100
|
+
4. Backward-compatible changes
|
|
101
|
+
5. Accessibility-first mindset
|
|
102
|
+
|
|
103
|
+
------------------------------------------------------------------------
|
|
104
|
+
|
|
105
|
+
## 3.2 Tech Stack
|
|
106
|
+
|
|
107
|
+
- React 18+
|
|
108
|
+
- TypeScript
|
|
109
|
+
- TailwindCSS
|
|
110
|
+
- Storybook
|
|
111
|
+
- Vitest
|
|
112
|
+
- tsup
|
|
113
|
+
|
|
114
|
+
------------------------------------------------------------------------
|
|
115
|
+
|
|
116
|
+
# 4. Folder Structure
|
|
117
|
+
|
|
118
|
+
``` bash
|
|
119
|
+
common-ui/
|
|
120
|
+
├─ src/
|
|
121
|
+
│ ├─ components/
|
|
122
|
+
│ ├─ hooks/
|
|
123
|
+
│ ├─ lib/
|
|
124
|
+
│ ├─ stories/
|
|
125
|
+
│ ├─ themes/
|
|
126
|
+
│ └─ index.ts
|
|
127
|
+
├─ .storybook/
|
|
128
|
+
├─ dist/
|
|
129
|
+
├─ package.json
|
|
130
|
+
├─ tsconfig.json
|
|
131
|
+
├─ tsup.config.json
|
|
132
|
+
└─ README.md
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
------------------------------------------------------------------------
|
|
136
|
+
|
|
137
|
+
# 5. Component Standards
|
|
138
|
+
|
|
139
|
+
## Naming Convention
|
|
140
|
+
|
|
141
|
+
- PascalCase cho component name
|
|
142
|
+
- KebabCase cho file name
|
|
143
|
+
- Props interface: `ComponentNameProps`
|
|
144
|
+
- Không sử dụng default export
|
|
145
|
+
|
|
146
|
+
## Rules
|
|
147
|
+
|
|
148
|
+
- Không gọi API
|
|
149
|
+
- Không import từ application layer
|
|
150
|
+
- Không chứa business validation logic
|
|
151
|
+
- Không phụ thuộc Redux / Zustand / App Context
|
|
152
|
+
|
|
153
|
+
------------------------------------------------------------------------
|
|
154
|
+
|
|
155
|
+
# 6. Storybook Governance
|
|
156
|
+
|
|
157
|
+
- Mỗi component bắt buộc có story
|
|
158
|
+
- Có default state và variants
|
|
159
|
+
- Có edge cases
|
|
160
|
+
|
|
161
|
+
Run:
|
|
162
|
+
|
|
163
|
+
``` bash
|
|
164
|
+
npm run storybook
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
Build:
|
|
168
|
+
|
|
169
|
+
``` bash
|
|
170
|
+
npm run build-storybook
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
------------------------------------------------------------------------
|
|
174
|
+
|
|
175
|
+
# 7. Versioning Policy
|
|
176
|
+
|
|
177
|
+
Tuân theo Semantic Versioning:
|
|
178
|
+
|
|
179
|
+
Type Meaning
|
|
180
|
+
------- ------------------
|
|
181
|
+
MAJOR Breaking changes
|
|
182
|
+
MINOR New feature
|
|
183
|
+
PATCH Bug fix
|
|
184
|
+
|
|
185
|
+
------------------------------------------------------------------------
|
|
186
|
+
|
|
187
|
+
# 8. CI/CD Workflow
|
|
188
|
+
|
|
189
|
+
1. Pull Request
|
|
190
|
+
2. Lint & Test (planned)
|
|
191
|
+
3. Review
|
|
192
|
+
4. Merge to main
|
|
193
|
+
5. Automated publish (planned)
|
|
194
|
+
|
|
195
|
+
------------------------------------------------------------------------
|
|
196
|
+
|
|
197
|
+
# 9. Security & Performance
|
|
198
|
+
|
|
199
|
+
- Tree-shakeable exports
|
|
200
|
+
- Không bundle React
|
|
201
|
+
- ESM & CJS output
|
|
202
|
+
- Audit dependency định kỳ
|
|
203
|
+
|
|
204
|
+
------------------------------------------------------------------------
|
|
205
|
+
|
|
206
|
+
# 10. Conclusion
|
|
207
|
+
|
|
208
|
+
`@nhatdev94/common-ui` là nền tảng UI governance cho toàn bộ frontend
|
|
209
|
+
ecosystem, đảm bảo consistency, scalability và maintainability cho sản
|
|
210
|
+
phẩm.
|
package/package.json
CHANGED
|
@@ -1,49 +1,49 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@nhatdev94/common-ui",
|
|
3
|
-
"version": "1.1.
|
|
4
|
-
"description": "",
|
|
5
|
-
"main": "dist/index.cjs",
|
|
6
|
-
"module": "dist/index.js",
|
|
7
|
-
"types": "dist/index.d.ts",
|
|
8
|
-
"files": [
|
|
9
|
-
"dist"
|
|
10
|
-
],
|
|
11
|
-
"exports": {
|
|
12
|
-
".": {
|
|
13
|
-
"import": "./dist/index.js",
|
|
14
|
-
"require": "./dist/index.cjs",
|
|
15
|
-
"types": "./dist/index.d.ts"
|
|
16
|
-
},
|
|
17
|
-
"./themes/*": "./dist/themes/*"
|
|
18
|
-
},
|
|
19
|
-
"sideEffects": [
|
|
20
|
-
"**/*.css"
|
|
21
|
-
],
|
|
22
|
-
"scripts": {
|
|
23
|
-
"build": "tsup && npm run copy-themes",
|
|
24
|
-
"copy-themes": "copyfiles -u 1 \"src/themes/*.css\" dist"
|
|
25
|
-
},
|
|
26
|
-
"keywords": [],
|
|
27
|
-
"author": "",
|
|
28
|
-
"license": "ISC",
|
|
29
|
-
"type": "commonjs",
|
|
30
|
-
"dependencies": {
|
|
31
|
-
"class-variance-authority": "^0.7.1",
|
|
32
|
-
"clsx": "^2.1.1",
|
|
33
|
-
"lucide-react": "^0.576.0",
|
|
34
|
-
"next-themes": "^0.4.6",
|
|
35
|
-
"radix-ui": "^1.4.3",
|
|
36
|
-
"sonner": "^2.0.7",
|
|
37
|
-
"tailwind-merge": "^3.5.0"
|
|
38
|
-
},
|
|
39
|
-
"devDependencies": {
|
|
40
|
-
"@types/react": "^19.2.14",
|
|
41
|
-
"copyfiles": "^2.4.1",
|
|
42
|
-
"react": "^19.2.4",
|
|
43
|
-
"tsup": "^8.5.1",
|
|
44
|
-
"typescript": "^5.9.3"
|
|
45
|
-
},
|
|
46
|
-
"peerDependencies": {
|
|
47
|
-
"react": ">=18"
|
|
48
|
-
}
|
|
49
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@nhatdev94/common-ui",
|
|
3
|
+
"version": "1.1.9",
|
|
4
|
+
"description": "",
|
|
5
|
+
"main": "dist/index.cjs",
|
|
6
|
+
"module": "dist/index.js",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"files": [
|
|
9
|
+
"dist"
|
|
10
|
+
],
|
|
11
|
+
"exports": {
|
|
12
|
+
".": {
|
|
13
|
+
"import": "./dist/index.js",
|
|
14
|
+
"require": "./dist/index.cjs",
|
|
15
|
+
"types": "./dist/index.d.ts"
|
|
16
|
+
},
|
|
17
|
+
"./themes/*": "./dist/themes/*"
|
|
18
|
+
},
|
|
19
|
+
"sideEffects": [
|
|
20
|
+
"**/*.css"
|
|
21
|
+
],
|
|
22
|
+
"scripts": {
|
|
23
|
+
"build": "tsup && npm run copy-themes",
|
|
24
|
+
"copy-themes": "copyfiles -u 1 \"src/themes/*.css\" dist"
|
|
25
|
+
},
|
|
26
|
+
"keywords": [],
|
|
27
|
+
"author": "",
|
|
28
|
+
"license": "ISC",
|
|
29
|
+
"type": "commonjs",
|
|
30
|
+
"dependencies": {
|
|
31
|
+
"class-variance-authority": "^0.7.1",
|
|
32
|
+
"clsx": "^2.1.1",
|
|
33
|
+
"lucide-react": "^0.576.0",
|
|
34
|
+
"next-themes": "^0.4.6",
|
|
35
|
+
"radix-ui": "^1.4.3",
|
|
36
|
+
"sonner": "^2.0.7",
|
|
37
|
+
"tailwind-merge": "^3.5.0"
|
|
38
|
+
},
|
|
39
|
+
"devDependencies": {
|
|
40
|
+
"@types/react": "^19.2.14",
|
|
41
|
+
"copyfiles": "^2.4.1",
|
|
42
|
+
"react": "^19.2.4",
|
|
43
|
+
"tsup": "^8.5.1",
|
|
44
|
+
"typescript": "^5.9.3"
|
|
45
|
+
},
|
|
46
|
+
"peerDependencies": {
|
|
47
|
+
"react": ">=18"
|
|
48
|
+
}
|
|
49
|
+
}
|