feat: add product hunt banner (#2003)

This commit is contained in:
Vladislav Ahmetvaliev 2019-01-23 10:22:40 +03:00 committed by Sergey Andrievskiy
parent f719641e6d
commit 0cf96be6d8
13 changed files with 205 additions and 126 deletions

View file

@ -1,36 +1,40 @@
import { Component, HostBinding, Inject, OnDestroy, OnInit } from '@angular/core';
import { NB_WINDOW, NbThemeService } from '@nebular/theme';
import { takeWhile } from 'rxjs/operators';
/**
* @license
* Copyright Akveo. All Rights Reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*/
const HIDE_BANNER_KEY = 'HIDE_RELEASE_2_BANNER';
import { Component, HostBinding, Inject, OnInit } from '@angular/core';
import { NB_WINDOW } from '@nebular/theme';
const HIDE_BANNER_KEY = 'HIDE_PRODUCT_HUNT_BANNER';
@Component({
selector: 'ngx-release-banner',
template: `
<div class="heading-with-icon">
<img class="icon" [src]="getBellPath()" alt="bell">
<h1 class="banner-heading">Nebular 3.0 stable <br> with 30+ components is out!</h1>
<img class="icon" src="/assets/images/product-hunt-cat.png" alt="Product Hunt">
<div class="banner-content">
<h2 class="banner-heading">ngx-admin is on Product Hunt today!</h2>
<p class="cta">Please
<a class="cta-link"
href="https://www.producthunt.com/posts/ngx-admin"
target="_blank">
share
</a>
your feedback :)
</p>
</div>
<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://akveo.github.io/nebular?utm_source=ngx-admin-demo&utm_medium=banner"
target="_blank">
check out
</a>
and star our repo :)
</p>
`,
styleUrls: ['./banner.component.scss'],
})
export class BannerComponent implements OnInit, OnDestroy {
export class BannerComponent implements OnInit {
private alive = true;
storage: Storage;
isDarkTheme: boolean;
@HostBinding('attr.hidden')
isHidden: true | null = null;
@ -40,7 +44,6 @@ export class BannerComponent implements OnInit, OnDestroy {
constructor(
@Inject(NB_WINDOW) private window,
private themeService: NbThemeService,
) {}
ngOnInit() {
@ -49,11 +52,6 @@ export class BannerComponent implements OnInit, OnDestroy {
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() {
@ -62,12 +60,4 @@ export class BannerComponent implements OnInit, OnDestroy {
}
this.isHidden = true;
}
getBellPath() {
return `assets/images/bell${this.isDarkTheme ? '' : '-white'}.svg`;
}
ngOnDestroy() {
this.alive = false;
}
}