All Projects → andreasonny83 → angular2-cookie-law

andreasonny83 / angular2-cookie-law

Licence: MIT License
Angular2+ component that provides a banner to inform users about cookie law

Programming Languages

typescript
32286 projects
javascript
184084 projects - #8 most used programming language
HTML
75241 projects
CSS
56736 projects

Projects that are alternatives of or similar to angular2-cookie-law

awesome-angular
💖 A list of awesome Angular (2️⃣➕) resources
Stars: ✭ 61 (+60.53%)
Mutual labels:  angular2, ng2, angular2-component, angular-components, angular2-components
Awesome Angular Components
Catalog of Angular 2+ Components & Libraries
Stars: ✭ 3,185 (+8281.58%)
Mutual labels:  ng2, angular2-component, angular-components, angular2-components
Angular Prest
pREST component for Angular
Stars: ✭ 16 (-57.89%)
Mutual labels:  angularjs, angular2, angular4, angular-components
Angular5 Seed
Angular5 Seed for Application
Stars: ✭ 222 (+484.21%)
Mutual labels:  angularjs, angular2, angular4, angular6
Ngautocomplete
Light-weight autocomplete component for Angular.
Stars: ✭ 52 (+36.84%)
Mutual labels:  angularjs, angular2, ng2, angular4
Ngx Quill Editor
🍡@quilljs editor component for @angular
Stars: ✭ 234 (+515.79%)
Mutual labels:  angularjs, ng2, angular4, angular-components
Angular-Firebase-Sortable-Table
Angular Firebase Sortable Table is a module that makes tables creation with firebase an easy task.
Stars: ✭ 28 (-26.32%)
Mutual labels:  angularjs, angular2, angular4, angular-components
Nebular
💥 Customizable Angular UI Library based on Eva Design System 🌚✨Dark Mode
Stars: ✭ 7,368 (+19289.47%)
Mutual labels:  angular2, angular4, angular-components, angular6
Truly Ui
Truly-UI - Web Angular UI Components for Desktop Applications (Electron, NW, APP JS)
Stars: ✭ 195 (+413.16%)
Mutual labels:  angular2, ng2, angular4, angular6
Ng Simple Slideshow
A simple, responsive slideshow for Angular 4+.
Stars: ✭ 119 (+213.16%)
Mutual labels:  angular2, angular4, angular-components, angular6
Ng Select
⭐ Native angular select component
Stars: ✭ 2,781 (+7218.42%)
Mutual labels:  angular2, angular4, angular-components, angular6
Angular4-seed
Angular 4 Seed for Angular Forms
Stars: ✭ 37 (-2.63%)
Mutual labels:  angularjs, angular2, angular4, angular-components
Angular2
Angular 2 Seed
Stars: ✭ 75 (+97.37%)
Mutual labels:  angularjs, angular2, angular4
Codebe
CodeBe(码币)是一个是使用angular2整合各种插件的项目,包括(layer,bootstrap-table,markdown编辑器,highcharts,ckeditor,高德地图,fullcalendar 等等)。如果你有什么想要集成的插件,请告诉我,我来加进去。(请给我加个星,谢谢。)
Stars: ✭ 307 (+707.89%)
Mutual labels:  angularjs, angular2, angular6
Fef
The Front End Framework is a Thomson Reuters Tax and Accounting project to create a re-usable library for creating rich HTML based applications. The end goal is to assemble the publicly available libraries into a reference application with documentation along with best practice architecture.
Stars: ✭ 96 (+152.63%)
Mutual labels:  angularjs, angular2, angular-components
Paperadmin
A flat admin dashboard using Angular JS 2/4
Stars: ✭ 80 (+110.53%)
Mutual labels:  angularjs, angular2, angular4
Fusebox Angular Universal Starter
Angular Universal seed project featuring Server-Side Rendering, @fuse-box bundling, material, firebase, Jest, Nightmare, and more
Stars: ✭ 132 (+247.37%)
Mutual labels:  angularjs, angular2, angular4
Ng Drag Drop
Drag & Drop for Angular - based on HTML5 with no external dependencies. 🎉
Stars: ✭ 233 (+513.16%)
Mutual labels:  angular2, angular4, angular-components
angular2-signature-pad
Signature pad component for Angular 2.x and above.
Stars: ✭ 17 (-55.26%)
Mutual labels:  angular2, ng2, angular4
angular-rollbar-source-maps
Angular 2+ implementation to upload sourcemaps to Rollbar
Stars: ✭ 17 (-55.26%)
Mutual labels:  angular2, angular4, angular6

Maintainers Wanted

This project was originally intended to be only consumed by my NG applications. I'm now working full-time on React related project only and it's been a while since I did look into Angular related code.

However, since there are now several people relying on this small and simple package, I'm looking for volunteers to actiely look after this project. If anyone is interested, please reply into this ticket.

Build Status npm version npm Coverage Status Commitizen friendly semantic-release

Angular2 Cookie Law

Angular2+ component that provides a banner to inform users about the cookie law now with Angular Universal support

Angular2 Cookie Law is an HTML <cookie-law> tag enhanced with styling and animation.

This documentation is for the latest version of angular2-cookie-law (>=6.x.x).

angular2-cookie-law@7 supports bot Angular v6 and v7

If you're using an older version of Angular (<6), please install angular2-cookie-law in version 1 with npm i --save angular2-cookie-law@1 and check out the documentation available here.

Live DEMO:

Table of contents

