@libs-ui/components-avatar 0.2.355-0 → 0.2.355-10

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.
Files changed (2) hide show
  1. package/package.json +3 -3
  2. package/README.md +0 -264
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "@libs-ui/components-avatar",
3
- "version": "0.2.355-0",
3
+ "version": "0.2.355-10",
4
4
  "peerDependencies": {
5
5
  "@angular/core": ">=18.0.0",
6
- "@libs-ui/interfaces-types": "0.2.355-0",
7
- "@libs-ui/utils": "0.2.355-0"
6
+ "@libs-ui/interfaces-types": "0.2.355-10",
7
+ "@libs-ui/utils": "0.2.355-10"
8
8
  },
9
9
  "sideEffects": false,
10
10
  "module": "fesm2022/libs-ui-components-avatar.mjs",
package/README.md DELETED
@@ -1,264 +0,0 @@
1
- # Avatar
2
-
3
- ## Giới thiệu
4
-
5
- `avatar` là một component Avatar linh hoạt dùng cho ứng dụng Angular. Component này cho phép hiển thị avatar người dùng với nhiều tùy chọn khác nhau như hình ảnh, chữ cái đầu, màu sắc tự động, và hỗ trợ fallback khi ảnh bị lỗi.
6
-
7
- ## Tính năng
8
-
9
- - Hiển thị hình ảnh avatar người dùng
10
- - Tự động hiển thị chữ cái đầu khi không có ảnh
11
- - Tạo màu nền tự động dựa trên ID
12
- - Hỗ trợ nhiều kích thước khác nhau (16px, 24px, 32px, 40px, 48px, 64px)
13
- - Hỗ trợ hình dạng khác nhau (tròn, vuông)
14
- - Xử lý lỗi hình ảnh với nhiều tùy chọn fallback
15
- - Hỗ trợ tùy chỉnh class CSS
16
-
17
- ## Cài đặt
18
-
19
- ### Yêu cầu
20
-
21
- - Angular 18.0.0 trở lên
22
- - Tailwind CSS 3.3.0 trở lên
23
-
24
- ### Hướng dẫn
25
-
26
- Để cài đặt component `avatar`, sử dụng npm hoặc yarn:
27
-
28
- ```bash
29
- npm install @libs-ui/components-avatar
30
- ```
31
-
32
- hoặc
33
-
34
- ```bash
35
- yarn add @libs-ui/components-avatar
36
- ```
37
-
38
- ## Sử dụng
39
-
40
- ### Import component
41
-
42
- ```typescript
43
- // example.component.ts
44
- import { Component } from '@angular/core';
45
- import { LibsUiComponentsAvatarComponent } from '@libs-ui/components-avatar';
46
-
47
- @Component({
48
- selector: 'app-example',
49
- standalone: true,
50
- imports: [LibsUiComponentsAvatarComponent],
51
- template: `
52
- <libs_ui-components-avatar
53
- [linkAvatar]="'https://example.com/avatar.jpg'"
54
- [textAvatar]="'Nguyễn Văn A'"
55
- [idGenColor]="'user-123'"
56
- [size]="40"></libs_ui-components-avatar>
57
- `,
58
- })
59
- export class ExampleComponent {
60
- // Component logic
61
- }
62
- ```
63
-
64
- #### Cách 2: Sử dụng file HTML riêng biệt
65
-
66
- ```typescript
67
- // example.component.ts
68
- import { Component } from '@angular/core';
69
- import { LibsUiComponentsAvatarComponent } from '@libs-ui/components-avatar';
70
-
71
- @Component({
72
- selector: 'app-example',
73
- standalone: true,
74
- imports: [LibsUiComponentsAvatarComponent],
75
- templateUrl: './example.component.html',
76
- })
77
- export class ExampleComponent {
78
- // Component logic
79
- }
80
- ```
81
-
82
- ```html
83
- <!-- example.component.html -->
84
- <libs_ui-components-avatar
85
- [linkAvatar]="'https://example.com/avatar.jpg'"
86
- [linkAvatarError]="'https://example.com/default-avatar.jpg'"
87
- [textAvatar]="'Nguyễn Văn A'"
88
- [idGenColor]="'user-123'"
89
- [size]="40"
90
- [typeShape]="'circle'"></libs_ui-components-avatar>
91
- ```
92
-
93
- ## Công nghệ sử dụng
94
-
95
- - **Angular 18**: Sử dụng các tính năng mới nhất của Angular 18 như control flow (@if, @for), standalone components, và signals
96
- - **Tailwind CSS**: Component được xây dựng với Tailwind CSS 3.3+ để quản lý style
97
-
98
- ## API Reference
99
-
100
- ### Inputs
101
-
102
- | Tên | Kiểu dữ liệu | Mặc định | Mô tả |
103
- | --------------------- | ---------------------------------- | ------------ | ---------------------------------------------------------------------- |
104
- | linkAvatar | `string` | - | Đường dẫn của hình ảnh avatar |
105
- | linkAvatarError | `string` | - | Đường dẫn của hình ảnh thay thế khi avatar chính bị lỗi |
106
- | textAvatar | `string` | - | Văn bản hiển thị khi không có hình ảnh (thường là chữ cái đầu của tên) |
107
- | idGenColor | `string` | - | ID dùng để tạo màu nền tự động khi sử dụng văn bản |
108
- | size | `16 \| 24 \| 32 \| 40 \| 48 \| 64` | `32` | Kích thước của avatar (tính bằng pixel) |
109
- | typeShape | `'circle' \| 'rectangle'` | `'circle'` | Hình dạng của avatar (tròn hoặc vuông) |
110
- | classInclude | `string` | `'mr-[8px]'` | CSS class bổ sung cho container chính |
111
- | classImageInclude | `string` | `''` | CSS class bổ sung cho thẻ img |
112
- | getLastTextAfterSpace | `boolean` | `false` | Nếu true, chỉ lấy chữ cái đầu tiên của từ cuối cùng trong textAvatar |
113
- | clickPreviewImage | `boolean` | `false` | Cho phép click vào avatar để mở xem ảnh preview |
114
-
115
- ### Outputs
116
-
117
- | Tên | Kiểu dữ liệu | Mô tả |
118
- | -------------- | ------------ | ------------------------------------------------------------------------ |
119
- | outAvatarError | `void` | Sự kiện được kích hoạt khi linkAvatar bị lỗi và không có linkAvatarError |
120
-
121
- ### Interfaces
122
-
123
- #### IAvatarConfig
124
-
125
- ```typescript
126
- export interface IAvatarConfig {
127
- classImageInclude?: string;
128
- classInclude?: string;
129
- size?: TYPE_SIZE_AVATAR_CONFIG;
130
- linkAvatar?: string;
131
- linkAvatarError?: string;
132
- idGenColor?: string;
133
- textAvatar?: string;
134
- typeShape?: TYPE_SHAPE_AVATAR;
135
- getLastTextAfterSpace?: boolean;
136
- }
137
-
138
- export type TYPE_SIZE_AVATAR_CONFIG = 16 | 24 | 32 | 40 | 48 | 64;
139
- export type TYPE_SHAPE_AVATAR = 'circle' | 'rectangle';
140
- ```
141
-
142
- ## Ví dụ
143
-
144
- ### Avatar với ảnh và fallback
145
-
146
- **TypeScript (user-avatar.component.ts):**
147
-
148
- ```typescript
149
- import { Component } from '@angular/core';
150
- import { LibsUiComponentsAvatarComponent } from '@libs-ui/components-avatar';
151
-
152
- @Component({
153
- selector: 'app-user-avatar',
154
- standalone: true,
155
- imports: [LibsUiComponentsAvatarComponent],
156
- templateUrl: './user-avatar.component.html',
157
- })
158
- export class UserAvatarComponent {
159
- user = {
160
- id: 'user-123',
161
- name: 'Nguyễn Văn A',
162
- avatar: 'https://example.com/avatar.jpg',
163
- };
164
-
165
- handleAvatarError() {
166
- console.log('Không thể tải được hình ảnh avatar');
167
- }
168
- }
169
- ```
170
-
171
- **HTML (user-avatar.component.html):**
172
-
173
- ```html
174
- <libs_ui-components-avatar
175
- [linkAvatar]="user.avatar"
176
- [textAvatar]="user.name"
177
- [idGenColor]="user.id"
178
- [size]="40"
179
- (outAvatarError)="handleAvatarError()"></libs_ui-components-avatar>
180
- ```
181
-
182
- ### Nhóm Avatars với kích thước và hình dạng khác nhau
183
-
184
- **TypeScript (avatar-group.component.ts):**
185
-
186
- ```typescript
187
- import { Component } from '@angular/core';
188
- import { LibsUiComponentsAvatarComponent } from '@libs-ui/components-avatar';
189
-
190
- @Component({
191
- selector: 'app-avatar-group',
192
- standalone: true,
193
- imports: [LibsUiComponentsAvatarComponent],
194
- templateUrl: './avatar-group.component.html',
195
- })
196
- export class AvatarGroupComponent {
197
- users = [
198
- {
199
- id: 'user-1',
200
- name: 'Nguyễn Văn A',
201
- avatar: 'https://example.com/avatar1.jpg',
202
- size: 64,
203
- },
204
- {
205
- id: 'user-2',
206
- name: 'Trần Thị B',
207
- avatar: 'https://example.com/avatar2.jpg',
208
- size: 48,
209
- },
210
- {
211
- id: 'user-3',
212
- name: 'Lê Văn C',
213
- avatar: 'https://example.com/avatar3.jpg',
214
- size: 32,
215
- },
216
- {
217
- id: 'user-4',
218
- name: 'Phạm Thị D',
219
- avatar: null,
220
- size: 24,
221
- },
222
- ];
223
- }
224
- ```
225
-
226
- **HTML (avatar-group.component.html):**
227
-
228
- ```html
229
- <div class="flex items-center space-x-2">
230
- @for (user of users; track user.id) {
231
- <libs_ui-components-avatar
232
- [linkAvatar]="user.avatar"
233
- [textAvatar]="user.name"
234
- [idGenColor]="user.id"
235
- [size]="user.size"
236
- [typeShape]="user.id === 'user-4' ? 'rectangle' : 'circle'"></libs_ui-components-avatar>
237
- }
238
- </div>
239
- ```
240
-
241
- ## Demo
242
-
243
- Để xem các ví dụ tương tác về component Avatar, bạn có thể sử dụng `LibsUiComponentsAvatarDemoComponent` trong ứng dụng của mình:
244
-
245
- ```typescript
246
- import { Component } from '@angular/core';
247
- import { LibsUiComponentsAvatarDemoComponent } from '@libs-ui/components-avatar';
248
-
249
- @Component({
250
- selector: 'app-avatar-demo',
251
- standalone: true,
252
- imports: [LibsUiComponentsAvatarDemoComponent],
253
- template: `
254
- <lib-avatar-demo></lib-avatar-demo>
255
- `,
256
- })
257
- export class AvatarDemoComponent {}
258
- ```
259
-
260
- Hoặc thêm trực tiếp trong template HTML:
261
-
262
- ```html
263
- <lib-avatar-demo></lib-avatar-demo>
264
- ```