-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added alert and alerts components to preview library along with assoc…
…iated alert service
- Loading branch information
1 parent
3b4d0a0
commit a087594
Showing
15 changed files
with
1,428 additions
and
14 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
89 changes: 89 additions & 0 deletions
89
libs/usersrole-nx-app/preview/src/lib/components/alert/_alert-theme.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,89 @@ | ||
@use 'sass:map'; | ||
@use '@angular/material' as mat; | ||
|
||
@mixin color($theme) { | ||
$color-config: mat.get-color-config($theme); | ||
$primary-palette: map.get($color-config, 'primary'); | ||
$accent-palette: map.get($color-config, 'accent'); | ||
$warn-palette: map.get($theme, 'warn'); | ||
$error-palette: map.get($theme, 'error'); | ||
$success-palette: map.get($theme, 'success'); | ||
$info-palette: map.get($theme, 'info'); | ||
|
||
$primary-color: mat.get-color-from-palette($primary-palette, default); | ||
$accent-color: mat.get-color-from-palette($accent-palette, default); | ||
$warn-color: mat.get-color-from-palette($warn-palette, default); | ||
$error-color: mat.get-color-from-palette($error-palette, default); | ||
$success-color: mat.get-color-from-palette($success-palette, default); | ||
$info-color: mat.get-color-from-palette($info-palette, default); | ||
|
||
$primary-color-contrast: mat.get-color-from-palette( | ||
$primary-palette, | ||
default-contrast | ||
); | ||
$accent-color-contrast: mat.get-color-from-palette( | ||
$accent-palette, | ||
default-contrast | ||
); | ||
$warn-color-contrast: mat.get-color-from-palette( | ||
$warn-palette, | ||
default-contrast | ||
); | ||
$error-color-contrast: mat.get-color-from-palette( | ||
$error-palette, | ||
default-contrast | ||
); | ||
$success-color-contrast: mat.get-color-from-palette( | ||
$success-palette, | ||
default-contrast | ||
); | ||
$info-color-contrast: mat.get-color-from-palette( | ||
$info-palette, | ||
default-contrast | ||
); | ||
|
||
.alert { | ||
@include _variant('primary', $primary-color, $primary-color-contrast); | ||
@include _variant('accent', $accent-color, $accent-color-contrast); | ||
@include _variant('warn', $warn-color, $warn-color-contrast); | ||
@include _variant('error', $error-color, $error-color-contrast); | ||
@include _variant('success', $success-color, $success-color-contrast); | ||
@include _variant('info', $info-color, $info-color-contrast); | ||
} | ||
} | ||
|
||
@mixin typography($theme) { | ||
$typography-config: mat.get-typography-config($theme); | ||
} | ||
|
||
@mixin theme($theme) { | ||
$color-config: mat.get-color-config($theme); | ||
|
||
@if $color-config != null { | ||
@include color($theme); | ||
} | ||
|
||
$typography-config: mat.get-typography-config($theme); | ||
|
||
@if $typography-config != null { | ||
@include typography($theme); | ||
} | ||
} | ||
|
||
@mixin _variant($type, $color, $color-contrast) { | ||
&.#{$type} { | ||
background-color: color-mix(in srgb, $color 25%, transparent); | ||
color: $color; | ||
|
||
&.filled { | ||
background-color: $color; | ||
color: $color-contrast; | ||
} | ||
|
||
&.outlined { | ||
background-color: transparent; | ||
color: $color; | ||
border: 1px solid $color; | ||
} | ||
} | ||
} |
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
23 changes: 22 additions & 1 deletion
23
libs/usersrole-nx-app/preview/src/lib/components/alert/alert.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 |
---|---|---|
@@ -1 +1,22 @@ | ||
<p>alert works!</p> | ||
<div | ||
*ngFor="let alert of alerts" | ||
[@fade]="{ value: fade, params: { fadeTime: fadeTime } }" | ||
class="{{ cssClass(alert) }}" | ||
data-cy="alert" | ||
> | ||
<mat-icon *ngIf="alert.icon" class="icon" data-cy="icon"> | ||
{{ alert.icon }} | ||
</mat-icon> | ||
<div *ngIf="!alert.icon" data-cy="icon"></div> | ||
<div [innerHTML]="alert.message" class="message" data-cy="message"></div> | ||
<button | ||
(click)="removeAlert(alert)" | ||
*ngIf="alert.closeButton" | ||
data-cy="close-button" | ||
mat-icon-button | ||
type="button" | ||
> | ||
<mat-icon>close</mat-icon> | ||
</button> | ||
<div *ngIf="!alert.closeButton" data-cy="close-button"></div> | ||
</div> |
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,16 @@ | ||
.alert { | ||
display: grid; | ||
align-items: center; | ||
grid-template-columns: auto 1fr auto; | ||
padding: 4px; | ||
margin: 4px; | ||
border-radius: 4px; | ||
|
||
.icon { | ||
padding: 4px 0 4px 4px; | ||
} | ||
|
||
.message { | ||
padding: 8px; | ||
} | ||
} |
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
Oops, something went wrong.