Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(core): update Notifications to latest design #12476

Merged
merged 1 commit into from
Oct 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import { Directive, HostBinding } from '@angular/core';
import { Directive } from '@angular/core';

@Directive({
selector: '[fdNotificationFooterContent], [fd-notification-footer-content]',
standalone: true
standalone: true,
host: {
class: 'fd-notification__footer-content'
}
})
export class NotificationFooterContentDirective {
/** @hidden */
@HostBinding('class.fd-notification__footer-content')
fdNotificationTitleClass = true;
}
export class NotificationFooterContentDirective {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import { Component, ElementRef, ViewChild } from '@angular/core';
import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
import { NotificationModule } from '../notification.module';

@Component({
template: `<span #directiveElement fd-notification-group-growing-item-title>Notification Group Growing Item Title Test</span> `
})
class TestComponent {
@ViewChild('directiveElement')
ref: ElementRef;
}
describe('NotificationGroupGrowingItemTitleDirective', () => {
let component: TestComponent;
let fixture: ComponentFixture<TestComponent>;

beforeEach(waitForAsync(() => {
TestBed.configureTestingModule({
declarations: [TestComponent],
imports: [NotificationModule]
}).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.className).toBe('fd-notification-group__growing-item-title');
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { Directive } from '@angular/core';

@Directive({
selector: '[fdNotificationGroupGrowingItemTitle], [fd-notification-group-growing-item-title]',
standalone: true,
host: {
class: 'fd-notification-group__growing-item-title'
}
})
export class NotificationGroupGrowingItemTitleDirective {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import { Component, ElementRef, ViewChild } from '@angular/core';
import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
import { NotificationModule } from '../notification.module';

@Component({
template: `<span #directiveElement fd-notification-group-header-title>Notification Group Header Title Test</span> `
})
class TestComponent {
@ViewChild('directiveElement')
ref: ElementRef;
}
describe('NotificationGroupHeaderTitleDirective', () => {
let component: TestComponent;
let fixture: ComponentFixture<TestComponent>;

beforeEach(waitForAsync(() => {
TestBed.configureTestingModule({
declarations: [TestComponent],
imports: [NotificationModule]
}).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.className).toBe('fd-notification-group__header-title');
});

it('should assign default role', () => {
expect(component.ref.nativeElement.getAttribute('role')).toBe('heading');
});

it('should assign default aria level', () => {
expect(component.ref.nativeElement.getAttribute('aria-level')).toBe('3');
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import { Directive, input } from '@angular/core';
import { FD_NOTIFICATION_GROUP_HEADER_TITLE } from '../token';

let notificationGroupHeaderTitleCounter = 0;

@Directive({
selector: '[fdNotificationGroupHeaderTitle], [fd-notification-group-header-title]',
standalone: true,
host: {
class: 'fd-notification-group__header-title',
role: 'heading',
'[attr.aria-level]': 'ariaLevel()',
'[attr.id]': 'id()'
},
providers: [
{
provide: FD_NOTIFICATION_GROUP_HEADER_TITLE,
useExisting: NotificationGroupHeaderTitleDirective
}
]
})
export class NotificationGroupHeaderTitleDirective {
/**
* aria-level for the title
* a numeric value from 1 to 6
* default value is 3
*/
ariaLevel = input<1 | 2 | 3 | 4 | 5 | 6>(3);

/**
* id for the notification group header title
* if not set, a default value is provided
*/
id = input('fd-notification-group-header-title-' + ++notificationGroupHeaderTitleCounter);
}

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import { Component, ElementRef, ViewChild } from '@angular/core';
import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
import { NotificationModule } from '../notification.module';

@Component({
template: `<div #directiveElement fd-notification-list>Notification List Test</div> `
})
class TestComponent {
@ViewChild('directiveElement')
ref: ElementRef;
}
describe('NotificationListDirective', () => {
let component: TestComponent;
let fixture: ComponentFixture<TestComponent>;

beforeEach(waitForAsync(() => {
TestBed.configureTestingModule({
declarations: [TestComponent],
imports: [NotificationModule]
}).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.className).toBe('fd-notification-list');
});

it('should assign default role', () => {
expect(component.ref.nativeElement.getAttribute('role')).toBe('list');
});

it('should assign default aria lebel', () => {
expect(component.ref.nativeElement.getAttribute('aria-label')).toBe('Notifications');
});
});
18 changes: 18 additions & 0 deletions libs/core/notification/directives/notification-list.directive.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { Directive, input } from '@angular/core';

@Directive({
selector: '[fdNotificationList], [fd-notification-list]',
standalone: true,
host: {
class: 'fd-notification-list',
role: 'list',
'[attr.aria-label]': 'ariaLabel()'
}
})
export class NotificationListDirective {
/**
* aria-label attribute for the element
* Default is set to 'Notifications'
*/
ariaLabel = input('Notifications');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be prepared for translation

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import { Component, ElementRef, ViewChild } from '@angular/core';
import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
import { NotificationModule } from '../notification.module';

@Component({
template: `<div #directiveElement fd-notification-message-strip-container>Notification Message Strip Container Test</div> `
})
class TestComponent {
@ViewChild('directiveElement')
ref: ElementRef;
}
describe('NotificationMessageStripContainerDirective', () => {
let component: TestComponent;
let fixture: ComponentFixture<TestComponent>;

beforeEach(waitForAsync(() => {
TestBed.configureTestingModule({
declarations: [TestComponent],
imports: [NotificationModule]
}).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.className).toBe('fd-notification__message-strip-container');
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { Directive } from '@angular/core';

@Directive({
selector: '[fdNotificationMessageStripContainer], [fd-notification-message-strip-container]',
standalone: true,
host: {
class: 'fd-notification__message-strip-container'
}
})
export class NotificationMessageStripContainerDirective {}
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
import { NotificationModule } from '../notification.module';

@Component({
template: `<p #directiveElement fd-notification-limit-description>Notification Limit Description Test</p> `
template: `<div #directiveElement fd-notification-message-strip>Notification Message Strip Test</div> `
})
class TestComponent {
@ViewChild('directiveElement')
ref: ElementRef;
}
describe('NotificationLimitDescriptionDirective', () => {
describe('NotificationMessageStripDirective', () => {
let component: TestComponent;
let fixture: ComponentFixture<TestComponent>;

Expand All @@ -31,6 +31,6 @@ describe('NotificationLimitDescriptionDirective', () => {
});

it('should assign class', () => {
expect(component.ref.nativeElement.className).toBe('fd-notification__limit--description');
expect(component.ref.nativeElement.className).toBe('fd-notification-message-strip');
});
});
Loading
Loading