File tree Expand file tree Collapse file tree 8 files changed +109
-0
lines changed Expand file tree Collapse file tree 8 files changed +109
-0
lines changed Original file line number Diff line number Diff line change 12
12
@use ' ./app/shared/footer/footer-theme' ;
13
13
@use ' ./app/shared/navbar/navbar-theme' ;
14
14
@use ' ./app/shared/table-of-contents/table-of-contents-theme' ;
15
+ @use ' ./app/shared/cookie-popup/cookie-popup-theme' ;
15
16
@use ' ./styles/api-theme' ;
16
17
@use ' ./styles/markdown-theme' ;
17
18
@use ' ./styles/svg-theme' ;
70
71
@include not-found-theme .theme ($theme );
71
72
@include navbar-theme .theme ($theme );
72
73
@include table-of-contents-theme .theme ($theme );
74
+ @include cookie-popup-theme .theme ($theme );
73
75
}
Original file line number Diff line number Diff line change @@ -7,6 +7,7 @@ import {RouterModule} from '@angular/router';
7
7
import { MaterialDocsApp } from './material-docs-app' ;
8
8
import { MATERIAL_DOCS_ROUTES } from './routes' ;
9
9
import { NavBarModule } from './shared/navbar' ;
10
+ import { CookiePopupModule } from './shared/cookie-popup/cookie-popup-module' ;
10
11
11
12
@NgModule ( {
12
13
imports : [
@@ -18,6 +19,7 @@ import {NavBarModule} from './shared/navbar';
18
19
relativeLinkResolution : 'corrected'
19
20
} ) ,
20
21
NavBarModule ,
22
+ CookiePopupModule ,
21
23
] ,
22
24
declarations : [ MaterialDocsApp ] ,
23
25
providers : [ { provide : LocationStrategy , useClass : PathLocationStrategy } ] ,
Original file line number Diff line number Diff line change
1
+ < app-cookie-popup > </ app-cookie-popup >
1
2
< app-navbar class ="mat-elevation-z6 "> </ app-navbar >
2
3
< router-outlet > </ router-outlet >
Original file line number Diff line number Diff line change
1
+ @use ' sass:map' ;
2
+ @use ' ~@angular/material' as mat ;
3
+
4
+ @mixin theme ($theme ) {
5
+ $primary : map .get ($theme , primary );
6
+ $accent : map .get ($theme , accent );
7
+ $warn : map .get ($theme , warn );
8
+ $background : map .get ($theme , background );
9
+ $foreground : map .get ($theme , foreground );
10
+ $is-dark-theme : map .get ($theme , is-dark );
11
+
12
+ app-cookie-popup {
13
+ .popup {
14
+ color : if ($is-dark-theme ,
15
+ map .get (map .get (mat .$grey-palette , contrast ), 50 ),
16
+ map .get (mat .$dark-theme-foreground-palette , secondary-text )
17
+ );
18
+ background : if ($is-dark-theme , map .get (mat .$grey-palette , 50 ), #252525 );
19
+ }
20
+ }
21
+ }
Original file line number Diff line number Diff line change
1
+ import { NgModule } from '@angular/core' ;
2
+ import { CommonModule } from '@angular/common' ;
3
+ import { MatButtonModule } from '@angular/material/button' ;
4
+ import { CookiePopup } from './cookie-popup' ;
5
+
6
+ @NgModule ( {
7
+ imports : [ CommonModule , MatButtonModule ] ,
8
+ declarations : [ CookiePopup ] ,
9
+ exports : [ CookiePopup ]
10
+ } )
11
+ export class CookiePopupModule { }
Original file line number Diff line number Diff line change
1
+ < div class ="popup " *ngIf ="!hasAccepted ">
2
+ This site uses cookies from Google to deliver its services and to analyze traffic.
3
+
4
+ < div class ="buttons ">
5
+ < a
6
+ href ="https://policies.google.com/technologies/cookies "
7
+ mat-button
8
+ color ="accent "
9
+ target ="_blank "
10
+ rel ="noopener "> More details</ a >
11
+ < button mat-button color ="accent " (click) ="accept() "> Ok, Got it</ button >
12
+ </ div >
13
+ </ div >
Original file line number Diff line number Diff line change
1
+ @use ' ~@angular/cdk' as cdk ;
2
+ @use ' ~@angular/material' as mat ;
3
+
4
+ $_inner-spacing : 16px ;
5
+
6
+ .popup {
7
+ @include mat .elevation (6 );
8
+ position : fixed ;
9
+ bottom : 0 ;
10
+ left : 0 ;
11
+ margin : 24px ;
12
+ max-width : 430px ;
13
+ z-index : cdk .$overlay-container-z-index + 1 ;
14
+ padding : $_inner-spacing $_inner-spacing $_inner-spacing / 2 ;
15
+ border-radius : 4px ;
16
+ }
17
+
18
+ .buttons {
19
+ display : flex ;
20
+ justify-content : flex-end ;
21
+ margin : $_inner-spacing $_inner-spacing / -2 0 0 ;
22
+
23
+ .mat-button {
24
+ text-transform : uppercase ;
25
+ }
26
+ }
Original file line number Diff line number Diff line change
1
+ import { ChangeDetectionStrategy , Component } from '@angular/core' ;
2
+
3
+ const STORAGE_KEY = 'docs-cookies' ;
4
+
5
+ @Component ( {
6
+ selector : 'app-cookie-popup' ,
7
+ templateUrl : './cookie-popup.html' ,
8
+ styleUrls : [ './cookie-popup.scss' ] ,
9
+ changeDetection : ChangeDetectionStrategy . OnPush
10
+ } )
11
+ export class CookiePopup {
12
+ /** Whether the user has accepted the cookie disclaimer. */
13
+ hasAccepted : boolean ;
14
+
15
+ constructor ( ) {
16
+ // Needs to be in a try/catch, because some browsers will
17
+ // throw when using `localStorage` in private mode.
18
+ try {
19
+ this . hasAccepted = localStorage . getItem ( STORAGE_KEY ) === 'true' ;
20
+ } catch {
21
+ this . hasAccepted = false ;
22
+ }
23
+ }
24
+
25
+ /** Accepts the cookie disclaimer. */
26
+ accept ( ) {
27
+ try {
28
+ localStorage . setItem ( STORAGE_KEY , 'true' ) ;
29
+ } catch { }
30
+
31
+ this . hasAccepted = true ;
32
+ }
33
+ }
You can’t perform that action at this time.
0 commit comments