Skip to content

Commit

Permalink
fix(core): styles of group popover control & a11y issues
Browse files Browse the repository at this point in the history
  • Loading branch information
artolshansky committed Jun 8, 2021
1 parent 27fbc55 commit 6799de9
Show file tree
Hide file tree
Showing 6 changed files with 102 additions and 18 deletions.
1 change: 1 addition & 0 deletions apps/docs/src/app/core/api-files.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export const API_FILES = {
'AvatarGroupComponent',
'AvatarGroupItemDirective',
'AvatarGroupFocusableAvatarDirective',
'AvatarGroupPopoverControlDirective',
'AvatarGroupOverflowBodyDirective',
'AvatarGroupOverflowItemDirective',
'AvatarGroupOverflowButtonDirective',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,16 @@
placement="bottom"
maxWidth="312"
#overflowPopover>
<fd-popover-control tabindex="0"
<fd-popover-control fd-avatar-group-popover-control
[attr.aria-label]="'Has popup type dialog Conjoined avatars, ' + (people?.length - avatarGroup_GroupType?.overflowItemsCount)
+ ' avatars displayed, ' + avatarGroup_GroupType?.overflowItemsCount + ' avatars hidden, activate for complete list'"
(click)="handleControlClick($event, overflowPopover)"
(keydown)="handleControlKeydown($event, overflowPopover)">
<div *ngFor="let person of people" fd-avatar-group-item>
<fd-avatar *ngIf="!person.imageUrl && !person.glyph"
[label]="person.firstName + ' ' + person.lastName"
[title]="person.firstName + ' ' + person.lastName"
[ariaLabel]="person.firstName + ' ' + person.lastName + ' avatar'"
role="img"
[circle]="true"
[border]="true"
Expand All @@ -24,6 +27,7 @@
<fd-avatar *ngIf="person.imageUrl"
role="img"
[title]="person.firstName + ' ' + person.lastName"
[ariaLabel]="person.firstName + ' ' + person.lastName + ' avatar'"
[circle]="true"
[border]="true"
[size]="size"
Expand All @@ -32,6 +36,7 @@
<fd-avatar *ngIf="person.glyph"
role="img"
[title]="person.firstName + ' ' + person.lastName"
[ariaLabel]="person.firstName + ' ' + person.lastName + ' avatar'"
[circle]="true"
[border]="true"
[size]="size"
Expand Down Expand Up @@ -81,6 +86,7 @@
size="s"
[label]="person.firstName + ' ' + person.lastName"
[title]="person.firstName + ' ' + person.lastName"
[ariaLabel]="person.firstName + ' ' + person.lastName + ' avatar'"
role="img"
(click)="openOverflowDetails(idx)"
(keydown.enter)="openOverflowDetails(idx)"
Expand All @@ -90,6 +96,7 @@
fd-avatar-group-focusable-avatar
role="img"
[title]="person.firstName + ' ' + person.lastName"
[ariaLabel]="person.firstName + ' ' + person.lastName + ' avatar'"
[circle]="true"
size="s"
[image]="person.imageUrl"
Expand All @@ -101,6 +108,7 @@
fd-avatar-group-focusable-avatar
role="img"
[title]="person.firstName + ' ' + person.lastName"
[ariaLabel]="person.firstName + ' ' + person.lastName + ' avatar'"
[circle]="true"
size="s"
[glyph]="person.glyph"
Expand All @@ -118,20 +126,23 @@
<fd-avatar *ngIf="!personDetails.imageUrl && !personDetails.glyph"
[circle]="true"
size="s"
[label]="personDetails.firstName + ' ' + personDetails.lastName"
role="img"
[title]="personDetails.firstName + ' ' + personDetails.lastName"></fd-avatar>
[label]="personDetails.firstName + ' ' + personDetails.lastName"
[title]="personDetails.firstName + ' ' + personDetails.lastName"
[ariaLabel]="personDetails.firstName + ' ' + personDetails.lastName + ' avatar'"></fd-avatar>
<fd-avatar *ngIf="personDetails.imageUrl"
[circle]="true"
size="s"
role="img"
[title]="personDetails.firstName + ' ' + personDetails.lastName"
[ariaLabel]="personDetails.firstName + ' ' + personDetails.lastName + ' avatar'"
[image]="personDetails.imageUrl"></fd-avatar>
<fd-avatar *ngIf="personDetails.glyph"
[circle]="true"
size="s"
role="img"
[title]="personDetails.firstName + ' ' + personDetails.lastName"
[ariaLabel]="personDetails.firstName + ' ' + personDetails.lastName + ' avatar'"
[glyph]="personDetails.glyph"></fd-avatar>
<fd-quick-view-subheader-title>{{ personDetails.firstName }} {{ personDetails.lastName }}</fd-quick-view-subheader-title>
<fd-quick-view-subheader-subtitle>{{ personDetails.position }}</fd-quick-view-subheader-subtitle>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,23 +20,26 @@
[size]="size"
role="img"
[title]="person.firstName + ' ' + person.lastName"
[label]="person.firstName + ' ' + person.lastName"></fd-avatar>
[label]="person.firstName + ' ' + person.lastName"
[ariaLabel]="person.firstName + ' ' + person.lastName + ' avatar'"></fd-avatar>

<fd-avatar *ngIf="person.imageUrl"
[circle]="true"
[border]="true"
[size]="size"
[image]="person.imageUrl"
role="img"
[title]="person.firstName + ' ' + person.lastName"></fd-avatar>
[title]="person.firstName + ' ' + person.lastName"
[ariaLabel]="person.firstName + ' ' + person.lastName + ' avatar'"></fd-avatar>

<fd-avatar *ngIf="person.glyph"
[circle]="true"
[border]="true"
[size]="size"
[glyph]="person.glyph"
role="img"
[title]="person.firstName + ' ' + person.lastName"></fd-avatar>
[title]="person.firstName + ' ' + person.lastName"
[ariaLabel]="person.firstName + ' ' + person.lastName + ' avatar'"></fd-avatar>
</div>
</fd-popover-control>

Expand All @@ -47,23 +50,26 @@
<fd-avatar *ngIf="!person.imageUrl && !person.glyph"
[circle]="true"
size="s"
[label]="person.firstName + ' ' + person.lastName"
role="img"
[title]="person.firstName + ' ' + person.lastName"></fd-avatar>
[label]="person.firstName + ' ' + person.lastName"
[title]="person.firstName + ' ' + person.lastName"
[ariaLabel]="person.firstName + ' ' + person.lastName + ' avatar'"></fd-avatar>

<fd-avatar *ngIf="person.imageUrl"
[circle]="true"
size="s"
[image]="person.imageUrl"
role="img"
[title]="person.firstName + ' ' + person.lastName"></fd-avatar>
[image]="person.imageUrl"
[title]="person.firstName + ' ' + person.lastName"
[ariaLabel]="person.firstName + ' ' + person.lastName + ' avatar'"></fd-avatar>

<fd-avatar *ngIf="person.glyph"
[circle]="true"
size="s"
[glyph]="person.glyph"
role="img"
[title]="person.firstName + ' ' + person.lastName"></fd-avatar>
[glyph]="person.glyph"
[title]="person.firstName + ' ' + person.lastName"
[ariaLabel]="person.firstName + ' ' + person.lastName + ' avatar'"></fd-avatar>
<fd-quick-view-subheader-title>{{ person.firstName }} {{ person.lastName }}</fd-quick-view-subheader-title>
<fd-quick-view-subheader-subtitle>{{ person.position }}</fd-quick-view-subheader-subtitle>
</fd-quick-view-subheader>
Expand Down Expand Up @@ -151,9 +157,10 @@
fd-avatar-group-focusable-avatar
[circle]="true"
size="s"
[label]="person.firstName + ' ' + person.lastName"
role="img"
[label]="person.firstName + ' ' + person.lastName"
[title]="person.firstName + ' ' + person.lastName"
[ariaLabel]="person.firstName + ' ' + person.lastName + ' avatar'"
(click)="openOverflowDetails(idx)"
(keydown.enter)="openOverflowDetails(idx)"
(keydown.space)="openOverflowDetails(idx)"
Expand All @@ -163,9 +170,10 @@
fd-avatar-group-focusable-avatar
[circle]="true"
size="s"
[image]="person.imageUrl"
role="img"
[image]="person.imageUrl"
[title]="person.firstName + ' ' + person.lastName"
[ariaLabel]="person.firstName + ' ' + person.lastName + ' avatar'"
(click)="openOverflowDetails(idx)"
(keydown.enter)="openOverflowDetails(idx)"
(keydown.space)="openOverflowDetails(idx)"
Expand All @@ -175,9 +183,10 @@
fd-avatar-group-focusable-avatar
[circle]="true"
size="s"
[glyph]="person.glyph"
role="img"
[glyph]="person.glyph"
[title]="person.firstName + ' ' + person.lastName"
[ariaLabel]="person.firstName + ' ' + person.lastName + ' avatar'"
(click)="openOverflowDetails(idx)"
(keydown.enter)="openOverflowDetails(idx)"
(keydown.space)="openOverflowDetails(idx)"
Expand All @@ -193,21 +202,24 @@
size="s"
[label]="personDetails.firstName + ' ' + personDetails.lastName"
role="img"
[title]="personDetails.firstName + ' ' + personDetails.lastName"></fd-avatar>
[title]="personDetails.firstName + ' ' + personDetails.lastName"
[ariaLabel]="personDetails.firstName + ' ' + personDetails.lastName + ' avatar'"></fd-avatar>

<fd-avatar *ngIf="personDetails.imageUrl"
[circle]="true"
size="s"
[image]="personDetails.imageUrl"
role="img"
[title]="personDetails.firstName + ' ' + personDetails.lastName"></fd-avatar>
[title]="personDetails.firstName + ' ' + personDetails.lastName"
[ariaLabel]="personDetails.firstName + ' ' + personDetails.lastName + ' avatar'"></fd-avatar>

<fd-avatar *ngIf="personDetails.glyph"
[circle]="true"
size="s"
[glyph]="personDetails.glyph"
role="img"
[title]="personDetails.firstName + ' ' + personDetails.lastName"></fd-avatar>
[title]="personDetails.firstName + ' ' + personDetails.lastName"
[ariaLabel]="personDetails.firstName + ' ' + personDetails.lastName + ' avatar'"></fd-avatar>
<fd-quick-view-subheader-title>{{ personDetails.firstName }} {{ personDetails.lastName }}</fd-quick-view-subheader-title>
<fd-quick-view-subheader-subtitle>{{ personDetails.position }}</fd-quick-view-subheader-subtitle>
</fd-quick-view-subheader>
Expand Down
3 changes: 3 additions & 0 deletions libs/core/src/lib/avatar-group/avatar-group.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,15 @@ import { AvatarGroupOverflowItemDirective } from './directives/avatar-group-over
import { AvatarGroupOverflowButtonDirective } from './directives/avatar-group-overflow-button.directive';
import { AvatarGroupOverflowButtonTextDirective } from './directives/avatar-group-overflow-button-text.directive';
import { AvatarGroupFocusableAvatarDirective } from './directives/avatar-group-focusable-avatar.directive';
import { AvatarGroupPopoverControlDirective } from './directives/avatar-group-popover-control.directive';

@NgModule({
imports: [CommonModule],
exports: [
AvatarGroupComponent,
AvatarGroupItemDirective,
AvatarGroupFocusableAvatarDirective,
AvatarGroupPopoverControlDirective,
AvatarGroupOverflowBodyDirective,
AvatarGroupOverflowItemDirective,
AvatarGroupOverflowButtonDirective,
Expand All @@ -24,6 +26,7 @@ import { AvatarGroupFocusableAvatarDirective } from './directives/avatar-group-f
AvatarGroupComponent,
AvatarGroupItemDirective,
AvatarGroupFocusableAvatarDirective,
AvatarGroupPopoverControlDirective,
AvatarGroupOverflowBodyDirective,
AvatarGroupOverflowItemDirective,
AvatarGroupOverflowButtonDirective,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
import { Component, ElementRef, ViewChild } from '@angular/core';

import { AvatarGroupModule } from '../avatar-group.module';

@Component({
template: `<fd-avatar #directiveElement fd-avatar-group-popover-control></fd-avatar>`
})
class TestComponent {
@ViewChild('directiveElement', { static: false })
ref: ElementRef;
}

describe('AvatarGroupPopoverControlDirective', () => {
let component: TestComponent;
let fixture: ComponentFixture<TestComponent>;

beforeEach(waitForAsync(() => {
TestBed.configureTestingModule({
declarations: [TestComponent],
imports: [AvatarGroupModule]
}).compileComponents();
}));

beforeEach(() => {
fixture = TestBed.createComponent(TestComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});

it('should create', () => {
expect(component).toBeTruthy();
});

it('should assign class', () => {
expect(component.ref.nativeElement).toHaveClass('fd-avatar-group__popover-control');
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { Directive, HostBinding, Input } from '@angular/core';

/** Needed to bind specific class to group type popover control. */
@Directive({
// tslint:disable-next-line:directive-selector
selector: '[fd-avatar-group-popover-control]',
host: { class: 'fd-avatar-group__popover-control' }
})
export class AvatarGroupPopoverControlDirective {
/** Tabindex of the popover control. */
@Input()
@HostBinding('attr.tabindex')
tabindex = 0;

/** Role of the popover control. */
@Input()
@HostBinding('attr.role')
role = 'button';
}

0 comments on commit 6799de9

Please sign in to comment.