Skip to content

Commit

Permalink
fix: cookies consent banner animation handling for both "accept" buttons
Browse files Browse the repository at this point in the history
* was missing for "accept only essential"
  • Loading branch information
shauke committed Sep 6, 2023
1 parent 94b25d5 commit 0a2a380
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
@@ -1,7 +1,7 @@
<div
*ngIf="showBanner"
[@bottomOut]="transitionBanner"
(@bottomOut.done)="acceptAllAnimationDone($event)"
(@bottomOut.done)="setCookiesConsent($event)"
class="cookies-banner"
>
<div [ishServerHtml]="'cookies.banner.text' | translate"></div>
Expand Down
Expand Up @@ -19,6 +19,7 @@ import { CookiesService } from 'ish-core/utils/cookies/cookies.service';
export class CookiesBannerComponent implements OnInit {
showBanner = false;
transitionBanner: string = undefined;
cookiesConsentFor: string[] = undefined;

constructor(private transferState: TransferState, private cookiesService: CookiesService) {}

Expand Down Expand Up @@ -47,13 +48,18 @@ export class CookiesBannerComponent implements OnInit {
this.transitionBanner = 'bottom-out';
}

acceptAllAnimationDone(event: AnimationEvent): void {
if (event.toState === 'bottom-out') {
this.cookiesService.setCookiesConsentForAll();
}
acceptOnlyRequired() {
this.transitionBanner = 'bottom-out';
this.cookiesConsentFor = ['required'];
}

acceptOnlyRequired() {
this.cookiesService.setCookiesConsentFor(['required']);
setCookiesConsent(event: AnimationEvent): void {
if (event.toState === this.transitionBanner) {
if (this.cookiesConsentFor === undefined) {
this.cookiesService.setCookiesConsentForAll();
} else {
this.cookiesService.setCookiesConsentFor(this.cookiesConsentFor);
}
}
}
}

0 comments on commit 0a2a380

Please sign in to comment.