@smartsoft001/claude-plugins 2.121.0 → 2.123.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/package.json +1 -1
- package/plugins/smart/.claude-plugin/plugin.json +1 -1
- package/plugins/smart/agents/angular-components/AGENT.md +49 -1
- package/plugins/smart/skills/angular-components-avatar/SKILL.md +218 -0
- package/plugins/smart/skills/angular-components-badge/SKILL.md +176 -0
- package/plugins/smart/skills/angular-components-button-group/SKILL.md +158 -0
- package/plugins/smart/skills/angular-components-command-palette/SKILL.md +209 -0
- package/plugins/smart/skills/angular-components-container/SKILL.md +115 -0
- package/plugins/smart/skills/angular-components-divider/SKILL.md +131 -0
- package/plugins/smart/skills/angular-components-drawer/SKILL.md +194 -0
- package/plugins/smart/skills/angular-components-dropdown/SKILL.md +170 -0
- package/plugins/smart/skills/angular-components-list-container/SKILL.md +157 -0
- package/plugins/smart/skills/angular-components-media-object/SKILL.md +139 -0
- package/plugins/smart/skills/angular-components-modal/SKILL.md +175 -0
- package/plugins/smart/skills/angular-components-notification/SKILL.md +219 -0
package/package.json
CHANGED
|
@@ -39,10 +39,21 @@ These render a default standard implementation and accept a custom implementatio
|
|
|
39
39
|
| Component | Skill | Selector | Token |
|
|
40
40
|
| ------------------- | ---------------------------------------- | ----------------------------- | ---------------------------------------------- |
|
|
41
41
|
| Action Panel | `angular-components-action-panel` | `<smart-action-panel>` | `ACTION_PANEL_STANDARD_COMPONENT_TOKEN` |
|
|
42
|
+
| Avatar | `angular-components-avatar` | `<smart-avatar>` | `AVATAR_STANDARD_COMPONENT_TOKEN` |
|
|
43
|
+
| Badge | `angular-components-badge` | `<smart-badge>` | `BADGE_STANDARD_COMPONENT_TOKEN` |
|
|
42
44
|
| Breadcrumbs | `angular-components-breadcrumbs` | `<smart-breadcrumbs>` | `BREADCRUMBS_STANDARD_COMPONENT_TOKEN` |
|
|
45
|
+
| Button Group | `angular-components-button-group` | `<smart-button-group>` | `BUTTON_GROUP_STANDARD_COMPONENT_TOKEN` |
|
|
43
46
|
| Calendar | `angular-components-calendar` | `<smart-calendar>` | `CALENDAR_STANDARD_COMPONENT_TOKEN` |
|
|
44
47
|
| Card Heading | `angular-components-card-heading` | `<smart-card-heading>` | `CARD_HEADING_STANDARD_COMPONENT_TOKEN` |
|
|
48
|
+
| Command Palette | `angular-components-command-palette` | `<smart-command-palette>` | `COMMAND_PALETTE_STANDARD_COMPONENT_TOKEN` |
|
|
49
|
+
| Container | `angular-components-container` | `<smart-container>` | `CONTAINER_STANDARD_COMPONENT_TOKEN` |
|
|
45
50
|
| Description List | `angular-components-description-list` | `<smart-description-list>` | `DESCRIPTION_LIST_STANDARD_COMPONENT_TOKEN` |
|
|
51
|
+
| Divider | `angular-components-divider` | `<smart-divider>` | `DIVIDER_STANDARD_COMPONENT_TOKEN` |
|
|
52
|
+
| Drawer | `angular-components-drawer` | `<smart-drawer>` | `DRAWER_STANDARD_COMPONENT_TOKEN` |
|
|
53
|
+
| Dropdown | `angular-components-dropdown` | `<smart-dropdown>` | `DROPDOWN_STANDARD_COMPONENT_TOKEN` |
|
|
54
|
+
| List Container | `angular-components-list-container` | `<smart-list-container>` | `LIST_CONTAINER_STANDARD_COMPONENT_TOKEN` |
|
|
55
|
+
| Media Object | `angular-components-media-object` | `<smart-media-object>` | `MEDIA_OBJECT_STANDARD_COMPONENT_TOKEN` |
|
|
56
|
+
| Notification | `angular-components-notification` | `<smart-notification>` | `NOTIFICATION_STANDARD_COMPONENT_TOKEN` |
|
|
46
57
|
| Details | `angular-components-details` | `<smart-details>` | `DETAILS_STANDARD_COMPONENT_TOKEN` |
|
|
47
58
|
| Empty State | `angular-components-empty-state` | `<smart-empty-state>` | `EMPTY_STATE_STANDARD_COMPONENT_TOKEN` |
|
|
48
59
|
| Feed | `angular-components-feed` | `<smart-feed>` | `FEED_STANDARD_COMPONENT_TOKEN` |
|
|
@@ -50,6 +61,7 @@ These render a default standard implementation and accept a custom implementatio
|
|
|
50
61
|
| Grid List | `angular-components-grid-list` | `<smart-grid-list>` | `GRID_LIST_STANDARD_COMPONENT_TOKEN` |
|
|
51
62
|
| Info | `angular-components-info` | `<smart-info>` | `INFO_STANDARD_COMPONENT_TOKEN` |
|
|
52
63
|
| List | `angular-components-list` | `<smart-list>` | `LIST_MODE_COMPONENTS_TOKEN` |
|
|
64
|
+
| Modal | `angular-components-modal` | `<smart-modal>` | `MODAL_STANDARD_COMPONENT_TOKEN` |
|
|
53
65
|
| Multi-Column Layout | `angular-components-multi-column-layout` | `<smart-multi-column-layout>` | `MULTI_COLUMN_LAYOUT_STANDARD_COMPONENT_TOKEN` |
|
|
54
66
|
| Navbar | `angular-components-navbar` | `<smart-navbar>` | `NAVBAR_STANDARD_COMPONENT_TOKEN` |
|
|
55
67
|
| Page Heading | `angular-components-page-heading` | `<smart-page-heading>` | `PAGE_HEADING_STANDARD_COMPONENT_TOKEN` |
|
|
@@ -87,7 +99,7 @@ These provide abstract base classes (`@Directive()`) that can be extended to cre
|
|
|
87
99
|
When a developer asks about a component:
|
|
88
100
|
|
|
89
101
|
1. **Wants to use `<smart-date-edit>`, `<smart-date-range>`, `<smart-detail>`, or `<smart-input>`** → delegate to the corresponding skill for usage API
|
|
90
|
-
2. **Wants to use `<smart-action-panel>`, `<smart-breadcrumbs>`, `<smart-calendar>`, `<smart-card-heading>`, `<smart-description-list>`, `<smart-details>`, `<smart-empty-state>`, `<smart-feed>`, `<smart-form>`, `<smart-grid-list>`, `<smart-info>`, `<smart-list>`, `<smart-multi-column-layout>`, `<smart-navbar>`, `<smart-page-heading>`, `<smart-password-strength>`, `<smart-progress-bars>`, `<smart-searchbar>`, `<smart-section-heading>`, `<smart-select-menu>`, `<smart-sidebar-layout>`, `<smart-sidebar-navigation>`, `<smart-sign-in-form>`, `<smart-stacked-layout>`, `<smart-stacked-list>`, `<smart-stats>`, `<smart-table>`, `<smart-tabs>`, `<smart-textarea>`, `<smart-toggle>`, or `<smart-vertical-navigation>`** → delegate to the skill to explain usage, token override pattern, and how to extend the base class with a custom implementation
|
|
102
|
+
2. **Wants to use `<smart-action-panel>`, `<smart-avatar>`, `<smart-badge>`, `<smart-breadcrumbs>`, `<smart-button-group>`, `<smart-calendar>`, `<smart-card-heading>`, `<smart-command-palette>`, `<smart-container>`, `<smart-description-list>`, `<smart-details>`, `<smart-divider>`, `<smart-drawer>`, `<smart-dropdown>`, `<smart-empty-state>`, `<smart-feed>`, `<smart-form>`, `<smart-grid-list>`, `<smart-info>`, `<smart-list>`, `<smart-list-container>`, `<smart-media-object>`, `<smart-modal>`, `<smart-multi-column-layout>`, `<smart-navbar>`, `<smart-notification>`, `<smart-page-heading>`, `<smart-password-strength>`, `<smart-progress-bars>`, `<smart-searchbar>`, `<smart-section-heading>`, `<smart-select-menu>`, `<smart-sidebar-layout>`, `<smart-sidebar-navigation>`, `<smart-sign-in-form>`, `<smart-stacked-layout>`, `<smart-stacked-list>`, `<smart-stats>`, `<smart-table>`, `<smart-tabs>`, `<smart-textarea>`, `<smart-toggle>`, or `<smart-vertical-navigation>`** → delegate to the skill to explain usage, token override pattern, and how to extend the base class with a custom implementation
|
|
91
103
|
3. **Wants to use `<smart-button>`, `<smart-card>`, `<smart-accordion>`, `<smart-page>`, or `<smart-paging>`** → delegate to the skill to explain how to extend the base class and create a custom implementation
|
|
92
104
|
4. **Wants to create a custom component** → delegate to the base-only skill for extension patterns and API
|
|
93
105
|
|
|
@@ -99,11 +111,19 @@ Always delegate to the per-component skill for detailed API, usage examples, and
|
|
|
99
111
|
- **Date Range** → use skill `angular-components-date-range`
|
|
100
112
|
- **Accordion** (base only) → use skill `angular-components-accordion`
|
|
101
113
|
- **Action Panel** (with extension token) → use skill `angular-components-action-panel`
|
|
114
|
+
- **Avatar** (with extension token) → use skill `angular-components-avatar`
|
|
115
|
+
- **Badge** (with extension token) → use skill `angular-components-badge`
|
|
102
116
|
- **Breadcrumbs** (with extension token) → use skill `angular-components-breadcrumbs`
|
|
117
|
+
- **Button Group** (with extension token) → use skill `angular-components-button-group`
|
|
103
118
|
- **Detail** → use skill `angular-components-detail`
|
|
104
119
|
- **Calendar** (with extension token) → use skill `angular-components-calendar`
|
|
105
120
|
- **Card Heading** (with extension token) → use skill `angular-components-card-heading`
|
|
121
|
+
- **Command Palette** (with extension token) → use skill `angular-components-command-palette`
|
|
122
|
+
- **Container** (with extension token) → use skill `angular-components-container`
|
|
106
123
|
- **Description List** (with extension token) → use skill `angular-components-description-list`
|
|
124
|
+
- **Divider** (with extension token) → use skill `angular-components-divider`
|
|
125
|
+
- **Drawer** (with extension token) → use skill `angular-components-drawer`
|
|
126
|
+
- **Dropdown** (with extension token) → use skill `angular-components-dropdown`
|
|
107
127
|
- **Details** (with extension token) → use skill `angular-components-details`
|
|
108
128
|
- **Empty State** (with extension token) → use skill `angular-components-empty-state`
|
|
109
129
|
- **Feed** (with extension token) → use skill `angular-components-feed`
|
|
@@ -112,8 +132,12 @@ Always delegate to the per-component skill for detailed API, usage examples, and
|
|
|
112
132
|
- **Info** (with extension token) → use skill `angular-components-info`
|
|
113
133
|
- **Input** → use skill `angular-components-input`
|
|
114
134
|
- **List** (with extension token map) → use skill `angular-components-list`
|
|
135
|
+
- **List Container** (with extension token) → use skill `angular-components-list-container`
|
|
136
|
+
- **Media Object** (with extension token) → use skill `angular-components-media-object`
|
|
137
|
+
- **Modal** (with extension token) → use skill `angular-components-modal`
|
|
115
138
|
- **Multi-Column Layout** (with extension token) → use skill `angular-components-multi-column-layout`
|
|
116
139
|
- **Navbar** (with extension token) → use skill `angular-components-navbar`
|
|
140
|
+
- **Notification** (with extension token) → use skill `angular-components-notification`
|
|
117
141
|
- **Page Heading** (with extension token) → use skill `angular-components-page-heading`
|
|
118
142
|
- **Password Strength** (with extension token) → use skill `angular-components-password-strength`
|
|
119
143
|
- **Progress Bars** (with extension token) → use skill `angular-components-progress-bars`
|
|
@@ -159,17 +183,33 @@ import {
|
|
|
159
183
|
import {
|
|
160
184
|
ActionPanelBaseComponent,
|
|
161
185
|
ACTION_PANEL_STANDARD_COMPONENT_TOKEN,
|
|
186
|
+
AvatarBaseComponent,
|
|
187
|
+
AVATAR_STANDARD_COMPONENT_TOKEN,
|
|
188
|
+
BadgeBaseComponent,
|
|
189
|
+
BADGE_STANDARD_COMPONENT_TOKEN,
|
|
162
190
|
BreadcrumbsBaseComponent,
|
|
163
191
|
BREADCRUMBS_STANDARD_COMPONENT_TOKEN,
|
|
164
192
|
ButtonBaseComponent,
|
|
193
|
+
ButtonGroupBaseComponent,
|
|
194
|
+
BUTTON_GROUP_STANDARD_COMPONENT_TOKEN,
|
|
165
195
|
CalendarBaseComponent,
|
|
166
196
|
CALENDAR_STANDARD_COMPONENT_TOKEN,
|
|
167
197
|
CardBaseComponent,
|
|
168
198
|
CardHeadingBaseComponent,
|
|
169
199
|
CARD_HEADING_STANDARD_COMPONENT_TOKEN,
|
|
200
|
+
CommandPaletteBaseComponent,
|
|
201
|
+
COMMAND_PALETTE_STANDARD_COMPONENT_TOKEN,
|
|
202
|
+
ContainerBaseComponent,
|
|
203
|
+
CONTAINER_STANDARD_COMPONENT_TOKEN,
|
|
170
204
|
AccordionBaseComponent,
|
|
171
205
|
DescriptionListBaseComponent,
|
|
172
206
|
DESCRIPTION_LIST_STANDARD_COMPONENT_TOKEN,
|
|
207
|
+
DividerBaseComponent,
|
|
208
|
+
DIVIDER_STANDARD_COMPONENT_TOKEN,
|
|
209
|
+
DrawerBaseComponent,
|
|
210
|
+
DRAWER_STANDARD_COMPONENT_TOKEN,
|
|
211
|
+
DropdownBaseComponent,
|
|
212
|
+
DROPDOWN_STANDARD_COMPONENT_TOKEN,
|
|
173
213
|
DetailBaseComponent,
|
|
174
214
|
DetailsBaseComponent,
|
|
175
215
|
DETAILS_STANDARD_COMPONENT_TOKEN,
|
|
@@ -190,10 +230,18 @@ import {
|
|
|
190
230
|
ListMode,
|
|
191
231
|
IListOptions,
|
|
192
232
|
IListProvider,
|
|
233
|
+
ListContainerBaseComponent,
|
|
234
|
+
LIST_CONTAINER_STANDARD_COMPONENT_TOKEN,
|
|
235
|
+
MediaObjectBaseComponent,
|
|
236
|
+
MEDIA_OBJECT_STANDARD_COMPONENT_TOKEN,
|
|
237
|
+
ModalBaseComponent,
|
|
238
|
+
MODAL_STANDARD_COMPONENT_TOKEN,
|
|
193
239
|
MultiColumnLayoutBaseComponent,
|
|
194
240
|
MULTI_COLUMN_LAYOUT_STANDARD_COMPONENT_TOKEN,
|
|
195
241
|
NavbarBaseComponent,
|
|
196
242
|
NAVBAR_STANDARD_COMPONENT_TOKEN,
|
|
243
|
+
NotificationBaseComponent,
|
|
244
|
+
NOTIFICATION_STANDARD_COMPONENT_TOKEN,
|
|
197
245
|
PageBaseComponent,
|
|
198
246
|
PAGE_VARIANT_COMPONENTS_TOKEN,
|
|
199
247
|
SmartPageVariant,
|
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: angular-components-avatar
|
|
3
|
+
description: Avatar component API with InjectionToken pattern for custom implementations.
|
|
4
|
+
user-invocable: false
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Avatar Component
|
|
8
|
+
|
|
9
|
+
The `<smart-avatar>` component renders a user/entity avatar in either single or grouped form. It follows the Base + Standard + Wrapper pattern with an InjectionToken-based extension mechanism. The abstract `AvatarBaseComponent` defines the shared API — `imageUrl`, `initials`, `size`, `shape`, `notificationPosition`, `group` (for stacked/multi-avatar display), optional `IAvatarOptions`, `cssClass` (alias `class`), and a derived `isGroup` computed signal that is `true` when `group()` has at least one item. `AvatarStandardComponent` is a barebones placeholder concrete implementation. `AvatarComponent` is the public wrapper that renders `AvatarStandardComponent` by default and accepts a custom replacement via `AVATAR_STANDARD_COMPONENT_TOKEN`.
|
|
10
|
+
|
|
11
|
+
## When to Use This Skill
|
|
12
|
+
|
|
13
|
+
- Developer wants to use or customize the avatar component
|
|
14
|
+
- Developer asks about `<smart-avatar>`, `AvatarComponent`, `AvatarStandardComponent`, or `AvatarBaseComponent`
|
|
15
|
+
- Developer needs to render a single avatar (image, initials, or placeholder) or a group of stacked avatars
|
|
16
|
+
|
|
17
|
+
## Components
|
|
18
|
+
|
|
19
|
+
### AvatarComponent (`<smart-avatar>`)
|
|
20
|
+
|
|
21
|
+
Main wrapper component. Renders `AvatarStandardComponent` by default. When `AVATAR_STANDARD_COMPONENT_TOKEN` is provided, renders the injected component via `NgComponentOutlet`.
|
|
22
|
+
|
|
23
|
+
### AvatarStandardComponent (`<smart-avatar-standard>`)
|
|
24
|
+
|
|
25
|
+
Barebones placeholder concrete implementation. Renders a host `<span>` carrying the external `cssClass` plus `data-size` and `data-shape` attributes. Inside:
|
|
26
|
+
|
|
27
|
+
- **Group mode** (`isGroup()` is `true`): one `<span class="smart-avatar-group-item">` per `IAvatarItem` (tracked by `id`). Each item renders an `<img>` when the item has `imageUrl`, otherwise a `<span class="smart-avatar-initials">` with the item's `initials`.
|
|
28
|
+
- **Single mode** (`isGroup()` is `false`): an `<img>` when `imageUrl()` is set, otherwise `<span class="smart-avatar-initials">` when `initials()` is set, otherwise a `<span aria-hidden="true" class="smart-avatar-placeholder">·</span>` fallback.
|
|
29
|
+
|
|
30
|
+
It does not include Tailwind UI styling — it exists solely as the default structural placeholder until a custom implementation is registered through the token.
|
|
31
|
+
|
|
32
|
+
### AvatarBaseComponent (abstract)
|
|
33
|
+
|
|
34
|
+
Abstract base directive for extending custom avatar implementations. Static `smartType: DynamicComponentType = 'avatar'`. Exposes:
|
|
35
|
+
|
|
36
|
+
- `imageUrl: InputSignal<string | undefined>`
|
|
37
|
+
- `initials: InputSignal<string | undefined>`
|
|
38
|
+
- `size: InputSignal<SmartAvatarSize>` (default `'md'`)
|
|
39
|
+
- `shape: InputSignal<SmartAvatarShape>` (default `'circle'`)
|
|
40
|
+
- `notificationPosition: InputSignal<'top' | 'bottom' | undefined>`
|
|
41
|
+
- `group: InputSignal<IAvatarItem[] | undefined>`
|
|
42
|
+
- `options: InputSignal<IAvatarOptions | undefined>`
|
|
43
|
+
- `cssClass: InputSignal<string>` (alias `class`, default `''`)
|
|
44
|
+
- `isGroup = computed(() => !!this.group()?.length)`
|
|
45
|
+
|
|
46
|
+
## API
|
|
47
|
+
|
|
48
|
+
### Inputs
|
|
49
|
+
|
|
50
|
+
| Input | Type | Default | Description |
|
|
51
|
+
| ---------------------- | --------------------------------------------- | ---------- | ------------------------------------------------------------------------ |
|
|
52
|
+
| `imageUrl` | `InputSignal<string \| undefined>` | - | URL of the avatar image (single mode) |
|
|
53
|
+
| `initials` | `InputSignal<string \| undefined>` | - | Initials shown when no `imageUrl` is provided (single mode) |
|
|
54
|
+
| `size` | `InputSignal<SmartAvatarSize>` | `'md'` | Avatar size: `'xs' \| 'sm' \| 'md' \| 'lg' \| 'xl'` |
|
|
55
|
+
| `shape` | `InputSignal<SmartAvatarShape>` | `'circle'` | Avatar shape: `'circle' \| 'rounded'` |
|
|
56
|
+
| `notificationPosition` | `InputSignal<'top' \| 'bottom' \| undefined>` | - | Reserved for custom implementations to position a notification dot/badge |
|
|
57
|
+
| `group` | `InputSignal<IAvatarItem[] \| undefined>` | - | When set, renders a group of avatars instead of a single one |
|
|
58
|
+
| `options` | `InputSignal<IAvatarOptions \| undefined>` | - | Optional configuration (placeholder type, stack direction) |
|
|
59
|
+
| `class` | `InputSignal<string>` | `''` | External CSS classes (alias for `cssClass`) |
|
|
60
|
+
|
|
61
|
+
### IAvatarItem
|
|
62
|
+
|
|
63
|
+
```typescript
|
|
64
|
+
interface IAvatarItem {
|
|
65
|
+
id: string;
|
|
66
|
+
imageUrl?: string;
|
|
67
|
+
initials?: string;
|
|
68
|
+
}
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
Each item in a group must have a unique `id` (used as the `@for` track key). When `imageUrl` is present the item renders as an `<img>`; otherwise as `initials`.
|
|
72
|
+
|
|
73
|
+
### IAvatarOptions
|
|
74
|
+
|
|
75
|
+
```typescript
|
|
76
|
+
interface IAvatarOptions {
|
|
77
|
+
placeholderType?: 'icon' | 'initials';
|
|
78
|
+
stackDirection?: 'top-to-bottom' | 'bottom-to-top';
|
|
79
|
+
}
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
The standard placeholder component does not consume these options — they are reserved for custom implementations registered through `AVATAR_STANDARD_COMPONENT_TOKEN` (e.g. to choose between an icon glyph and initials as the empty fallback, or to control z-index ordering when avatars in a group are stacked/overlapped).
|
|
83
|
+
|
|
84
|
+
### Single vs Group Mode
|
|
85
|
+
|
|
86
|
+
The component automatically detects mode from `group()`:
|
|
87
|
+
|
|
88
|
+
- **Group mode**: when `group()` is a non-empty array, `isGroup()` is `true` and the component iterates `group()`. The single-mode `imageUrl`/`initials`/placeholder branch is not rendered.
|
|
89
|
+
- **Single mode**: when `group()` is `undefined` or `[]`, `isGroup()` is `false` and the component renders `imageUrl` (or `initials`, or placeholder) as a single avatar.
|
|
90
|
+
|
|
91
|
+
## AVATAR_STANDARD_COMPONENT_TOKEN
|
|
92
|
+
|
|
93
|
+
```typescript
|
|
94
|
+
import { AVATAR_STANDARD_COMPONENT_TOKEN } from '@smartsoft001/angular';
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
InjectionToken that allows replacing the default `AvatarStandardComponent` with a custom implementation. Provide a `Type<AvatarBaseComponent>` to override.
|
|
98
|
+
|
|
99
|
+
```typescript
|
|
100
|
+
// In your app module or component providers:
|
|
101
|
+
providers: [
|
|
102
|
+
{
|
|
103
|
+
provide: AVATAR_STANDARD_COMPONENT_TOKEN,
|
|
104
|
+
useValue: MyCustomAvatarComponent,
|
|
105
|
+
},
|
|
106
|
+
];
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
## Extending the Base Class
|
|
110
|
+
|
|
111
|
+
```typescript
|
|
112
|
+
import {
|
|
113
|
+
ChangeDetectionStrategy,
|
|
114
|
+
Component,
|
|
115
|
+
computed,
|
|
116
|
+
input,
|
|
117
|
+
ViewEncapsulation,
|
|
118
|
+
} from '@angular/core';
|
|
119
|
+
|
|
120
|
+
import { AvatarBaseComponent } from '@smartsoft001/angular';
|
|
121
|
+
|
|
122
|
+
@Component({
|
|
123
|
+
selector: 'my-custom-avatar',
|
|
124
|
+
template: `
|
|
125
|
+
<span [class]="containerClasses()">
|
|
126
|
+
@if (isGroup()) {
|
|
127
|
+
@for (item of group(); track item.id) {
|
|
128
|
+
<span class="my-avatar-group-item">
|
|
129
|
+
@if (item.imageUrl) {
|
|
130
|
+
<img [src]="item.imageUrl" alt="" />
|
|
131
|
+
} @else {
|
|
132
|
+
<span class="my-avatar-initials">{{ item.initials }}</span>
|
|
133
|
+
}
|
|
134
|
+
</span>
|
|
135
|
+
}
|
|
136
|
+
} @else {
|
|
137
|
+
@if (imageUrl()) {
|
|
138
|
+
<img [src]="imageUrl()" alt="" />
|
|
139
|
+
} @else if (initials()) {
|
|
140
|
+
<span class="my-avatar-initials">{{ initials() }}</span>
|
|
141
|
+
} @else if (options()?.placeholderType === 'icon') {
|
|
142
|
+
<svg class="my-avatar-icon" aria-hidden="true">...</svg>
|
|
143
|
+
} @else {
|
|
144
|
+
<span aria-hidden="true">·</span>
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
@if (notificationPosition()) {
|
|
148
|
+
<span
|
|
149
|
+
class="my-avatar-notification"
|
|
150
|
+
[attr.data-position]="notificationPosition()"
|
|
151
|
+
></span>
|
|
152
|
+
}
|
|
153
|
+
</span>
|
|
154
|
+
`,
|
|
155
|
+
encapsulation: ViewEncapsulation.None,
|
|
156
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
157
|
+
})
|
|
158
|
+
export class MyCustomAvatarComponent extends AvatarBaseComponent {
|
|
159
|
+
// NgComponentOutlet passes 'cssClass' by canonical name, not the 'class' alias.
|
|
160
|
+
override cssClass = input<string>('');
|
|
161
|
+
|
|
162
|
+
containerClasses = computed(() => {
|
|
163
|
+
const classes = [
|
|
164
|
+
'my-avatar',
|
|
165
|
+
`my-avatar--${this.size()}`,
|
|
166
|
+
`my-avatar--${this.shape()}`,
|
|
167
|
+
];
|
|
168
|
+
const extra = this.cssClass();
|
|
169
|
+
if (extra) classes.push(extra);
|
|
170
|
+
return classes.join(' ');
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
When extending the base directly, remember to:
|
|
176
|
+
|
|
177
|
+
- declare `cssClass = input<string>('')` explicitly (no `class` alias) if the component is used via `NgComponentOutlet` through `AVATAR_STANDARD_COMPONENT_TOKEN`, because `NgComponentOutlet` passes inputs by canonical name (not by alias),
|
|
178
|
+
- branch on `isGroup()` to render either the group iteration or the single-avatar fallback chain (`imageUrl` -> `initials` -> placeholder),
|
|
179
|
+
- track `@for` by `item.id` (the `IAvatarItem` contract).
|
|
180
|
+
|
|
181
|
+
## Usage Examples
|
|
182
|
+
|
|
183
|
+
```html
|
|
184
|
+
<!-- Single avatar with image -->
|
|
185
|
+
<smart-avatar [imageUrl]="user.photo" />
|
|
186
|
+
|
|
187
|
+
<!-- Single avatar with initials fallback -->
|
|
188
|
+
<smart-avatar [initials]="'AB'" size="lg" shape="rounded" />
|
|
189
|
+
|
|
190
|
+
<!-- Avatar group -->
|
|
191
|
+
<smart-avatar
|
|
192
|
+
[group]="[
|
|
193
|
+
{ id: '1', imageUrl: 'a.png' },
|
|
194
|
+
{ id: '2', initials: 'CD' },
|
|
195
|
+
{ id: '3', initials: 'EF' }
|
|
196
|
+
]"
|
|
197
|
+
/>
|
|
198
|
+
|
|
199
|
+
<!-- With notification indicator (consumed by custom implementations) -->
|
|
200
|
+
<smart-avatar [imageUrl]="user.photo" notificationPosition="top" />
|
|
201
|
+
|
|
202
|
+
<!-- With options -->
|
|
203
|
+
<smart-avatar
|
|
204
|
+
[imageUrl]="user.photo"
|
|
205
|
+
[options]="{ placeholderType: 'initials', stackDirection: 'top-to-bottom' }"
|
|
206
|
+
/>
|
|
207
|
+
|
|
208
|
+
<!-- With external class -->
|
|
209
|
+
<smart-avatar [imageUrl]="user.photo" class="smart:m-2" />
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
## File Locations
|
|
213
|
+
|
|
214
|
+
- Wrapper: `packages/shared/angular/src/lib/components/avatar/avatar.component.ts`
|
|
215
|
+
- Standard: `packages/shared/angular/src/lib/components/avatar/standard/standard.component.ts`
|
|
216
|
+
- Base class: `packages/shared/angular/src/lib/components/avatar/base/base.component.ts`
|
|
217
|
+
- Token: `packages/shared/angular/src/lib/shared.inectors.ts` (`AVATAR_STANDARD_COMPONENT_TOKEN`)
|
|
218
|
+
- Interfaces: `packages/shared/angular/src/lib/models/interfaces.ts` (`IAvatarItem`, `IAvatarOptions`, `SmartAvatarSize`, `SmartAvatarShape`)
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: angular-components-badge
|
|
3
|
+
description: Badge component API with InjectionToken pattern for custom implementations.
|
|
4
|
+
user-invocable: false
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Badge Component
|
|
8
|
+
|
|
9
|
+
The `<smart-badge>` component renders a small inline status / label indicator. It follows the Base + Standard + Wrapper pattern with an InjectionToken-based extension mechanism. The abstract `BadgeBaseComponent` defines the shared API — `text` (required), `color`, `size`, optional `IBadgeOptions`, `cssClass` (alias `class`), a `removed` output, and a `remove()` method that emits `removed`. `BadgeStandardComponent` is a barebones placeholder concrete implementation. `BadgeComponent` is the public wrapper that renders `BadgeStandardComponent` by default and accepts a custom replacement via `BADGE_STANDARD_COMPONENT_TOKEN`.
|
|
10
|
+
|
|
11
|
+
## When to Use This Skill
|
|
12
|
+
|
|
13
|
+
- Developer wants to use or customize the badge component
|
|
14
|
+
- Developer asks about `<smart-badge>`, `BadgeComponent`, `BadgeStandardComponent`, or `BadgeBaseComponent`
|
|
15
|
+
|
|
16
|
+
## Components
|
|
17
|
+
|
|
18
|
+
### BadgeComponent (`<smart-badge>`)
|
|
19
|
+
|
|
20
|
+
Main wrapper component. Renders `BadgeStandardComponent` by default. When `BADGE_STANDARD_COMPONENT_TOKEN` is provided, renders the injected component via `NgComponentOutlet`. Re-emits `removed` from the default standard child.
|
|
21
|
+
|
|
22
|
+
### BadgeStandardComponent (`<smart-badge-standard>`)
|
|
23
|
+
|
|
24
|
+
Barebones placeholder concrete implementation. Renders a `<span>` host with `data-color` and `data-size` attributes, an optional leading dot when `options.withDot` is true, the badge `text`, and an optional remove button when `options.withRemove` is true that emits the `removed` output on click. It does not include Tailwind UI styling — it exists solely as the default structural placeholder until a custom implementation is registered through the token.
|
|
25
|
+
|
|
26
|
+
### BadgeBaseComponent (abstract)
|
|
27
|
+
|
|
28
|
+
Abstract base directive for extending custom badge implementations. Exposes `text` as a required `InputSignal<string>`, `color` as an `InputSignal<SmartBadgeColor>` (default `'gray'`), `size` as an `InputSignal<'sm' | 'md'>` (default `'md'`), `options` as an `InputSignal<IBadgeOptions | undefined>`, `cssClass` as an `InputSignal<string>` (with alias `class`), `removed` as an `OutputEmitterRef<void>`, and a `remove()` method that emits the `removed` output.
|
|
29
|
+
|
|
30
|
+
## API
|
|
31
|
+
|
|
32
|
+
### Inputs
|
|
33
|
+
|
|
34
|
+
| Input | Type | Default | Description |
|
|
35
|
+
| --------- | ----------------------------------------- | -------- | ------------------------------------------- |
|
|
36
|
+
| `text` | `InputSignal<string>` (required) | - | Badge label text |
|
|
37
|
+
| `color` | `InputSignal<SmartBadgeColor>` | `'gray'` | Semantic color of the badge |
|
|
38
|
+
| `size` | `InputSignal<'sm' \| 'md'>` | `'md'` | Visual size variant |
|
|
39
|
+
| `options` | `InputSignal<IBadgeOptions \| undefined>` | - | Optional configuration (variant, dot, etc.) |
|
|
40
|
+
| `class` | `InputSignal<string>` | `''` | External CSS classes (alias for `cssClass`) |
|
|
41
|
+
|
|
42
|
+
### Outputs
|
|
43
|
+
|
|
44
|
+
| Output | Type | Description |
|
|
45
|
+
| --------- | ------------------------ | ---------------------------------------------------------------- |
|
|
46
|
+
| `removed` | `OutputEmitterRef<void>` | Emits when the user clicks the remove button (with `withRemove`) |
|
|
47
|
+
|
|
48
|
+
### SmartBadgeColor
|
|
49
|
+
|
|
50
|
+
```typescript
|
|
51
|
+
type SmartBadgeColor =
|
|
52
|
+
| 'gray'
|
|
53
|
+
| 'red'
|
|
54
|
+
| 'yellow'
|
|
55
|
+
| 'green'
|
|
56
|
+
| 'blue'
|
|
57
|
+
| 'indigo'
|
|
58
|
+
| 'purple'
|
|
59
|
+
| 'pink';
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
### IBadgeOptions
|
|
63
|
+
|
|
64
|
+
```typescript
|
|
65
|
+
interface IBadgeOptions {
|
|
66
|
+
variant?: 'border' | 'flat';
|
|
67
|
+
pill?: boolean;
|
|
68
|
+
withDot?: boolean;
|
|
69
|
+
withRemove?: boolean;
|
|
70
|
+
}
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
The standard component only consumes `withDot` (renders a leading bullet) and `withRemove` (renders a remove button that emits `removed`). The remaining properties — `variant` and `pill` — are reserved for custom implementations registered through `BADGE_STANDARD_COMPONENT_TOKEN` and are ignored by `BadgeStandardComponent`.
|
|
74
|
+
|
|
75
|
+
## BADGE_STANDARD_COMPONENT_TOKEN
|
|
76
|
+
|
|
77
|
+
```typescript
|
|
78
|
+
import { BADGE_STANDARD_COMPONENT_TOKEN } from '@smartsoft001/angular';
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
InjectionToken that allows replacing the default `BadgeStandardComponent` with a custom implementation. Provide a `Type<BadgeBaseComponent>` to override.
|
|
82
|
+
|
|
83
|
+
```typescript
|
|
84
|
+
// In your app module or component providers:
|
|
85
|
+
providers: [
|
|
86
|
+
{
|
|
87
|
+
provide: BADGE_STANDARD_COMPONENT_TOKEN,
|
|
88
|
+
useValue: MyCustomBadgeComponent,
|
|
89
|
+
},
|
|
90
|
+
];
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
## Extending the Base Class
|
|
94
|
+
|
|
95
|
+
```typescript
|
|
96
|
+
import {
|
|
97
|
+
ChangeDetectionStrategy,
|
|
98
|
+
Component,
|
|
99
|
+
computed,
|
|
100
|
+
input,
|
|
101
|
+
ViewEncapsulation,
|
|
102
|
+
} from '@angular/core';
|
|
103
|
+
|
|
104
|
+
import { BadgeBaseComponent } from '@smartsoft001/angular';
|
|
105
|
+
|
|
106
|
+
@Component({
|
|
107
|
+
selector: 'my-custom-badge',
|
|
108
|
+
template: `
|
|
109
|
+
<span [class]="containerClasses()" [attr.data-color]="color()">
|
|
110
|
+
@if (options()?.withDot) {
|
|
111
|
+
<span aria-hidden="true" class="my-badge-dot">•</span>
|
|
112
|
+
}
|
|
113
|
+
<span class="my-badge-text">{{ text() }}</span>
|
|
114
|
+
@if (options()?.withRemove) {
|
|
115
|
+
<button type="button" aria-label="Remove" (click)="remove()">
|
|
116
|
+
×
|
|
117
|
+
</button>
|
|
118
|
+
}
|
|
119
|
+
</span>
|
|
120
|
+
`,
|
|
121
|
+
encapsulation: ViewEncapsulation.None,
|
|
122
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
123
|
+
})
|
|
124
|
+
export class MyCustomBadgeComponent extends BadgeBaseComponent {
|
|
125
|
+
// NgComponentOutlet passes 'cssClass' by canonical name, not the 'class' alias.
|
|
126
|
+
override cssClass = input<string>('');
|
|
127
|
+
|
|
128
|
+
containerClasses = computed(() => {
|
|
129
|
+
const classes = ['my-badge-container'];
|
|
130
|
+
if (this.options()?.pill) classes.push('my-badge-pill');
|
|
131
|
+
if (this.options()?.variant === 'border') classes.push('my-badge-border');
|
|
132
|
+
const extra = this.cssClass();
|
|
133
|
+
if (extra) classes.push(extra);
|
|
134
|
+
return classes.join(' ');
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
When extending the base directly, remember to:
|
|
140
|
+
|
|
141
|
+
- declare `cssClass = input<string>('')` explicitly (no `class` alias) if the component is used via `NgComponentOutlet` through `BADGE_STANDARD_COMPONENT_TOKEN`, because `NgComponentOutlet` passes inputs by canonical name (not by alias),
|
|
142
|
+
- call `this.remove()` from your remove button click handler so the `removed` output is emitted consistently.
|
|
143
|
+
|
|
144
|
+
## Usage Examples
|
|
145
|
+
|
|
146
|
+
```html
|
|
147
|
+
<!-- Basic -->
|
|
148
|
+
<smart-badge text="New" />
|
|
149
|
+
|
|
150
|
+
<!-- Colored -->
|
|
151
|
+
<smart-badge text="Active" color="green" />
|
|
152
|
+
|
|
153
|
+
<!-- Small size -->
|
|
154
|
+
<smart-badge text="Beta" size="sm" />
|
|
155
|
+
|
|
156
|
+
<!-- With leading dot -->
|
|
157
|
+
<smart-badge text="Online" color="green" [options]="{ withDot: true }" />
|
|
158
|
+
|
|
159
|
+
<!-- Removable (handle removed output) -->
|
|
160
|
+
<smart-badge
|
|
161
|
+
text="Tag"
|
|
162
|
+
[options]="{ withRemove: true }"
|
|
163
|
+
(removed)="onTagRemoved()"
|
|
164
|
+
/>
|
|
165
|
+
|
|
166
|
+
<!-- With external class -->
|
|
167
|
+
<smart-badge text="Note" class="smart:my-2" />
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
## File Locations
|
|
171
|
+
|
|
172
|
+
- Wrapper: `packages/shared/angular/src/lib/components/badge/badge.component.ts`
|
|
173
|
+
- Standard: `packages/shared/angular/src/lib/components/badge/standard/standard.component.ts`
|
|
174
|
+
- Base class: `packages/shared/angular/src/lib/components/badge/base/base.component.ts`
|
|
175
|
+
- Token: `packages/shared/angular/src/lib/shared.inectors.ts` (`BADGE_STANDARD_COMPONENT_TOKEN`)
|
|
176
|
+
- Interface: `packages/shared/angular/src/lib/models/interfaces.ts` (`IBadgeOptions`, `SmartBadgeColor`)
|