-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(notification-panel): add new component (#78)
- Loading branch information
Showing
29 changed files
with
710 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
{} | ||
{} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 4 additions & 0 deletions
4
.../documentation/examples/notification-panel-actions/notification-panel-actions-example.css
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
.inline-delete { | ||
display: flex; | ||
justify-content: space-between; | ||
} |
53 changes: 53 additions & 0 deletions
53
...documentation/examples/notification-panel-actions/notification-panel-actions-example.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
<button nxIconButton="small tertiary" class="nx-margin-0" | ||
[nxNotificationPanelTriggerFor]="panel1" title="Notifications"> | ||
<nx-icon name="bell-o"></nx-icon> | ||
</button> | ||
|
||
<ng-template #panel1> | ||
<nx-notification-panel> | ||
<nx-notification-header> | ||
<h3 nxCopytext="large" class="nx-margin-0">Unread | ||
</h3><button nxPlainButton="small" type="button">Mark all as read <nx-icon | ||
name="check" class="nx-margin-left-2xs"></nx-icon></button> | ||
</nx-notification-header> | ||
|
||
<a nxNotificationPanelItem clickable="false" [attr.href]="null"> | ||
<nx-notification-item-metadata> | ||
<nx-icon size="s" class="nx-margin-right-2xs" name="lock-o" | ||
aria-hidden="true"></nx-icon>File lock release · 16:53 | ||
</nx-notification-item-metadata> | ||
<nx-notification-item-content> | ||
The file you tried to edit (XY12345) is now available. | ||
</nx-notification-item-content> | ||
<nx-notification-item-actions> | ||
<nx-link><a href="#file-link">Edit file</a></nx-link> | ||
<button nxPlainButton="small" type="button" title="Delete"> | ||
<nx-icon name="trash-o" aria-hidden="true"></nx-icon> | ||
</button> | ||
</nx-notification-item-actions> | ||
</a> | ||
<div nxNotificationPanelItem clickable="false"> | ||
<nx-notification-item-metadata> | ||
<nx-icon size="s" class="nx-margin-right-2xs" name="phone" | ||
aria-hidden="true"></nx-icon>Callback · 11:35 | ||
</nx-notification-item-metadata> | ||
<nx-notification-item-content class="inline-delete"> | ||
Please call back James Erwin at 15:00 | ||
<button nxPlainButton="small" class="" type="button" title="Delete"> | ||
<nx-icon name="trash-o" aria-hidden="true"></nx-icon> | ||
</button> | ||
</nx-notification-item-content> | ||
</div> | ||
<nx-notification-header> | ||
<h3 nxCopytext="large" class="nx-margin-0">Unread | ||
</h3> | ||
</nx-notification-header> | ||
<div nxNotificationPanelItem read clickable="false"> | ||
<nx-notification-item-metadata>Offers · Yesterday | ||
</nx-notification-item-metadata> | ||
<nx-notification-item-content> | ||
Mary London - Note created | ||
</nx-notification-item-content> | ||
</div> | ||
</nx-notification-panel> | ||
</ng-template> |
11 changes: 11 additions & 0 deletions
11
...a/documentation/examples/notification-panel-actions/notification-panel-actions-example.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { Component } from '@angular/core'; | ||
|
||
/** | ||
* @title Notification Panel | ||
*/ | ||
@Component({ | ||
templateUrl: './notification-panel-actions-example.html', | ||
styleUrls: ['./notification-panel-actions-example.css'] | ||
}) | ||
export class NotificationPanelActionsExampleComponent { | ||
} |
Empty file.
40 changes: 40 additions & 0 deletions
40
...mentation/examples/notification-panel-clickable/notification-panel-clickable-example.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<button nxIconButton="small tertiary" class="nx-margin-0" | ||
[nxNotificationPanelTriggerFor]="panel1" title="Notifications"> | ||
<nx-icon name="bell-o"></nx-icon> | ||
</button> | ||
|
||
<ng-template #panel1> | ||
<nx-notification-panel> | ||
<nx-notification-header> | ||
<h3 nxCopytext="large" class="nx-margin-0">Unread | ||
</h3><button nxPlainButton="small" type="button">Mark all as read <nx-icon | ||
name="check" class="nx-margin-left-2xs"></nx-icon></button> | ||
</nx-notification-header> | ||
|
||
<a nxNotificationPanelItem routerLink="#clickable-notification1"> | ||
<nx-notification-item-metadata>Tasks · 5 minutes ago | ||
</nx-notification-item-metadata> | ||
<nx-notification-item-content> | ||
Frank Loyd - created new offer | ||
</nx-notification-item-content> | ||
</a> | ||
<a nxNotificationPanelItem routerLink="#clickable-notification2"> | ||
<nx-notification-item-metadata>Offers · 11:45 | ||
</nx-notification-item-metadata> | ||
<nx-notification-item-content> | ||
Susi Müller - Offer status has changed | ||
</nx-notification-item-content> | ||
</a> | ||
<nx-notification-header> | ||
<h3 nxCopytext="large" class="nx-margin-0">Unread | ||
</h3> | ||
</nx-notification-header> | ||
<a nxNotificationPanelItem read routerLink="#clickable-notification3"> | ||
<nx-notification-item-metadata>Offers · Yesterday | ||
</nx-notification-item-metadata> | ||
<nx-notification-item-content> | ||
Mary London - Note created | ||
</nx-notification-item-content> | ||
</a> | ||
</nx-notification-panel> | ||
</ng-template> |
11 changes: 11 additions & 0 deletions
11
...cumentation/examples/notification-panel-clickable/notification-panel-clickable-example.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { Component } from '@angular/core'; | ||
|
||
/** | ||
* @title Notification Panel | ||
*/ | ||
@Component({ | ||
templateUrl: './notification-panel-clickable-example.html', | ||
styleUrls: ['./notification-panel-clickable-example.css'] | ||
}) | ||
export class NotificationPanelClickableExampleComponent { | ||
} |
Empty file.
44 changes: 44 additions & 0 deletions
44
...ila/documentation/examples/notification-panel-mixed/notification-panel-mixed-example.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
<button nxIconButton="small tertiary" class="nx-margin-0" | ||
[nxNotificationPanelTriggerFor]="panel1" title="Notifications"> | ||
<nx-icon name="bell-o"></nx-icon> | ||
</button> | ||
|
||
<ng-template #panel1> | ||
<nx-notification-panel> | ||
<nx-notification-header> | ||
<h3 nxCopytext="large" class="nx-margin-0">Unread | ||
</h3><button nxPlainButton="small" type="button">Mark all as read <nx-icon | ||
name="check" class="nx-margin-left-2xs"></nx-icon></button> | ||
</nx-notification-header> | ||
|
||
<a nxNotificationPanelItem routerLink="#clickable-notification1"> | ||
<nx-notification-item-metadata> | ||
<nx-icon size="s" class="nx-margin-right-2xs" name="lock-o" | ||
aria-hidden="true"></nx-icon>File lock release · 16:53 | ||
</nx-notification-item-metadata> | ||
<nx-notification-item-content> | ||
The file you tried to edit (XY12345) is now available. | ||
</nx-notification-item-content> | ||
</a> | ||
<a nxNotificationPanelItem clickable="false" [routerLink]="null"> | ||
<nx-notification-item-metadata> | ||
<nx-icon size="s" class="nx-margin-right-2xs" name="phone" | ||
aria-hidden="true"></nx-icon>Callback · 11:35 | ||
</nx-notification-item-metadata> | ||
<nx-notification-item-content> | ||
Please call back James Erwin at 15:00 | ||
</nx-notification-item-content> | ||
</a> | ||
<nx-notification-header> | ||
<h3 nxCopytext="large" class="nx-margin-0">Unread | ||
</h3> | ||
</nx-notification-header> | ||
<div nxNotificationPanelItem read routerLink="#clickable-notification3"> | ||
<nx-notification-item-metadata>Offers · Yesterday | ||
</nx-notification-item-metadata> | ||
<nx-notification-item-content> | ||
Mary London - Note created | ||
</nx-notification-item-content> | ||
</div> | ||
</nx-notification-panel> | ||
</ng-template> |
11 changes: 11 additions & 0 deletions
11
...quila/documentation/examples/notification-panel-mixed/notification-panel-mixed-example.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { Component } from '@angular/core'; | ||
|
||
/** | ||
* @title Notification Panel | ||
*/ | ||
@Component({ | ||
templateUrl: './notification-panel-mixed-example.html', | ||
styleUrls: ['./notification-panel-mixed-example.css'] | ||
}) | ||
export class NotificationPanelMixedExampleComponent { | ||
} |
17 changes: 17 additions & 0 deletions
17
projects/ng-aquila/src/notification-panel/notification-item/notification-item-slots.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { Directive } from '@angular/core'; | ||
|
||
// tslint:disable-next-line:directive-selector | ||
@Directive({ selector: 'nx-notification-item-metadata' }) | ||
export class NxNotificationItemMetadataDirective {} | ||
|
||
// tslint:disable-next-line:directive-selector | ||
@Directive({ selector: 'nx-notification-item-content' }) | ||
export class NxNotificationItemContentDirective {} | ||
|
||
// tslint:disable-next-line:directive-selector | ||
@Directive({ selector: 'nx-notification-item-actions' }) | ||
export class NxNotificationItemActionsDirective {} | ||
|
||
// tslint:disable-next-line:directive-selector | ||
@Directive({ selector: 'nx-notification-header' }) | ||
export class NxNotificationItemHeaderDirective {} |
7 changes: 7 additions & 0 deletions
7
projects/ng-aquila/src/notification-panel/notification-item/notification-item.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<ng-content select="nx-notification-item-metadata"></ng-content> | ||
|
||
<ng-content select="nx-notification-item-content"></ng-content> | ||
<ng-content></ng-content> | ||
|
||
<ng-content select="nx-notification-item-actions"></ng-content> | ||
|
62 changes: 62 additions & 0 deletions
62
projects/ng-aquila/src/notification-panel/notification-item/notification-item.component.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
@import "../../shared-styles/index"; | ||
:host { | ||
display: flex; | ||
flex-direction: column; | ||
background-color: var(--notification-panel-item-unread-background-color); | ||
padding: 16px 24px; | ||
margin: 0 -24px; | ||
&.nx-notification-item--read { | ||
background-color: var(--notification-panel-item-read-background-color); | ||
} | ||
&:focus { | ||
outline: none; | ||
} | ||
} | ||
|
||
:host-context([data-whatinput="keyboard"]):focus { | ||
@include focus-style-inset; | ||
} | ||
|
||
::ng-deep { | ||
nx-notification-item-metadata { | ||
font-size: 14px; | ||
font-weight: 400; | ||
line-height: 20px; | ||
letter-spacing: 0.2px; | ||
margin-bottom: 4px; | ||
display: flex; | ||
align-items: center; | ||
} | ||
nx-notification-item-content { | ||
font-size: 16px; | ||
font-weight: 400; | ||
line-height: 24px; | ||
} | ||
nx-notification-item-actions { | ||
font-size: 16px; | ||
font-weight: 400; | ||
line-height: 24px; | ||
display: flex; | ||
justify-content: space-between; | ||
padding-top: 8px; | ||
} | ||
} | ||
|
||
// Hover and active styles for clickable item | ||
:host(.nx-notification-item--clickable) { | ||
cursor: pointer; | ||
&:hover { | ||
background-color: var(--notification-panel-item-unread-hover-background-color); | ||
} | ||
&:active { | ||
background-color: var(--notification-panel-item-unread-active-background-color); | ||
} | ||
&.nx-notification-item--read { | ||
&:hover { | ||
background-color: var(--notification-panel-item-read-hover-background-color); | ||
} | ||
&:active { | ||
background-color: var(-notification-panel-item-read-active-background-color); | ||
} | ||
} | ||
} |
67 changes: 67 additions & 0 deletions
67
projects/ng-aquila/src/notification-panel/notification-item/notification-item.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
import { FocusableOption, FocusOrigin } from '@angular/cdk/a11y'; | ||
import { BooleanInput, coerceBooleanProperty } from '@angular/cdk/coercion'; | ||
import { Component, ElementRef, Input } from '@angular/core'; | ||
import { Subject } from 'rxjs'; | ||
|
||
@Component({ | ||
selector: 'nx-notification-panel-item, [nxNotificationPanelItem]', | ||
templateUrl: 'notification-item.component.html', | ||
styleUrls: ['./notification-item.component.scss'], | ||
host: { | ||
'[class.nx-notification-item--read]': 'read', | ||
'[class.nx-notification-item--clickable]': 'clickable', | ||
'tabindex': '0', | ||
'(focus)': 'focus()', | ||
'(blur)': '_blur()' | ||
} | ||
}) | ||
|
||
export class NxNotificationPanelItemComponent implements FocusableOption { | ||
|
||
private _read: boolean = false; | ||
private _clickable: boolean = true; | ||
private _hasFocus = false; | ||
|
||
focused = new Subject<NxNotificationPanelItemComponent>(); | ||
|
||
@Input() | ||
set read(value: boolean) { | ||
this._read = coerceBooleanProperty(value); | ||
} | ||
get read() { | ||
return this._read; | ||
} | ||
|
||
@Input() | ||
set clickable(value: boolean) { | ||
this._clickable = coerceBooleanProperty(value); | ||
} | ||
get clickable() { | ||
return this._clickable; | ||
} | ||
|
||
constructor(private _elementRef: ElementRef) { } | ||
|
||
focus(focusOrigin?: FocusOrigin) { | ||
// the focus key manager calls this method with the focusOrigin | ||
// property. if it is not set we know the focus comes from another source | ||
// like the user using TAB to go through the list. Then we want to notify | ||
// the focus manager about this change of focus. | ||
if (typeof focusOrigin === 'undefined' && !this._hasFocus) { | ||
this.focused.next(this); | ||
this._hasFocus = true; | ||
} | ||
|
||
if (!this._hasFocus) { | ||
this._elementRef.nativeElement.focus(); | ||
this._hasFocus = true; | ||
} | ||
} | ||
|
||
_blur() { | ||
this._hasFocus = false; | ||
} | ||
|
||
static ngAcceptInputType_read: BooleanInput; | ||
static ngAcceptInputType_clickable: BooleanInput; | ||
} |
Oops, something went wrong.