Installation

  1. Install the component using npm
  2. angular2-cookie-law depends on the Angular animations module in order to be able to do more advanced transitions. If you want these animations to work in your app, you have to install the @angular/animations module and include the BrowserAnimationsModule in your app.
# To get the latest stable version and update package.json file:
$ npm install angular2-cookie-law@6 @angular/animations --save

or yarn with:

$ yarn add angular2-cookie-law @angular/animations

Setup

angular2-cookie-law class is an Angular module therefore, it needs to be registered in the modules array (encouraged way):

// app.module.ts
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { CookieLawModule } from 'angular2-cookie-law';
import { AppComponent } from './app.component';

@NgModule({
  declarations: [ AppComponent ],
  imports: [
    BrowserModule,
    BrowserAnimationsModule, // BrowserAnimationsModule is required
    CookieLawModule // import Angular's CookieLaw modules
  ],
  bootstrap: [ AppComponent ]
})
export class AppModule { }

Usage

Use the component anywhere around your application:

// app.component.ts
import { Component } from '@angular/core';

@Component({
  selector: 'app',
  template: `
    <cookie-law></cookie-law>
  `
})
export class AppComponent  { }

Example

// app.component.ts
import { Component } from '@angular/core';

@Component({
  selector: 'app',
  template: `
    <h1>
      Hello World!
    </h1>

    <cookie-law></cookie-law>
  `
})
export class AppComponent  { }
Output

cookie-law example

Demo App

Have a look at the demo app available in this repository for a real Angular application using the angular2-Cookie-Law library. Clone this repo on you machine with

$ git clone [email protected]:andreasonny83/angular2-cookie-law.git

Then install all the Node dependencies (Node v8 or later is required).

$ npm install

And run the project with:

$ npm start

Open your browser to http://localhost:4200/ to see the application running.

Options

Attributes

learnMore

Type Default value
string null

If set to a valid absolute or relative URL, it will render an extra 'learn more' link pointing to the link.

Example
<cookie-law learnMore="/learn-more"></cookie-law>

output with link

awsomeCloseIcon

Font Awsome is required in your header for this feature to work.

<script defer src="https://use.fontawesome.com/releases/v5.0.6/js/all.js"></script>
Type Default value
string null

If set to a Font awsome Icon e.g. "fa-window-close" it will replace the standard SVG with the Font awsome Icon.

Example
<cookie-law awsomeCloseIcon="fa-window-close"></cookie-law>

target

Type Default value
string _blank

Set to _self if you want the external link not to be opened in a new tab.

Example
<cookie-law learnMore="/learn-more" target="_self"></cookie-law>

position

Type Default value
string "bottom"

Allows you to decide where in the page, the banner will be rendered. Possible values are: "bottom" and "top".

Example
<cookie-law position="top" learnMore="/learn-more" target="_self"></cookie-law>

name

Type Default value
string "cookieLawSeen"

Allows you to decide which name will be used for storing the cookie in the client's browser.

Example
<cookie-law name="myShinyCookieLaw"></cookie-law>

The previous example will generate a myShinyCookieLaw=true as soon as the user dismiss the banner.

expiration

Type Default value Description
number - Set a the cookie expiration time (in days)
Example
<cookie-law name="myShinyCookieLaw" expiration="7">I'm gonna expire in 1 week!</cookie-law>

Properties

Name Type Description
cookieLawSeen boolean true if the user has already dismissed the banner
Example
@Component({
  selector: 'demo-app',
  template: `
    <h3 *ngIf="cookieLawSeen">Cookie law has been dismissed</h3>

    <cookie-law #cookieLaw></cookie-law>

  `,
})
export class AppComponent implements OnInit {
  @ViewChild('cookieLaw')
  private cookieLawEl: any;

  private cookieLawSeen: boolean;

  ngOnInit() {
    this.cookieLawSeen = this.cookieLawEl.cookieLawSeen;
  }
}

Events

Name Type Description
isSeen boolean Triggered when the user dismiss the banner
Example
@Component({
  selector: 'demo-app',
  template: `
    <h3 *ngIf="cookieLawSeen">Cookie law has been dismissed</h3>

    <cookie-law (isSeen)="seen($event)"></cookie-law>
  `,
})
export class AppComponent {
  private cookieLawSeen: boolean;

  public seen(evt: any) {
    this.cookieLawSeen = evt;
  }
}

Methods

Name Description
dismiss Dismiss a banner
Example
@Component({
  selector: 'demo-app',
  template: `
  <button type="button" (click)="dismiss()">Dismiss Modal</button>
  <cookie-law #cookieLaw></cookie-law>

  `,
})
export class AppComponent implements OnInit {
  @ViewChild('cookieLaw')
  private cookieLawEl: any;

  public dismiss(): void {
    this.cookieLawEl.dismiss();
  }
}

Custom template

It is possible to overwrite our default cookie policy law text with a custom template. Just put your favorite html content between the component like in the following example:

<cookie-law position="top">
  This website contains cookie.
  <a href="#/cookie-policy">Read more</a>
</cookie-law>

Contributing

This package is using the AngularJS commit messages as default way to contribute with Commitizen node package integrated in this repository.

  1. Fork it!
  2. Create your feature branch: git checkout -b my-new-feature
  3. Add your changes: git add .
  4. Commit your changes: npm run commit
  5. Push to the branch: git push origin my-new-feature
  6. Submit a pull request 😎

Changelog

Changelog available here

License

MIT License © Andrea SonnY

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].