This repository was archived by the owner on Dec 18, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 395
feat: add cookie popup #988
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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,2 +1,3 @@ | ||
<app-cookie-popup></app-cookie-popup> | ||
<app-navbar class="mat-elevation-z6"></app-navbar> | ||
<router-outlet></router-outlet> |
This file contains hidden or 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,21 @@ | ||
@use 'sass:map'; | ||
@use '~@angular/material' as mat; | ||
|
||
@mixin theme($theme) { | ||
$primary: map.get($theme, primary); | ||
$accent: map.get($theme, accent); | ||
$warn: map.get($theme, warn); | ||
$background: map.get($theme, background); | ||
$foreground: map.get($theme, foreground); | ||
$is-dark-theme: map.get($theme, is-dark); | ||
|
||
app-cookie-popup { | ||
.popup { | ||
color: if($is-dark-theme, | ||
map.get(map.get(mat.$grey-palette, contrast), 50), | ||
map.get(mat.$dark-theme-foreground-palette, secondary-text) | ||
); | ||
background: if($is-dark-theme, map.get(mat.$grey-palette, 50), #252525); | ||
} | ||
} | ||
} |
This file contains hidden or 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,11 @@ | ||
import {NgModule} from '@angular/core'; | ||
import {CommonModule} from '@angular/common'; | ||
import {MatButtonModule} from '@angular/material/button'; | ||
import {CookiePopup} from './cookie-popup'; | ||
|
||
@NgModule({ | ||
imports: [CommonModule, MatButtonModule], | ||
declarations: [CookiePopup], | ||
exports: [CookiePopup] | ||
}) | ||
export class CookiePopupModule {} |
This file contains hidden or 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,13 @@ | ||
<div class="popup" *ngIf="!hasAccepted"> | ||
This site uses cookies from Google to deliver its services and to analyze traffic. | ||
|
||
<div class="buttons"> | ||
<a | ||
href="https://policies.google.com/technologies/cookies" | ||
mat-button | ||
color="accent" | ||
target="_blank" | ||
rel="noopener">More details</a> | ||
<button mat-button color="accent" (click)="accept()">Ok, Got it</button> | ||
</div> | ||
</div> |
This file contains hidden or 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,26 @@ | ||
@use '~@angular/cdk' as cdk; | ||
@use '~@angular/material' as mat; | ||
|
||
$_inner-spacing: 16px; | ||
|
||
.popup { | ||
@include mat.elevation(6); | ||
position: fixed; | ||
bottom: 0; | ||
left: 0; | ||
margin: 24px; | ||
max-width: 430px; | ||
z-index: cdk.$overlay-container-z-index + 1; | ||
padding: $_inner-spacing $_inner-spacing $_inner-spacing / 2; | ||
border-radius: 4px; | ||
} | ||
|
||
.buttons { | ||
display: flex; | ||
justify-content: flex-end; | ||
margin: $_inner-spacing $_inner-spacing / -2 0 0; | ||
|
||
.mat-button { | ||
text-transform: uppercase; | ||
} | ||
} |
This file contains hidden or 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,33 @@ | ||
import {ChangeDetectionStrategy, Component} from '@angular/core'; | ||
|
||
const STORAGE_KEY = 'docs-cookies'; | ||
|
||
@Component({ | ||
selector: 'app-cookie-popup', | ||
templateUrl: './cookie-popup.html', | ||
styleUrls: ['./cookie-popup.scss'], | ||
changeDetection: ChangeDetectionStrategy.OnPush | ||
}) | ||
export class CookiePopup { | ||
/** Whether the user has accepted the cookie disclaimer. */ | ||
hasAccepted: boolean; | ||
|
||
constructor() { | ||
// Needs to be in a try/catch, because some browsers will | ||
// throw when using `localStorage` in private mode. | ||
try { | ||
this.hasAccepted = localStorage.getItem(STORAGE_KEY) === 'true'; | ||
} catch { | ||
this.hasAccepted = false; | ||
} | ||
} | ||
|
||
/** Accepts the cookie disclaimer. */ | ||
accept() { | ||
try { | ||
localStorage.setItem(STORAGE_KEY, 'true'); | ||
} catch {} | ||
|
||
this.hasAccepted = true; | ||
} | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.