-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: split single notification effects service
+ increase notification contrast for the dark theme
- Loading branch information
1 parent
d7f3950
commit 28f332b
Showing
65 changed files
with
641 additions
and
251 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
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
18 changes: 18 additions & 0 deletions
18
modules/shared/components/src/lib/error-notification/error-notification.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,18 @@ | ||
<span matSnackBarLabel> | ||
<span class="message"> | ||
<mat-icon [fontIcon]="'warning_amber'" | ||
[color]="'warn'" | ||
[inline]="true" | ||
></mat-icon> | ||
{{ error$ | async }} | ||
</span> | ||
</span> | ||
|
||
<span matSnackBarActions> | ||
<button mat-button | ||
matSnackBarAction | ||
(click)="onDismiss()" | ||
> | ||
{{ 'common.dismissNotification' | transloco }} | ||
</button> | ||
</span> |
10 changes: 10 additions & 0 deletions
10
modules/shared/components/src/lib/error-notification/error-notification.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,10 @@ | ||
:host { | ||
display: flex; | ||
align-items: center; | ||
} | ||
|
||
.message { | ||
display: flex; | ||
align-items: center; | ||
gap: 10px; | ||
} |
37 changes: 37 additions & 0 deletions
37
modules/shared/components/src/lib/error-notification/error-notification.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,37 @@ | ||
import { ChangeDetectionStrategy, Component, Inject, inject } from '@angular/core'; | ||
import { MatButton } from '@angular/material/button'; | ||
import { MAT_SNACK_BAR_DATA, MatSnackBarAction, MatSnackBarActions, MatSnackBarLabel, MatSnackBarRef } from '@angular/material/snack-bar'; | ||
import { TranslocoPipe } from '@ngneat/transloco'; | ||
import { Observable } from 'rxjs'; | ||
import { AsyncPipe } from '@angular/common'; | ||
import { MatIcon } from '@angular/material/icon'; | ||
|
||
@Component({ | ||
standalone: true, | ||
selector: 'lib-error-notification', | ||
templateUrl: './error-notification.component.html', | ||
styleUrls: [ './error-notification.component.scss' ], | ||
imports: [ | ||
MatButton, | ||
MatSnackBarAction, | ||
MatSnackBarActions, | ||
MatSnackBarLabel, | ||
TranslocoPipe, | ||
AsyncPipe, | ||
MatIcon | ||
], | ||
changeDetection: ChangeDetectionStrategy.OnPush | ||
}) | ||
export class ErrorNotificationComponent { | ||
public readonly snackBarRef = inject(MatSnackBarRef); | ||
|
||
constructor( | ||
@Inject(MAT_SNACK_BAR_DATA) public readonly error$: Observable<string> | ||
) { | ||
} | ||
|
||
|
||
public onDismiss(): void { | ||
this.snackBarRef.dismiss(); | ||
} | ||
} |
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 @@ | ||
export * from './error-notification.component'; |
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
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 @@ | ||
export * from './info-notification.component'; |
14 changes: 14 additions & 0 deletions
14
modules/shared/components/src/lib/info-notification/info-notification.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,14 @@ | ||
<span matSnackBarLabel> | ||
<span class="message"> | ||
{{ caption$ | async }} | ||
</span> | ||
</span> | ||
|
||
<span matSnackBarActions> | ||
<button mat-button | ||
matSnackBarAction | ||
(click)="onDismiss()" | ||
> | ||
{{ 'common.dismissNotification' | transloco }} | ||
</button> | ||
</span> |
10 changes: 10 additions & 0 deletions
10
modules/shared/components/src/lib/info-notification/info-notification.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,10 @@ | ||
:host { | ||
display: flex; | ||
align-items: center; | ||
} | ||
|
||
.message { | ||
display: flex; | ||
align-items: baseline; | ||
gap: 10px; | ||
} |
35 changes: 35 additions & 0 deletions
35
modules/shared/components/src/lib/info-notification/info-notification.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,35 @@ | ||
import { ChangeDetectionStrategy, Component, Inject, inject } from '@angular/core'; | ||
import { MatButton } from '@angular/material/button'; | ||
import { MAT_SNACK_BAR_DATA, MatSnackBarAction, MatSnackBarActions, MatSnackBarLabel, MatSnackBarRef } from '@angular/material/snack-bar'; | ||
import { TranslocoPipe } from '@ngneat/transloco'; | ||
import { Observable } from 'rxjs'; | ||
import { AsyncPipe } from '@angular/common'; | ||
|
||
@Component({ | ||
standalone: true, | ||
selector: 'lib-info-notification', | ||
templateUrl: './info-notification.component.html', | ||
styleUrls: [ './info-notification.component.scss' ], | ||
imports: [ | ||
MatButton, | ||
MatSnackBarAction, | ||
MatSnackBarActions, | ||
MatSnackBarLabel, | ||
TranslocoPipe, | ||
AsyncPipe | ||
], | ||
changeDetection: ChangeDetectionStrategy.OnPush | ||
}) | ||
export class InfoNotificationComponent { | ||
public readonly snackBarRef = inject(MatSnackBarRef); | ||
|
||
constructor( | ||
@Inject(MAT_SNACK_BAR_DATA) public readonly caption$: Observable<string> | ||
) { | ||
} | ||
|
||
|
||
public onDismiss(): void { | ||
this.snackBarRef.dismiss(); | ||
} | ||
} |
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
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
11 changes: 11 additions & 0 deletions
11
modules/store/src/lib/actions/show-notification.actions.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 { createActionGroup, emptyProps, props } from '@ngrx/store'; | ||
|
||
export const SHOW_NOTIFICATION_ACTIONS = createActionGroup({ | ||
source: 'Show Notification', | ||
events: { | ||
error: props<{ l10nKey: string; l10nPayload?: object }>(), | ||
genericError: props<{ error: Error }>(), | ||
info: props<{ l10nKey: string; l10nPayload?: object }>(), | ||
appUpdated: emptyProps() | ||
} | ||
}); |
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
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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
17 changes: 17 additions & 0 deletions
17
modules/store/src/lib/effects/control-scheme/notify-on-control-scheme-imported.effect.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 { Actions, createEffect, ofType } from '@ngrx/effects'; | ||
import { inject } from '@angular/core'; | ||
import { map } from 'rxjs'; | ||
|
||
import { CONTROL_SCHEME_ACTIONS, SHOW_NOTIFICATION_ACTIONS } from '../../actions'; | ||
|
||
export const NOTIFY_ON_CONTROL_SCHEME_IMPORTED_EFFECT = createEffect(( | ||
actions: Actions = inject(Actions) | ||
) => { | ||
return actions.pipe( | ||
ofType(CONTROL_SCHEME_ACTIONS.importControlScheme), | ||
map((action) => SHOW_NOTIFICATION_ACTIONS.info({ | ||
l10nKey: 'controlScheme.importSuccessNotification', | ||
l10nPayload: action.scheme | ||
})) | ||
); | ||
}, { functional: true }); |
23 changes: 23 additions & 0 deletions
23
...les/store/src/lib/effects/control-scheme/notify-on-control-scheme-start-failure.effect.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,23 @@ | ||
import { Actions, createEffect, ofType } from '@ngrx/effects'; | ||
import { inject } from '@angular/core'; | ||
import { map } from 'rxjs'; | ||
|
||
import { CONTROL_SCHEME_ACTIONS, SHOW_NOTIFICATION_ACTIONS } from '../../actions'; | ||
import { OutOfRangeCalibrationError } from '../../hub-facades'; | ||
|
||
export const NOTIFY_ON_CONTROL_SCHEME_START_FAILURE_EFFECT = createEffect(( | ||
actions: Actions = inject(Actions), | ||
) => { | ||
return actions.pipe( | ||
ofType(CONTROL_SCHEME_ACTIONS.schemeStartFailed), | ||
map((action) => { | ||
const l10nKey = action.reason instanceof OutOfRangeCalibrationError | ||
? 'controlScheme.runFailedCalibrationOutOfRange' | ||
: 'controlScheme.runFailed'; | ||
return SHOW_NOTIFICATION_ACTIONS.error({ | ||
l10nKey, | ||
l10nPayload: action | ||
}); | ||
}) | ||
); | ||
}, { functional: true }); |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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
File renamed without changes.
File renamed without changes.
15 changes: 11 additions & 4 deletions
15
modules/store/src/lib/effects/controllers/capture-input/index.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 |
---|---|---|
@@ -1,4 +1,11 @@ | ||
export * from './capture-gamepad-input.effect'; | ||
export * from './capture-keyboard-input.effect'; | ||
export * from './capture-hub-green-button-input.effect'; | ||
export * from './capture-hub-button-groups-input.effect'; | ||
import { CAPTURE_GAMEPAD_INPUT } from './capture-gamepad-input.effect'; | ||
import { CAPTURE_KEYBOARD_INPUT } from './capture-keyboard-input.effect'; | ||
import { CAPTURE_HUB_GREEN_BUTTON_INPUT } from './capture-hub-green-button-input.effect'; | ||
import { CAPTURE_HUB_BUTTON_GROUPS_INPUT } from './capture-hub-button-groups-input.effect'; | ||
|
||
export const CONTROLLER_CAPTURE_INPUT_EFFECTS = { | ||
gamepadInput: CAPTURE_GAMEPAD_INPUT, | ||
keyboardInput: CAPTURE_KEYBOARD_INPUT, | ||
hubGreenButtonInput: CAPTURE_HUB_GREEN_BUTTON_INPUT, | ||
hubButtonGroupsInput: CAPTURE_HUB_BUTTON_GROUPS_INPUT, | ||
} as const; |
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,17 +1,11 @@ | ||
import { FunctionalEffect } from '@ngrx/effects'; | ||
|
||
import { CAPTURE_GAMEPAD_INPUT, CAPTURE_HUB_BUTTON_GROUPS_INPUT, CAPTURE_HUB_GREEN_BUTTON_INPUT, CAPTURE_KEYBOARD_INPUT } from './capture-input'; | ||
import { LISTEN_GAMEPAD_CONNECT, LISTEN_HUB_CONNECT, LISTEN_KEYBOARD_CONNECT } from './listen-connect'; | ||
import { LISTEN_GAMEPAD_DISCONNECT, LISTEN_HUB_DISCONNECT } from './listen-disconnect'; | ||
import { CONTROLLER_LISTEN_CONNECT_EFFECTS } from './listen-connect'; | ||
import { CONTROLLER_LISTEN_DISCONNECT_EFFECTS } from './listen-disconnect'; | ||
import { CONTROLLER_CAPTURE_INPUT_EFFECTS } from './capture-input'; | ||
|
||
export const CONTROLLER_EFFECTS: { [name: string]: FunctionalEffect } = { | ||
gamepadInput: CAPTURE_GAMEPAD_INPUT, | ||
gamepadConnect: LISTEN_GAMEPAD_CONNECT, | ||
gamepadDisconnect: LISTEN_GAMEPAD_DISCONNECT, | ||
keyboardConnect: LISTEN_KEYBOARD_CONNECT, | ||
keyboardInput: CAPTURE_KEYBOARD_INPUT, | ||
hubConnect: LISTEN_HUB_CONNECT, | ||
hubDisconnect: LISTEN_HUB_DISCONNECT, | ||
hubGreenButtonInput: CAPTURE_HUB_GREEN_BUTTON_INPUT, | ||
hubButtonGroupsInput: CAPTURE_HUB_BUTTON_GROUPS_INPUT | ||
}; | ||
...CONTROLLER_CAPTURE_INPUT_EFFECTS, | ||
...CONTROLLER_LISTEN_CONNECT_EFFECTS, | ||
...CONTROLLER_LISTEN_DISCONNECT_EFFECTS | ||
} as const; |
22 changes: 19 additions & 3 deletions
22
modules/store/src/lib/effects/controllers/listen-connect/index.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 |
---|---|---|
@@ -1,3 +1,19 @@ | ||
export * from './listen-gamepad-connect.effect'; | ||
export * from './listen-keyboard-connect.effect'; | ||
export * from './listen-hub-connect.effect'; | ||
import { FunctionalEffect } from '@ngrx/effects'; | ||
|
||
import { LISTEN_HUB_CONNECT } from './listen-hub-connect.effect'; | ||
import { LISTEN_KEYBOARD_CONNECT } from './listen-keyboard-connect.effect'; | ||
import { LISTEN_GAMEPAD_CONNECT } from './listen-gamepad-connect.effect'; | ||
import { NOTIFY_ON_HUB_KEYBOARD_DISCOVERED_EFFECT } from './notify-on-keyboard-discovered.effect'; | ||
import { NOTIFY_ON_HUB_KEYBOARD_CONNECTED_EFFECT } from './notify-on-keyboard-connected.effect'; | ||
import { NOTIFY_ON_GAMEPAD_CONNECTED_EFFECT } from './notify-on-gamepad-connected.effect'; | ||
import { NOTIFY_ON_GAMEPAD_DISCOVERED_EFFECT } from './notify-on-gamepad-discovered.effect'; | ||
|
||
export const CONTROLLER_LISTEN_CONNECT_EFFECTS: {[name: string]: FunctionalEffect} = { | ||
gamepadConnect: LISTEN_GAMEPAD_CONNECT, | ||
keyboardConnect: LISTEN_KEYBOARD_CONNECT, | ||
hubConnect: LISTEN_HUB_CONNECT, | ||
notifyOnHubKeyboardDiscovered: NOTIFY_ON_HUB_KEYBOARD_DISCOVERED_EFFECT, | ||
notifyOnHubKeyboardConnected: NOTIFY_ON_HUB_KEYBOARD_CONNECTED_EFFECT, | ||
notifyOnGamepadDiscovered: NOTIFY_ON_GAMEPAD_DISCOVERED_EFFECT, | ||
notifyOnGamepadConnected: NOTIFY_ON_GAMEPAD_CONNECTED_EFFECT, | ||
} as const; |
Oops, something went wrong.