Skip to content

Commit

Permalink
feat: add cookie disclaimer banner (#68)
Browse files Browse the repository at this point in the history
* feat: add cookie disclaimer

* fix: fix mistakes in cookie disclaimer.

* fix: improve cookie banner grammar

---------

Co-authored-by: Daniel Jancar <[email protected]>
  • Loading branch information
Gr1ll and danieljancar authored Aug 13, 2024
1 parent 171a986 commit d2138b0
Show file tree
Hide file tree
Showing 8 changed files with 83 additions and 7 deletions.
1 change: 1 addition & 0 deletions apps/frontend/src/app/app.component.html
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<app-navbar />
<router-outlet />
<div class="mb-20"></div>
<app-disclaimer />
3 changes: 2 additions & 1 deletion apps/frontend/src/app/app.component.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import { Component } from '@angular/core'
import { RouterModule } from '@angular/router'
import { NavbarComponent } from './shared/navigation/navbar/navbar.component'
import { DisclaimerComponent } from './shared/navigation/disclaimer/disclaimer.component'

@Component({
standalone: true,
imports: [RouterModule, NavbarComponent],
imports: [RouterModule, NavbarComponent, DisclaimerComponent],
selector: 'app-root',
templateUrl: './app.component.html',
styleUrl: './app.component.scss',
Expand Down
11 changes: 10 additions & 1 deletion apps/frontend/src/app/features/home/home.component.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { ComponentFixture, TestBed } from '@angular/core/testing'
import { ComponentFixture, inject, TestBed } from '@angular/core/testing'
import { HomeComponent } from './home.component'
import { Router } from '@angular/router'

describe('HomeComponent', () => {
let component: HomeComponent
Expand All @@ -18,4 +19,12 @@ describe('HomeComponent', () => {
it('should create', () => {
expect(component).toBeTruthy()
})

test('should search vote', inject([Router], (mockRouter: Router) => {
const spyRouter = spyOn(mockRouter, 'navigate').and.stub()

component.voteId.setValue('123')
component.searchVote()
expect(spyRouter.calls.first().args[0]).toContain('voting' && '123')
}))
})
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
@if (!hasAcceptedCookies()) {
<div class="pointer-events-none fixed inset-x-0 bottom-0 px-6 pb-6">
<div
class="pointer-events-auto ml-auto max-w-xl rounded-xl bg-white p-6 shadow-lg ring-1 ring-gray-900/10"
>
<p class="text-sm leading-6 text-gray-900">
We use cookies to enhance your experience. Any data, such as your wallet
address, is only shared between you and the Stellar Network. By using our
site, you consent to this.
</p>
<div class="mt-4 flex items-center gap-x-5">
<button
(click)="acceptCookies()"
type="button"
class="rounded-md bg-gray-900 px-3 py-2 text-sm font-semibold text-white shadow-sm hover:bg-gray-700 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-gray-900"
>
Accept
</button>
</div>
</div>
</div>
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { ComponentFixture, TestBed } from '@angular/core/testing'

import { DisclaimerComponent } from './disclaimer.component'

describe('DisclaimerComponent', () => {
let component: DisclaimerComponent
let fixture: ComponentFixture<DisclaimerComponent>

beforeEach(async () => {
await TestBed.configureTestingModule({
imports: [DisclaimerComponent],
}).compileComponents()

fixture = TestBed.createComponent(DisclaimerComponent)
component = fixture.componentInstance
fixture.detectChanges()
})

it('should create', () => {
expect(component).toBeTruthy()
})
})
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { Component } from '@angular/core'
import { CookieService } from 'ngx-cookie-service'
import { RouterLink } from '@angular/router'

@Component({
selector: 'app-disclaimer',
standalone: true,
imports: [RouterLink],
templateUrl: './disclaimer.component.html',
styleUrl: './disclaimer.component.css',
})
export class DisclaimerComponent {
constructor(private cookieService: CookieService) {}
acceptCookies() {
this.cookieService.set('disclaimer', 'accepted', 365)
}

hasAcceptedCookies() {
return this.cookieService.check('disclaimer')
}
}
10 changes: 5 additions & 5 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit d2138b0

Please sign in to comment.