[angular-16-irish-monitor | DONE | CHANGED] cookie banner: parameterize cookie name

This commit is contained in:
argirok 2023-12-06 15:13:59 +02:00
parent 736546c0eb
commit 8c5c4923d3
2 changed files with 7 additions and 7 deletions

View File

@ -66,7 +66,7 @@ export type CookieLawTarget = '_blank' | '_self';
}) })
export class CookieLawComponent implements OnInit { export class CookieLawComponent implements OnInit {
public cookieLawSeen: boolean; public cookieLawSeen: boolean;
@Input() cookieName = "cookieLawSeen";
@Input('learnMore') @Input('learnMore')
get learnMore() { return this._learnMore; } get learnMore() { return this._learnMore; }
set learnMore(value: string) { set learnMore(value: string) {
@ -109,7 +109,7 @@ export class CookieLawComponent implements OnInit {
this.isSeenEvt = new EventEmitter<boolean>(); this.isSeenEvt = new EventEmitter<boolean>();
this.animation = 'topIn'; this.animation = 'topIn';
this._position = 'bottom'; this._position = 'bottom';
this.cookieLawSeen = this._service.seen(); this.cookieLawSeen = this._service.seen(this.cookieName);
} }
ngOnInit(): void { ngOnInit(): void {
@ -142,7 +142,7 @@ export class CookieLawComponent implements OnInit {
evt.preventDefault(); evt.preventDefault();
} }
this._service.storeCookie(); this._service.storeCookie(this.cookieName);
this.animation = this.position === 'top' ? 'topOut' : 'bottomOut'; this.animation = this.position === 'top' ? 'topOut' : 'bottomOut';
} }
} }

View File

@ -12,12 +12,12 @@ import { Injectable } from '@angular/core';
export class CookieLawService { export class CookieLawService {
seen(): boolean { seen(cookieName): boolean {
return this.cookieExists('cookieLawSeen'); return this.cookieExists(cookieName);
} }
storeCookie(): void { storeCookie(cookieName): void {
return this.setCookie('cookieLawSeen'); return this.setCookie('cookieName');
} }
/** /**