Skip to content

Commit 3b8edda

Browse files
authored
Merge pull request #6547 from IgniteUI/pbozhinov/avatar-docs-annotations
Updates docs for the igxAvatarComponent API
2 parents 1323048 + 4b3d1dc commit 3b8edda

File tree

2 files changed

+64
-87
lines changed

2 files changed

+64
-87
lines changed

projects/igniteui-angular/src/lib/avatar/avatar.component.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ describe('Avatar', () => {
8888
expect(instance.size).toEqual(IgxAvatarSize.LARGE);
8989
expect(hostEl.classList).not.toContain(classes.large);
9090

91-
instance.size = 'nonsense';
91+
instance.size = 'nonsense' as any;
9292
fixture.detectChanges();
9393
expect(instance.size).toEqual(IgxAvatarSize.SMALL);
9494
expect(hostEl.classList).toContain(classes.small);

projects/igniteui-angular/src/lib/avatar/avatar.component.ts

Lines changed: 63 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,22 @@ export enum IgxAvatarType {
2828
}
2929

3030
/**
31-
* **Ignite UI for Angular Avatar** -
32-
* [Documentation](https://www.infragistics.com/products/ignite-ui-angular/angular/components/avatar.html)
31+
* Avatar provides a way to display an image, icon or initials to the user.
32+
*
33+
* @igxModule IgxAvatarModule
34+
*
35+
* @igxTheme igx-avatar-theme, igx-icon-theme
36+
*
37+
* @igxKeywords avatar, profile, picture, initials
38+
*
39+
* @igxGroup Layouts
40+
*
41+
* @remarks
3342
*
3443
* The Ignite UI Avatar provides an easy way to add an avatar icon to your application. This icon can be an
35-
* image, someone's initials or a material icon from the google material icon set.
44+
* image, someone's initials or a material icon from the Google Material icon set.
3645
*
37-
* Example:
46+
* @example
3847
* ```html
3948
* <igx-avatar initials="MS" roundShape="true" size="large">
4049
* </igx-avatar>
@@ -47,43 +56,36 @@ export enum IgxAvatarType {
4756
export class IgxAvatarComponent implements OnInit, AfterViewInit {
4857

4958
/**
50-
* This is a reference to the avatar `image` element in the DOM.
59+
* This is a reference to the avatar image element in the DOM.
5160
*
61+
* @example
5262
* ```typescript
53-
* let image = this.avatar.image;
63+
* let image = this.avatar.image;
5464
* ```
55-
* @memberof IgxAvatarComponent
5665
*/
5766
@ViewChild('image')
5867
public image: ElementRef;
5968

60-
/**
61-
*@hidden
62-
*/
69+
/** @hidden @internal */
6370
@ViewChild('defaultTemplate', { read: TemplateRef, static: true })
6471
protected defaultTemplate: TemplateRef<any>;
6572

66-
/**
67-
*@hidden
68-
*/
73+
/** @hidden @internal */
6974
@ViewChild('imageTemplate', { read: TemplateRef, static: true })
7075
protected imageTemplate: TemplateRef<any>;
7176

72-
/**
73-
*@hidden
74-
*/
77+
/** @hidden @internal */
7578
@ViewChild('initialsTemplate', { read: TemplateRef, static: true })
7679
protected initialsTemplate: TemplateRef<any>;
7780

78-
/**
79-
*@hidden
80-
*/
81+
/** @hidden @internal */
8182
@ViewChild('iconTemplate', { read: TemplateRef, static: true })
8283
protected iconTemplate: TemplateRef<any>;
8384

8485
/**
85-
* Returns the `aria-label` of the avatar.
86+
* Returns the `aria-label` attribute of the avatar.
8687
*
88+
* @example
8789
* ```typescript
8890
* let ariaLabel = this.avatar.ariaLabel;
8991
* ```
@@ -95,23 +97,19 @@ export class IgxAvatarComponent implements OnInit, AfterViewInit {
9597
/**
9698
* Returns the `role` attribute of the avatar.
9799
*
100+
* @example
98101
* ```typescript
99102
* let avatarRole = this.avatar.role;
100103
* ```
101-
*
102-
* @memberof IgxAvatarComponent
103104
*/
104105
@HostBinding('attr.role')
105106
public role = 'img';
106107

107108
/**
108-
* Returns the class of the avatar.
109+
* Host `class.igx-avatar` binding.
109110
*
110-
* ```typescript
111-
* let avatarCLass = this.avatar.cssClass;
112-
* ```
113-
*
114-
* @memberof IgxAvatarComponent
111+
* @hidden
112+
* @internal
115113
*/
116114
@HostBinding('class.igx-avatar')
117115
public cssClass = 'igx-avatar';
@@ -124,56 +122,47 @@ export class IgxAvatarComponent implements OnInit, AfterViewInit {
124122
* - `"image type avatar"`.
125123
* - `"custom type avatar"`.
126124
*
125+
* @example
127126
* ```typescript
128127
* let avatarDescription = this.avatar.roleDescription;
129128
* ```
130-
*
131-
* @memberof IgxAvatarComponent
132129
*/
133130
@HostBinding('attr.aria-roledescription')
134131
public roleDescription: string;
135132

136-
/**
137-
* @hidden
138-
*/
139-
private _size: string | IgxAvatarSize = IgxAvatarSize.SMALL;
140-
141133
/**
142134
* Sets the `id` of the avatar. If not set, the first avatar component will have `id` = `"igx-avatar-0"`.
143135
*
136+
* @example
144137
* ```html
145138
* <igx-avatar id="my-first-avatar"></igx-avatar>
146139
* ```
147-
*
148-
* @memberof IgxAvatarComponent
149140
*/
150141
@HostBinding('attr.id')
151142
@Input()
152143
public id = `igx-avatar-${NEXT_ID++}`;
153144

154145
/**
155-
* Sets a round shape to the avatar if `roundShape` is `"true"`.
146+
* Sets a round shape to the avatar, if `roundShape` is set to `true`.
156147
* By default the shape of the avatar is a square.
157148
*
149+
* @example
158150
* ```html
159-
* <igx-avatar roundShape = "true" ></igx-avatar>
151+
* <igx-avatar roundShape="true" ></igx-avatar>
160152
* ```
161-
*
162-
* @memberof IgxAvatarComponent
163153
*/
164154

165155
@HostBinding('class.igx-avatar--rounded')
166156
@Input()
167157
public roundShape = false;
168158

169159
/**
170-
* Sets the avatar's `initials`/`icon` color.
160+
* Sets the color of the avatar's initials or icon.
171161
*
162+
* @example
172163
*```html
173164
*<igx-avatar color="blue"></igx-avatar>
174165
*```
175-
*
176-
* @memberof IgxAvatarComponent
177166
*/
178167

179168
@HostBinding('style.color')
@@ -183,76 +172,77 @@ export class IgxAvatarComponent implements OnInit, AfterViewInit {
183172
/**
184173
* Sets the background color of the avatar.
185174
*
175+
* @example
186176
* ```html
187177
* <igx-avatar bgColor="yellow"></igx-avatar>
188178
* ```
189-
*
190-
* @memberof IgxAvatarComponent
179+
* @igxFriendlyName Background color
191180
*/
192181

193182
@HostBinding('style.background')
194183
@Input()
195184
public bgColor: string;
196185

197186
/**
198-
* Sets `initials` to the avatar.
187+
* Sets initials to the avatar.
199188
*
189+
* @example
200190
* ```html
201191
* <igx-avatar initials="MN"></igx-avatar>
202192
* ```
203-
*
204-
* @memberof IgxAvatarComponent
205193
*/
206194
@Input()
207195
public initials: string;
208196

209197
/**
210-
* Sets an `icon` to the avatar. All icons from the material icon set are supported.
198+
* Sets an icon to the avatar. All icons from the material icon set are supported.
211199
*
200+
* @example
212201
* ```html
213202
* <igx-avatar icon="phone"></igx-avatar>
214203
* ```
215-
*
216-
* @memberof IgxAvatarComponent
217204
*/
218205
@Input()
219206
public icon: string;
220207

221208
/**
222-
* Sets the `image` source of the avatar.
209+
* Sets the image source of the avatar.
223210
*
211+
* @example
224212
* ```html
225213
* <igx-avatar src="images/picture.jpg"></igx-avatar>
226214
* ```
227-
*
228-
* @memberof IgxAvatarComponent
215+
* @igxFriendlyName Image URL
229216
*/
230217
@Input()
231218
public src: string;
232219

233220
/**
234-
* Returns the `size` of the avatar.
221+
* @hidden
222+
* @internal
223+
*/
224+
private _size: string | IgxAvatarSize = IgxAvatarSize.SMALL;
225+
/**
226+
* Returns the size of the avatar.
235227
*
228+
* @example
236229
* ```typescript
237-
*let avatarSize = this.avatar.size;
230+
* let avatarSize = this.avatar.size;
238231
* ```
239-
*
240-
* @memberof IgxAvatarComponent
241232
*/
242233
@Input()
243234
public get size(): string | IgxAvatarSize {
244235
return this._size;
245236
}
246237

247238
/**
248-
* Sets the `size` of the avatar.
249-
* By default the `size` is `"small"`. It can be set to `"medium"` or `"large"`.
239+
* Sets the size of the avatar.
240+
* By default, the size is `"small"`. It can be set to `"medium"` or `"large"`.
250241
*
251-
* ```
242+
* @example
243+
* ```html
252244
* <igx-avatar size="large"></igx-avatar>
253245
* ```
254-
*
255-
* @memberof IgxAvatarComponent
256246
*/
257247
public set size(value: string | IgxAvatarSize) {
258248
switch (value) {
@@ -269,11 +259,10 @@ export class IgxAvatarComponent implements OnInit, AfterViewInit {
269259
/**
270260
* Returns the type of the avatar.
271261
*
262+
* @example
272263
* ```typescript
273264
* let avatarType = this.avatar.type;
274265
* ```
275-
*
276-
* @memberof IgxAvatarComponent
277266
*/
278267
get type(): IgxAvatarType {
279268
if (this.src) {
@@ -294,11 +283,8 @@ export class IgxAvatarComponent implements OnInit, AfterViewInit {
294283
/**
295284
* Returns the template of the avatar.
296285
*
297-
* ```typescript
298-
* let template = this.avatar.template;
299-
* ```
300-
*
301-
* @memberof IgxAvatarComponent
286+
* @hidden
287+
* @internal
302288
*/
303289
get template(): TemplateRef<any> {
304290
switch (this.type) {
@@ -315,16 +301,12 @@ export class IgxAvatarComponent implements OnInit, AfterViewInit {
315301

316302
constructor(public elementRef: ElementRef) { }
317303

318-
/**
319-
* @hidden
320-
*/
304+
/** @hidden @internal */
321305
public ngOnInit() {
322306
this.roleDescription = this.getRole();
323307
}
324308

325-
/**
326-
*@hidden
327-
*/
309+
/** @hidden @internal */
328310
public ngAfterViewInit() {
329311
if (this.type !== IgxAvatarType.CUSTOM) {
330312
this.elementRef.nativeElement.classList.add(`igx-avatar--${this.type}`);
@@ -333,9 +315,7 @@ export class IgxAvatarComponent implements OnInit, AfterViewInit {
333315
this.elementRef.nativeElement.classList.add(`igx-avatar--${this._size}`);
334316
}
335317

336-
/**
337-
* @hidden
338-
*/
318+
/** @hidden @internal */
339319
private getRole(): string {
340320
switch (this.type) {
341321
case IgxAvatarType.IMAGE:
@@ -350,13 +330,10 @@ export class IgxAvatarComponent implements OnInit, AfterViewInit {
350330
}
351331

352332
/**
353-
* Returns the url of the `image`.
333+
* Returns the css url of the image.
354334
*
355-
* ```typescript
356-
* let imageSourceUrl = this.avatar.getSrcUrl();
357-
* ```
358-
*
359-
* @memberof IgxAvatarComponent
335+
* @hidden
336+
* @internal
360337
*/
361338
public getSrcUrl() {
362339
return `url(${this.src})`;

0 commit comments

Comments
 (0)