mirror of
https://github.com/akveo/ngx-admin.git
synced 2026-01-16 22:45:30 +01:00
feat: add release 2.0 banner
This commit is contained in:
parent
93d800b676
commit
2f43a538df
9 changed files with 235 additions and 1 deletions
|
|
@ -0,0 +1,26 @@
|
|||
@import '../../styles/themes';
|
||||
|
||||
@mixin ngx-release-banner-component {
|
||||
ngx-release-banner {
|
||||
background-color: nb-theme(release-banner-bg);
|
||||
color: nb-theme(release-banner-fg);
|
||||
|
||||
.heading-with-icon {
|
||||
border-bottom-color: nb-theme(release-banner-separator);
|
||||
}
|
||||
|
||||
.banner-heading,
|
||||
.close-button {
|
||||
color: nb-theme(release-banner-fg);
|
||||
}
|
||||
|
||||
.cta {
|
||||
color: nb-theme(release-banner-cta);
|
||||
}
|
||||
|
||||
.cta-link {
|
||||
background: nb-theme(release-banner-fg);
|
||||
color: nb-theme(release-banner-bg);
|
||||
}
|
||||
}
|
||||
}
|
||||
58
src/app/@theme/components/banner/banner.component.scss
Normal file
58
src/app/@theme/components/banner/banner.component.scss
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
@import '../../styles/themes';
|
||||
|
||||
:host {
|
||||
position: fixed;
|
||||
@include nb-ltr(right, 1.5rem);
|
||||
@include nb-rtl(left, 1.5rem);
|
||||
top: 8vh;
|
||||
border-radius: 5px;
|
||||
box-shadow: 0 5px 12px 0 rgba(0, 32, 128, 0.14);
|
||||
z-index: 99999999;
|
||||
|
||||
.heading-with-icon {
|
||||
border-bottom-width: 1px;
|
||||
border-bottom-style: solid;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.icon {
|
||||
height: auto;
|
||||
width: 4rem;
|
||||
margin: 0 1.625rem;
|
||||
}
|
||||
|
||||
.banner-heading {
|
||||
font-size: 1.5rem;
|
||||
line-height: 1.5;
|
||||
font-weight: 600;
|
||||
margin: 1.625rem 0;
|
||||
}
|
||||
|
||||
.close-button {
|
||||
background: none;
|
||||
border: none;
|
||||
cursor: pointer;
|
||||
margin-bottom: auto;
|
||||
padding: 0.625rem;
|
||||
}
|
||||
|
||||
.nb-close {
|
||||
font-size: 1.5rem;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.cta {
|
||||
margin: 0;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.cta-link {
|
||||
border-radius: 1.8px;
|
||||
display: inline-block;
|
||||
padding: 0.5rem 1rem;
|
||||
margin: 0.725rem 0.8rem;
|
||||
text-transform: uppercase;
|
||||
font-weight: 600;
|
||||
}
|
||||
}
|
||||
67
src/app/@theme/components/banner/banner.component.ts
Normal file
67
src/app/@theme/components/banner/banner.component.ts
Normal file
|
|
@ -0,0 +1,67 @@
|
|||
import { Component, HostBinding, Inject, OnDestroy, OnInit } from '@angular/core';
|
||||
import { NB_WINDOW, NbThemeService } from '@nebular/theme';
|
||||
import { takeWhile } from 'rxjs/operators';
|
||||
|
||||
const HIDE_BANNER_KEY = 'HIDE_RELEASE_2_BANNER';
|
||||
|
||||
@Component({
|
||||
selector: 'ngx-release-banner',
|
||||
template: `
|
||||
<div class="heading-with-icon">
|
||||
<img class="icon" [src]="getBellPath()" alt="bell">
|
||||
<h1 class="banner-heading">Nebular 2.0 stable <br> with 30+ components is out!</h1>
|
||||
<button class="close-button" aria-label="close" (click)="closeBanner()">
|
||||
<span class="nb-close"></span>
|
||||
</button>
|
||||
</div>
|
||||
<p class="cta">
|
||||
Don't forget to <a class="cta-link" href="https://github.com/akveo/nebular">check out</a> and star our repo :)
|
||||
</p>
|
||||
`,
|
||||
styleUrls: ['./banner.component.scss'],
|
||||
})
|
||||
export class BannerComponent implements OnInit, OnDestroy {
|
||||
|
||||
private alive = true;
|
||||
storage: Storage;
|
||||
isDarkTheme: boolean;
|
||||
|
||||
@HostBinding('attr.hidden')
|
||||
isHidden: true | null = null;
|
||||
|
||||
@HostBinding('attr.dir')
|
||||
dir = 'ltr';
|
||||
|
||||
constructor(
|
||||
@Inject(NB_WINDOW) private window,
|
||||
private themeService: NbThemeService,
|
||||
) {}
|
||||
|
||||
ngOnInit() {
|
||||
this.storage = this.window.localStorage;
|
||||
|
||||
this.isHidden = this.storage && this.storage.getItem(HIDE_BANNER_KEY)
|
||||
? true
|
||||
: null;
|
||||
|
||||
this.isDarkTheme = this.themeService.currentTheme === 'cosmic';
|
||||
this.themeService.onThemeChange()
|
||||
.pipe(takeWhile(() => this.alive))
|
||||
.subscribe(({ name }) => this.isDarkTheme = name === 'cosmic');
|
||||
}
|
||||
|
||||
closeBanner() {
|
||||
if (this.storage) {
|
||||
this.storage.setItem(HIDE_BANNER_KEY, 'true');
|
||||
}
|
||||
this.isHidden = true;
|
||||
}
|
||||
|
||||
getBellPath() {
|
||||
return `assets/images/bell${this.isDarkTheme ? '' : '-white'}.svg`;
|
||||
}
|
||||
|
||||
ngOnDestroy() {
|
||||
this.alive = false;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue