From f69123f9456a6dfb8dc5e6b0432ee7f49a0effe0 Mon Sep 17 00:00:00 2001 From: Andrea Zornada Date: Tue, 29 May 2018 09:40:32 +0100 Subject: [PATCH] :memo: Including readme in npm project --- projects/angular2-cookie-law/README.md | 358 ++++++++++++++++++++++ projects/angular2-cookie-law/package.json | 2 +- 2 files changed, 359 insertions(+), 1 deletion(-) create mode 100644 projects/angular2-cookie-law/README.md diff --git a/projects/angular2-cookie-law/README.md b/projects/angular2-cookie-law/README.md new file mode 100644 index 0000000..42c970c --- /dev/null +++ b/projects/angular2-cookie-law/README.md @@ -0,0 +1,358 @@ +[![Build Status](https://travis-ci.org/andreasonny83/angular2-cookie-law.svg?branch=master)](https://travis-ci.org/andreasonny83/angular2-cookie-law) +[![npm version](https://badge.fury.io/js/angular2-cookie-law.svg)](https://badge.fury.io/js/angular2-cookie-law) +[![npm](https://img.shields.io/npm/dt/angular2-cookie-law.svg)](https://www.npmjs.com/package/angular2-cookie-law) +[![Coverage Status](https://coveralls.io/repos/github/andreasonny83/angular2-cookie-law/badge.svg)](https://coveralls.io/github/andreasonny83/angular2-cookie-law) +[![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg)](http://commitizen.github.io/cz-cli/) +[![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/semantic-release/semantic-release) + +# Angular2 Cookie Law + +> Angular2+ component that provides a banner to inform users about the cookie law + +Angular2 Cookie Law is an HTML `` tag enhanced with styling and animation. + +**This documentation is for the latest version of `angular2-cookie-law` (6.x.x).** + +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](https://github.com/andreasonny83/angular2-cookie-law/tree/v1.4.0). + +**Live DEMO:** + +* [Angular2 Cookie Law with Angular6](https://stackblitz.com/edit/angular2-cookie-law) + +## Table of contents + +* [Installation](#installation) +* [Setup](#setup) +* [Usage](#usage) +* [Example](#example) +* [Demo App](#demo-app) +* [Options](#options) + * [Attributes](#attributes) + * [Properties](#properties) + * [Events](#events) + * [Methods](#methods) +* [Custom template](#custom-template) +* [Contributing](#contributing) +* [Changelog](#changelog) +* [License](#license) + +## Installation + +1. Install the component using `npm` +1. 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. + + ```bash + # To get the latest stable version and update package.json file: + $ npm install angular2-cookie-law@6 @angular/animations --save + ``` + + or `yarn` with: + + ```bash + $ 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): + +```js +// 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: + +```js +// app.component.ts +import { Component } from '@angular/core'; + +@Component({ + selector: 'app', + template: ` + + ` +}) +export class AppComponent { } +``` + +## Example + +```js +// app.component.ts +import { Component } from '@angular/core'; + +@Component({ + selector: 'app', + template: ` +

+ Hello World! +

+ + + ` +}) +export class AppComponent { } +``` + +###### Output + +![cookie-law example](http://i.imgur.com/W9LUdwy.png) + +# 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 + +```sh +$ git clone git@github.com:andreasonny83/angular2-cookie-law.git +``` + +Then install all the Node dependencies (Node v8 or later is required). + +```sh +$ npm install +``` + +And run the project with: + +```bash +$ npm start +``` + +Open your browser to [http://localhost:4200/](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 + +```html + +``` + +![output with link](http://i.imgur.com/0nvb6sP.png) + +### awsomeCloseIcon + +Font Awsome is required in your header for this feature to work. + +```html + +``` + +| 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 + +```html + +``` + +### target + +| Type | Default value | +| --- | --- | +| string | _blank | + +Set to `_self` if you want the external link not to be opened in a new tab. + +###### Example + +```html + +``` + +### 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 + +```html + +``` + +### 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 + +```html + +``` + +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 + +```html +I'm gonna expire in 1 week! +``` + +## Properties + +| Name | Type | Description | +| --- | --- | --- | +| cookieLawSeen | boolean | true if the user has already dismissed the banner | + +###### Example + +```js +@Component({ + selector: 'demo-app', + template: ` +

Cookie law has been dismissed

+ + + + `, +}) +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 + +```js +@Component({ + selector: 'demo-app', + template: ` +

Cookie law has been dismissed

+ + + `, +}) +export class AppComponent { + private cookieLawSeen: boolean; + + public seen(evt: any) { + this.cookieLawSeen = evt; + } +} +``` + +## Methods + +| Name | Description | +| --- | --- | +| dismiss | Dismiss a banner | + +###### Example + +```js +@Component({ + selector: 'demo-app', + template: ` + + + + `, +}) +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: +```html + + This website contains cookie. + Read more + +``` + +## 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! +1. Create your feature branch: `git checkout -b my-new-feature` +1. Add your changes: `git add .` +1. Commit your changes: `npm run commit` +1. Push to the branch: `git push origin my-new-feature` +1. Submit a pull request :sunglasses: + +## Changelog + +Changelog available [here](https://github.com/andreasonny83/angular2-cookie-law/releases) + +## License + +[MIT License](https://github.com/andreasonny83/angular2-cookie-law/blob/master/LICENSE) © Andrea SonnY diff --git a/projects/angular2-cookie-law/package.json b/projects/angular2-cookie-law/package.json index 3866151..a587bbe 100644 --- a/projects/angular2-cookie-law/package.json +++ b/projects/angular2-cookie-law/package.json @@ -22,7 +22,7 @@ "url": "https://github.com/andreasonny83/angular2-cookie-law/issues" }, "homepage": "https://github.com/andreasonny83/angular2-cookie-law#readme", - "version": "6.0.1", + "version": "6.0.2", "peerDependencies": { "@angular/common": "^6.0.0-rc.0 || ^6.0.0", "@angular/core": "^6.0.0-rc.0 || ^6.0.0"