58 |
59 |
60 |
--------------------------------------------------------------------------------
/test/test.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | cookie-consent test
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
95 |
96 |
97 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # \
2 | [](https://www.webcomponents.org/element/Dabolus/cookie-consent)
3 | [](https://travis-ci.org/Dabolus/cookie-consent)
4 | [](https://github.com/Dabolus/cookie-consent)
5 |
6 | _[Demo and API docs](https://www.webcomponents.org/element/Dabolus/cookie-consent)_
7 |
8 | A great, simple and fully customizable material design cookie consent that automatically
9 | shows up only to the users subject to the cookie law (EU users).
10 |
11 | ## Features
12 | - Ready out of the box. Just include it and insert a ``
13 | in your web app and you are ready to go!
14 | - Fully customizable. It can be completely styled and it supports a lot of properties that
15 | allows you to easily change its default behavior.
16 | - Easily detect what the user does. The readonly `cookies-status` property can be binded to
17 | detect whether the user consent is `pending`, `accepted` or `rejected`. It also fires a
18 | `cookies-status-changed` event when the user responds, so you can wait for the user to
19 | accept or reject the cookies before doing something with their data.
20 | - Tested using the [web-component-tester](https://github.com/Polymer/web-component-tester)
21 |
22 | ## Installation
23 | ```
24 | bower install --save cookie-consent
25 | ```
26 |
27 | ## Usage
28 | #### Basic usage
29 | ```html
30 |
31 | ```
32 | #### Custom text, policy link and consent rejection
33 | ```html
34 |
38 |
39 | ```
40 |
41 | #### Full customization
42 | You can even set an empty text and then use a span with the class `.text` to insert anything
43 | you want (icons, etc.). The same can be done with the policy link. Just use the `.policy-link`
44 | class in an anchor tag inside the `cookie-consent`.
45 | ```html
46 |
47 |
48 | This website uses cookies
49 |
50 |
51 | Yay!
52 |
53 | ```
54 |
55 | _**Note:** the user response is saved by default in a permanent cookie.
56 | You can change this behavior by adding the `use-local-storage`
57 | or the `use-session-storage` properties._
58 |
59 | ## Styling
60 |
61 | The following custom properties and mixins are available for styling:
62 |
63 | | Custom property | Description | Default |
64 | | ------------------------------------ | ---------------------------------------------------------------- | ----------------------- |
65 | | `--cookie-consent-background-color` | The background color of the cookie consent | `#323232` |
66 | | `--cookie-consent-text-color` | The color of text in the cookie consent | `#f1f1f1` |
67 | | `--cookie-consent-policy-link-color` | The color of the link to the cookie policy | `--light-accent-color` |
68 | | `--cookie-consent-reject-text-color` | The main color of the button to reject the cookie policy | `--disabled-text-color` |
69 | | `--cookie-consent-reject-background` | The background of the button to reject the cookie policy | `transparent` |
70 | | `--cookie-consent-reject-ink-color` | The color of the ink displayed when the reject button is pressed | `--disabled-text-color` |
71 | | `--cookie-consent-accept-text-color` | The main color of the button to accept the cookie policy | `--accent-color` |
72 | | `--cookie-consent-accept-background` | The background of the button to accept the cookie policy | `transparent` |
73 | | `--cookie-consent-accept-ink-color` | The color of the ink displayed when the accept button is pressed | `--accent-color` |
74 | | `--cookie-consent-accept-button` | Mixin applied to the accept button | `{}` |
75 | | `--cookie-consent-reject-button` | Mixin applied to the reject button | `{}` |
76 | | `--cookie-consent-buttons` | Mixin applied to both the accept and reject buttons | `{}` |
77 | | `--cookie-consent-policy-link` | Mixin applied to the policy link | `{}` |
78 | | `--cookie-consent-text` | Mixin applied to the cookie consent text | `{}` |
79 | | `--cookie-consent-toast` | Mixin applied to the cookie consent toast | `{}` |
80 | | `--cookie-consent` | Mixin applied to the cookie consent | `{}` |
81 |
82 | This element uses `paper-toast` to display the consent. `paper-toast` applies the mixin `--paper-font-common-base` but does not import `paper-styles/typography.html`.
83 | In order to apply the `Roboto` font to this element, make sure you've imported `paper-styles/typography.html`.
84 |
--------------------------------------------------------------------------------
/cookie-consent.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
17 |
18 |
19 |
20 |
70 |
71 |
75 |
76 |
77 |