├── .editorconfig
├── .eslintignore
├── .github
├── CONTRIBUTING.md
├── ISSUE_TEMPLATE.md
├── PULL_REQUEST_TEMPLATE.md
└── lock.yml
├── .gitignore
├── .ncurc.js
├── .npmignore
├── .npmrc
├── .travis.yml
├── CHANGELOG.md
├── CODE_OF_CONDUCT.md
├── LICENSE.md
├── README.md
├── babel.config.js
├── babel.ext.json
├── declination.json
├── docs
├── commands.md
├── contribute.md
├── installation.md
├── introduction.md
├── js
│ └── jsdoc.md
├── prerequisite.md
└── release.md
├── internals
└── testing
│ └── test-bundler.js
├── package.json
├── rollup.config.js
├── sonar-project.properties
├── src
├── CookieBot.js
├── CookieBot.md
├── CookieBot.native.js
├── index.js
└── tests
│ └── index.test.js
├── styleguide.config.js
└── styleguide
├── jsdoc.sh
├── prepare.sh
└── styleguide.ext.json
/.editorconfig:
--------------------------------------------------------------------------------
1 | root = true
2 |
3 | [*]
4 | charset = utf-8
5 | indent_size = 2
6 | end_of_line = lf
7 | indent_style = space
8 | insert_final_newline = true
9 | trim_trailing_whitespace = true
10 |
--------------------------------------------------------------------------------
/.eslintignore:
--------------------------------------------------------------------------------
1 | lib/
2 | dist/
3 |
--------------------------------------------------------------------------------
/.github/CONTRIBUTING.md:
--------------------------------------------------------------------------------
1 | # Contributing to `react-cookiebot`
2 |
3 | Love react-cookiebot and want to help? Thanks so much, there's something to do for everybody!
4 |
5 | Please take a moment to review this document in order to make the contribution process easy and effective for everyone involved.
6 |
7 | Following these guidelines helps to communicate that you respect the time of the developers managing and developing this open source project. In return, they should reciprocate that respect in addressing your issue or assessing patches and features.
8 |
9 | ## Using the issue tracker
10 |
11 | The [issue tracker](https://github.com/yeutech-lab/react-cookiebot/issues) is
12 | the preferred channel for [bug reports](#bugs), [features requests](#features)
13 | and [submitting pull requests](#pull-requests).
14 |
15 |
16 | ## Bug reports
17 |
18 | A bug is a _demonstrable problem_ that is caused by the code in the repository.
19 | Good bug reports are extremely helpful - thank you!
20 |
21 | Guidelines for bug reports:
22 |
23 | 1. **Use the GitHub issue search** — check if the issue has already been reported.
24 |
25 | 2. **Check if the issue has been fixed** — try to reproduce it using the latest `master` or development branch in the repository.
26 |
27 | 3. **Isolate the problem** — ideally create a reduced test case and a live example.
28 |
29 | A good bug report shouldn't leave others needing to chase you up for more information. Please try to be as detailed as possible in your report. What is your environment? What steps will reproduce the issue? What browser(s) and OS
30 | experience the problem? What would you expect to be the outcome? All these details will help people to fix any potential bugs.
31 |
32 | Example:
33 |
34 | > Short and descriptive example bug report title
35 | >
36 | > A summary of the issue and the browser/OS environment in which it occurs. If
37 | > suitable, include the steps required to reproduce the bug.
38 | >
39 | > 1. This is the first step
40 | > 2. This is the second step
41 | > 3. Further steps, etc.
42 | >
43 | > `` - a link to the reduced test case
44 | >
45 | > Any other information you want to share that is relevant to the issue being
46 | > reported. This might include the lines of code that you have identified as
47 | > causing the bug, and potential solutions (and your opinions on their
48 | > merits).
49 |
50 |
51 |
52 | ## Feature requests
53 |
54 | Feature requests are welcome. But take a moment to find out whether your idea fits with the scope and aims of the project. It's up to *you* to make a strong case to convince the project's developers of the merits of this feature. Please provide as much detail and context as possible.
55 |
56 |
57 |
58 | ## Pull requests
59 |
60 | Good pull requests - patches, improvements, new features - are a fantastic
61 | help. They should remain focused in scope and avoid containing unrelated
62 | commits.
63 |
64 | **Please ask first** before embarking on any significant pull request (e.g.
65 | implementing features, refactoring code, porting to a different language),
66 | otherwise you risk spending a lot of time working on something that the
67 | project's developers might not want to merge into the project.
68 |
69 | Please adhere to the coding conventions used throughout a project (indentation,
70 | accurate comments, etc.) and any other requirements (such as test coverage).
71 |
72 | Since the `master` branch is what people actually use in production, we have a
73 | `dev` branch that unstable changes get merged into first. Only when we
74 | consider that stable we merge it into the `master` branch and release the
75 | changes for real.
76 |
77 | Adhering to the following process is the best way to get your work
78 | included in the project:
79 |
80 | 1. [Fork](https://help.github.com/articles/fork-a-repo/) the project, clone your fork, and configure the remotes:
81 |
82 | ```bash
83 | # Clone your fork of the repo into the current directory
84 | git clone https://github.com//react-cookiebot.git
85 | # Navigate to the newly cloned directory
86 | cd react-cookiebot
87 | # Assign the original repo to a remote called "upstream"
88 | git remote add upstream https://github.com/kopax/react-cookiebot.git
89 | ```
90 |
91 | 2. If you cloned a while ago, get the latest changes from upstream:
92 |
93 | ```bash
94 | git checkout dev
95 | git pull upstream dev
96 | ```
97 |
98 | 3. Create a new topic branch (off the `dev` branch) to contain your feature, change, or fix:
99 |
100 | ```bash
101 | git checkout -b
102 | ```
103 |
104 | 4. Commit your changes in logical chunks. Please adhere to these [git commit message guidelines](https://github.com/angular/angular.js/blob/master/DEVELOPERS.md#-git-commit-guidelines) or your code is unlikely be merged into the main project. Use Git's [interactive rebase](https://help.github.com/articles/about-git-rebase/) feature to tidy up your commits before making them public.
105 |
106 | 5. Locally merge (or rebase) the upstream dev branch into your topic branch:
107 |
108 | ```bash
109 | git pull [--rebase] upstream dev
110 | ```
111 |
112 | 6. Push your topic branch up to your fork:
113 |
114 | ```bash
115 | git push origin
116 | ```
117 |
118 | 7. [Open a Pull Request](https://help.github.com/articles/using-pull-requests/)
119 | with a clear title and description.
120 |
121 | **IMPORTANT**: By submitting a patch, you agree to allow the project
122 | owners to license your work under the terms of the [MIT License](https://github.com/yeutech-lab/react-cookiebot/blob/master/LICENSE.md).
123 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE.md:
--------------------------------------------------------------------------------
1 | # react-cookiebot
2 |
3 | Before opening a new issue, please take a moment to review our [**community guidelines**](https://github.com/yeutech-lab/react-cookiebot/blob/master/.github/CONTRIBUTING.md) to make the contribution process easy and effective for everyone involved.
4 |
5 | **Before opening a new issue, you may find an answer in already closed issues**:
6 | https://github.com/yeutech-lab/react-cookiebot/issues?q=is%3Aissue+is%3Aclosed
7 |
8 | ## Issue Type
9 |
10 | - [ ] [Bug](https://github.com/yeutech-lab/react-cookiebot/blob/master/.github/CONTRIBUTING.md#bug-reports)
11 | - [ ] [Feature](https://github.com/yeutech-lab/react-cookiebot/blob/master/.github/CONTRIBUTING.md#feature-requests)
12 |
13 | ## Description
14 |
15 | (Add images if possible)
16 |
17 | ## Steps to reproduce
18 |
19 | (Add link to a demo on https://jsfiddle.net or similar if possible)
20 |
21 | # Versions
22 |
23 | - Node/NPM:
24 | - OS:
25 | - react-cookiebot:
26 |
27 |
--------------------------------------------------------------------------------
/.github/PULL_REQUEST_TEMPLATE.md:
--------------------------------------------------------------------------------
1 | ## react-cookiebot
2 |
3 | Thank you for contributing! Please take a moment to review our [**contributing guidelines**](https://github.com/yeutech-lab/react-cookiebot/blob/master/.github/CONTRIBUTING.md)
4 | to make the process easy and effective for everyone involved.
5 |
6 | **Please open an issue** before embarking on any significant pull request, especially those that
7 | add a new library or change existing tests, otherwise you risk spending a lot of time working
8 | on something that might not end up being merged into the project.
9 |
10 | Before opening a pull request, please ensure:
11 |
12 | - [ ] You have followed our [**contributing guidelines**](https://github.com/yeutech-lab/react-cookiebot/blob/master/.github/CONTRIBUTING.md)
13 | - [ ] Double-check your branch is based on `dev` and targets `dev`
14 | - [ ] Your are doing semantic commit message using [commitizen](https://github.com/commitizen/cz-cli) and our [commit message convention](https://github.com/angular/angular.js/blob/master/DEVELOPERS.md#-git-commit-guidelines)
15 | - [ ] Pull request has tests (we are going for 100% coverage!)
16 | - [ ] Code is well-commented, linted and follows project conventions
17 | - [ ] Documentation is updated (if necessary)
18 | - [ ] Description explains the issue/use-case resolved and auto-closes related issues
19 |
20 | Be kind to code reviewers, please try to keep pull requests as small and focused as possible :)
21 |
22 | **IMPORTANT**: By submitting a patch, you agree to allow the project
23 | owners to license your work under the terms of the [MIT License](https://github.com/yeutech-lab/react-cookiebot/blob/master/LICENSE.md).
24 |
--------------------------------------------------------------------------------
/.github/lock.yml:
--------------------------------------------------------------------------------
1 | # Configuration for lock-threads - https://github.com/dessant/lock-threads
2 |
3 | # Number of days of inactivity before a closed issue or pull request is locked
4 | daysUntilLock: 365
5 |
6 | # Skip issues and pull requests created before a given timestamp. Timestamp must
7 | # follow ISO 8601 (`YYYY-MM-DD`). Set to `false` to disable
8 | skipCreatedBefore: false
9 |
10 | # Issues and pull requests with these labels will not be locked. Set to `[]` to disable
11 | exemptLabels: []
12 |
13 | # Label to add before locking, such as `outdated`. Set to `false` to disable
14 | lockLabel: false
15 |
16 | # Comment to post before locking. Set to `false` to disable
17 | lockComment: >
18 | This thread has been automatically locked since there has not been
19 | any recent activity after it was closed. Please open a new issue for
20 | related bugs.
21 |
22 | # Assign `resolved` as the reason for locking. Set to `false` to disable
23 | setLockReason: true
24 |
25 | # Limit to only `issues` or `pulls`
26 | # only: issues
27 |
28 | # Optionally, specify configuration settings just for `issues` or `pulls`
29 | # issues:
30 | # exemptLabels:
31 | # - help-wanted
32 | # lockLabel: outdated
33 |
34 | # pulls:
35 | # daysUntilLock: 30
36 |
37 | # Repository to extend settings from
38 | # _extends: repo
39 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | node_modules
2 | npm-debug.log
3 | tmp.json
4 | .DS_Store
5 | bundle-stats.html
6 | .idea/
7 | coverage/
8 | /reports
9 | /test-report.xml
10 | jest_0
11 | lib
12 | dist
13 | /public
14 | /docs/cli
15 | /docs/declinations
16 | /docs/translation.md
17 | .git-credentials
18 | package-lock.json
19 | /*.tgz
20 | .iml
21 | debug.json
22 |
--------------------------------------------------------------------------------
/.ncurc.js:
--------------------------------------------------------------------------------
1 | const { createConfig } = require('@rollup-umd/ncu');
2 | module.exports = createConfig();
3 |
--------------------------------------------------------------------------------
/.npmignore:
--------------------------------------------------------------------------------
1 | node_modules
2 | npm-debug.log
3 | tmp.json
4 | .DS_Store
5 | /test-report.xml
6 | /jest_0
7 | .npmrc
8 | .idea
9 | .babelrc
10 | babel.config.js
11 | babel.ext.json
12 | .gitlab-ci.yml
13 | .github
14 | .gitlab
15 | .travis.yml
16 | .eslintignore
17 | .editorconfig
18 | /coverage
19 | /src
20 | /docs
21 | /public
22 | /bundle-stats.html
23 | /CODE_OF_CONDUCT.md
24 | /CONTRIBUTING.md
25 | /CHANGELOG.md
26 | sonar-project.properties
27 | declination.json
28 | rollup.config.js
29 | /styleguide.config.js
30 | /styleguide
31 | /reports
32 | /*.tgz
33 | /lib/**/*.md
34 | /internals
35 | **/tests/*.test.js
36 | .ncurc.js
37 |
--------------------------------------------------------------------------------
/.npmrc:
--------------------------------------------------------------------------------
1 | package-lock=false
2 |
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | language: node_js
2 | sudo: required
3 | dist: trusty
4 |
5 | # Blocked branch list
6 | branches:
7 | except:
8 | - gh-pages # will be deployed to, no need to build it
9 |
10 | cache:
11 | directories:
12 | - node_modules
13 |
14 | before_install:
15 | - npm install -g npm
16 |
17 | stages:
18 | - build
19 | - test
20 | - release
21 | - deploy
22 |
23 | jobs:
24 | include:
25 |
26 | # Job: Build
27 | - stage: build
28 | node_js:
29 | - 'lts/*'
30 | - '10'
31 | - '8'
32 | script:
33 | - npx @rollup-umd/build
34 | # Job: Test
35 | - stage: test
36 | node_js:
37 | - 'lts/*'
38 | - '10'
39 | - '8'
40 | addons:
41 | sonarcloud:
42 | organization: $(echo $TRAVIS_REPO_SLUG | awk -F '/' '{print $1}')
43 | script:
44 | - npx @rollup-umd/test
45 |
46 | # Job: Release
47 | - stage: release
48 | if: branch = master AND type = push AND fork = false
49 | node_js:
50 | - 'lts/*'
51 | skip_cleanup: true
52 | script:
53 | - npx semantic-release
54 |
55 | # Job: Page
56 | - stage: deploy
57 | if: branch = master AND type = push AND fork = false
58 | node_js:
59 | - 'lts/*'
60 | script:
61 | - targetVersion=$(git describe --tags `git rev-list --tags --max-count=1`)
62 | - npx @rollup-umd/deploy --target-version ${targetVersion}
63 | deploy:
64 | - provider: pages
65 | skip_cleanup: true
66 | github_token: $GH_TOKEN # Set automatically in the settings page of your repository, as a secure variable
67 | keep_history: true
68 | local_dir: public/
69 |
--------------------------------------------------------------------------------
/CHANGELOG.md:
--------------------------------------------------------------------------------
1 | ## [1.0.10](https://github.com/yeutech-lab/react-cookiebot/compare/v1.0.9...v1.0.10) (2020-12-22)
2 |
3 |
4 | ### Bug Fixes
5 |
6 | * **ssr:** return null when SSR ([d296bb9](https://github.com/yeutech-lab/react-cookiebot/commit/d296bb94a3a5a1f02527c800e01949c93398c259))
7 |
8 | ## [1.0.9](https://github.com/yeutech-lab/react-cookiebot/compare/v1.0.8...v1.0.9) (2020-12-22)
9 |
10 |
11 | ### Bug Fixes
12 |
13 | * **dependencies:** upgrade all dependencies and added some test for [#19](https://github.com/yeutech-lab/react-cookiebot/issues/19) ([96575b4](https://github.com/yeutech-lab/react-cookiebot/commit/96575b4f4f0c1b90b24fd3279732e1291353df59))
14 |
15 | ## [1.0.8](https://github.com/yeutech-lab/react-cookiebot/compare/v1.0.7...v1.0.8) (2020-02-17)
16 |
17 |
18 | ### Bug Fixes
19 |
20 | * **typo:** fix typo blockingmog => blockingmode ([cc6a6b9](https://github.com/yeutech-lab/react-cookiebot/commit/cc6a6b938dd8bed86bd43115600c774b022f111d))
21 |
22 | ## [1.0.7](https://github.com/yeutech-lab/react-cookiebot/compare/v1.0.6...v1.0.7) (2020-02-17)
23 |
24 |
25 | ### Bug Fixes
26 |
27 | * **dependencies:** upgrade all dependencies and added using CookieBot.native.js instead of MainField ([e54fa16](https://github.com/yeutech-lab/react-cookiebot/commit/e54fa16cb7b6b46deac9b1dea5a1193bb23db621))
28 |
29 | ## [1.0.6](https://github.com/yeutech-lab/react-cookiebot/compare/v1.0.5...v1.0.6) (2020-02-15)
30 |
31 |
32 | ### Bug Fixes
33 |
34 | * **(demo:** improve demo text ([5c2c43e](https://github.com/yeutech-lab/react-cookiebot/commit/5c2c43e128f1b857328646d19fd9dacfc3bacb2b))
35 |
36 | ## [1.0.5](https://github.com/yeutech-lab/react-cookiebot/compare/v1.0.4...v1.0.5) (2020-02-15)
37 |
38 |
39 | ### Bug Fixes
40 |
41 | * **CookieBot:** never render if no DOM ([a875d3c](https://github.com/yeutech-lab/react-cookiebot/commit/a875d3c06d31619d85efda16812c7717fcea6e09))
42 |
43 | ## [1.0.4](https://github.com/yeutech-lab/react-cookiebot/compare/v1.0.3...v1.0.4) (2020-02-12)
44 |
45 |
46 | ### Bug Fixes
47 |
48 | * **documentation:** improve order ([84d2cc2](https://github.com/yeutech-lab/react-cookiebot/commit/84d2cc25e7d0d054d45c687c19f4ab27d4e4aa86))
49 |
50 | ## [1.0.3](https://github.com/yeutech-lab/react-cookiebot/compare/v1.0.2...v1.0.3) (2020-02-12)
51 |
52 |
53 | ### Bug Fixes
54 |
55 | * **documentation:** improve example ([447fdee](https://github.com/yeutech-lab/react-cookiebot/commit/447fdeede4a6ce6cb505ecd32e3cef8692d03331))
56 |
57 | ## [1.0.2](https://github.com/yeutech-lab/react-cookiebot/compare/v1.0.1...v1.0.2) (2020-02-12)
58 |
59 |
60 | ### Bug Fixes
61 |
62 | * **demo:** added demo ([14db5f0](https://github.com/yeutech-lab/react-cookiebot/commit/14db5f078d7cf2385100a417ba83421acbdf102f))
63 |
64 | ## [1.0.1](https://github.com/yeutech-lab/react-cookiebot/compare/v1.0.0...v1.0.1) (2020-02-12)
65 |
66 |
67 | ### Bug Fixes
68 |
69 | * **release:** GitHub release https://github.com/yeutech-lab/react-cookiebot ([3b910fa](https://github.com/yeutech-lab/react-cookiebot/commit/3b910fa982435d2cfc1462bf3d410c7af535b6bb))
70 |
71 | # 1.0.0 (2020-02-12)
72 |
73 |
74 | ### Features
75 |
76 | * **ReactCookieBot:** added react cookiebot ([3e9ddd8](https://module.kopaxgroup.com/yeutech/react-cookiebot/commit/3e9ddd8b38e8b16c59869a453d96cfa706384e35))
77 | * **ReactCookieBot:** added react cookiebot ([b089e8e](https://module.kopaxgroup.com/yeutech/react-cookiebot/commit/b089e8ead3e2481343146065f93015400cf5cc6c))
78 |
--------------------------------------------------------------------------------
/CODE_OF_CONDUCT.md:
--------------------------------------------------------------------------------
1 | # Contributor Covenant Code of Conduct
2 |
3 | ## Our Pledge
4 |
5 | In the interest of fostering an open and welcoming environment, we as
6 | contributors and maintainers pledge to making participation in our project and
7 | our community a harassment-free experience for everyone, regardless of age, body
8 | size, disability, ethnicity, gender identity and expression, level of experience,
9 | nationality, personal appearance, race, religion, or sexual identity and
10 | orientation.
11 |
12 | ## Our Standards
13 |
14 | Examples of behavior that contributes to creating a positive environment
15 | include:
16 |
17 | * Using welcoming and inclusive language
18 | * Being respectful of differing viewpoints and experiences
19 | * Gracefully accepting constructive criticism
20 | * Focusing on what is best for the community
21 | * Showing empathy towards other community members
22 |
23 | Examples of unacceptable behavior by participants include:
24 |
25 | * The use of sexualized language or imagery and unwelcome sexual attention or
26 | advances
27 | * Trolling, insulting/derogatory comments, and personal or political attacks
28 | * Public or private harassment
29 | * Publishing others' private information, such as a physical or electronic
30 | address, without explicit permission
31 | * Other conduct which could reasonably be considered inappropriate in a
32 | professional setting
33 |
34 | ## Our Responsibilities
35 |
36 | Project maintainers are responsible for clarifying the standards of acceptable
37 | behavior and are expected to take appropriate and fair corrective action in
38 | response to any instances of unacceptable behavior.
39 |
40 | Project maintainers have the right and responsibility to remove, edit, or
41 | reject comments, commits, code, wiki edits, issues, and other contributions
42 | that are not aligned to this Code of Conduct, or to ban temporarily or
43 | permanently any contributor for other behaviors that they deem inappropriate,
44 | threatening, offensive, or harmful.
45 |
46 | ## Scope
47 |
48 | This Code of Conduct applies both within project spaces and in public spaces
49 | when an individual is representing the project or its community. Examples of
50 | representing a project or community include using an official project e-mail
51 | address, posting via an official social media account, or acting as an appointed
52 | representative at an online or offline event. Representation of a project may be
53 | further defined and clarified by project maintainers.
54 |
55 | ## Enforcement
56 |
57 | Instances of abusive, harassing, or otherwise unacceptable behavior may be
58 | reported by contacting the project team at contact@yeutech.vn. All
59 | complaints will be reviewed and investigated and will result in a response that
60 | is deemed necessary and appropriate to the circumstances. The project team is
61 | obligated to maintain confidentiality with regard to the reporter of an incident.
62 | Further details of specific enforcement policies may be posted separately.
63 |
64 | Project maintainers who do not follow or enforce the Code of Conduct in good
65 | faith may face temporary or permanent repercussions as determined by other
66 | members of the project's leadership.
67 |
68 | ## Attribution
69 |
70 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71 | available at [here][version]
72 |
73 | [homepage]: http://contributor-covenant.org
74 | [version]: http://contributor-covenant.org/version/1/4/
75 |
--------------------------------------------------------------------------------
/LICENSE.md:
--------------------------------------------------------------------------------
1 | Copyright 2020 Yeutech Company Limited
2 |
3 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4 |
5 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6 |
7 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
8 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # react-cookiebot
2 |
3 | [](https://travis-ci.org/yeutech-lab/react-cookiebot)
4 | [](https://www.npmjs.com/package/react-cookiebot)
5 | [](https://www.npmjs.com/package/react-cookiebot)
6 | [](https://npmjs.org/package/react-cookiebot)
7 | [](https://npmjs.org/package/react-cookiebot)
8 | [](https://www.npmjs.com/package/react-cookiebot)
9 | [](https://www.npmjs.com/package/react-cookiebot)
10 | [](https://sonarcloud.io/dashboard?id=com.github.yeutech-lab.react-cookiebot) [](https://sonarcloud.io/dashboard?id=com.github.yeutech-lab.react-cookiebot)
11 | [](https://app.fossa.com/projects/git%2Bgithub.com%2Fyeutech-lab%2Freact-cookiebot?ref=badge_shield)
12 |
13 | A simple react cookie bot component that configure Cookiebot in your [`react`](https://reactjs.org/) or [`react-native-web`](https://github.com/necolas/react-native-web/) application.
14 |
15 | > That will definitely work. It's also a good way to dynamically add/modify attributes.
16 | > It's important that the script is the first to load though, to make sure nothing else loads first and can cause issues.
17 | > Richard, Cookiebot Support
18 |
19 | ## Table of Contents
20 |
21 | - [What is cookie bot ?](#what-is-cookie-bot)
22 | - [Demo](#demo)
23 | - [Usage](#usage)
24 | - [Documentation](#documentation)
25 | - [Create a cookie bot account](#create-a-cookie-bot-account)
26 | - [Configuration](#configuration)
27 | - [Consent banner/dialog language](#consent-banner-dialog-language)
28 | - [Contributing](#contributing)
29 | - [License MIT](#license-mit)
30 |
31 | ---
32 |
33 |
34 | [](https://app.fossa.com/projects/git%2Bgithub.com%2Fyeutech-lab%2Freact-cookiebot?ref=badge_large)
35 |
36 | ## What is cookie bot ?
37 |
38 | COOKIEBOT HELPS MAKE YOUR USE OF COOKIES AND ONLINE TRACKING COMPLIANT.
39 |
40 | The General Data Protection Regulation (GDPR) applies to all websites with users from the EU. Check if your website’s use of cookies and online tracking is compliant with GDPR and the ePrivacy Directive (ePR).
41 |
42 | See what data your website collects and shares with 3rd parties – also useful for CCPA compliance (California Consumer Privacy Act).
43 |
44 | Visit Cookiebot [website](https://www.cookiebot.com)
45 |
46 | ## Demo
47 |
48 | View the [Demo](https://yeutech-lab.github.io/react-cookiebot/#cookiebot)
49 |
50 | ## Usage
51 |
52 | Just import ``, this example show how to use it and how to test if it is correctly injected in the page:
53 |
54 | ```js
55 |
56 | import React, { useState } from 'react';
57 | import { Button, View, Text } from 'react-native';
58 | const domainGroupId = 'ecff8d69-d1cb-416f-a86f-ba55b3f38707';
59 |
60 | function App() {
61 | const [hasCookieBot, setHasCookieBot] = useState(undefined);
62 | return (
63 |
64 |
65 | Click to test Cookiebot
66 |
71 | );
72 | }
73 |
74 |
75 | ```
76 |
77 | > React CookieBot work with react-native-web, configure your resolve extensions to resolve `.web.js` and `.js`.
78 |
79 |
80 | ## Documentation
81 |
82 | Read [react-cookiebot documentation](https://yeutech-lab.github.io/react-cookiebot).
83 |
84 |
85 | ## Create a cookie bot account
86 |
87 | You need to [create an account on cookiebot](https://manage.cookiebot.com/en/signup) and get a `domainGroupId` for your web site:
88 |
89 | 
90 |
91 | Create the account
92 |
93 | 
94 |
95 | Create the domain cookie bot will handle
96 |
97 | 
98 |
99 | Configure the cookie bot layout
100 |
101 | 
102 |
103 | Configure the cookie bot language
104 |
105 | 
106 |
107 | Get your domain group id
108 |
109 | **Don't forget to save**
110 |
111 | 
112 |
113 | You will have this cookie consent displayed on your website:
114 |
115 | 
116 |
117 | ## Configuration
118 |
119 | Configure webpack to load extensions `['.web.js', '.js']`:
120 |
121 | ```diff
122 | {
123 | "resolve": {
124 | "extensions": [".web.js", ".js"]
125 | }
126 | }
127 | ```
128 |
129 | ### Consent banner/dialog language
130 |
131 | If you want to force the language of consent (for i18n):
132 |
133 | ```js
134 |
135 | ```
136 |
137 | If consent with that language is no defined, the default language are loaded (or auto-detect).
138 |
139 | ### Use it once
140 |
141 | You must render this component at the root of your application, otherwise make sure your parent component does not re-rerender.
142 |
143 | The following will appear in your console if you break `react-cookiebot`: `WARNING: Cookiebot script is included twice - please remove one instance to avoid unexpected results.`
144 |
145 | ## Contributing
146 |
147 | If you want to contribute to react-cookiebot please see our [contributing and community guidelines](https://github.com/yeutech-lab/react-cookiebot/blob/master/.github/CONTRIBUTING.md), they\'ll help you get set up locally and explain the whole process.
148 |
149 | Please also note that all repositories under the yeutech-lab organization follow our [Code of Conduct](https://github.com/yeutech-lab/react-cookiebot/blob/master/CODE_OF_CONDUCT.md), make sure to review and follow it.
150 |
151 | ## License MIT
152 |
153 | Copyright 2020 Yeutech Company Limited
154 |
155 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
156 |
157 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
158 |
159 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
--------------------------------------------------------------------------------
/babel.config.js:
--------------------------------------------------------------------------------
1 | const fs = require('fs');
2 | const merge = require('babel-merge');
3 | const ext = `${__dirname}/babel.ext.json`;
4 |
5 | module.exports = merge({
6 | only: [
7 | 'src',
8 | 'styleguide',
9 | ],
10 | comments: false,
11 | presets: [
12 | [
13 | '@babel/preset-env',
14 | {
15 | modules: false,
16 | },
17 | ],
18 | '@babel/preset-react',
19 | ],
20 | plugins: [
21 | 'babel-plugin-array-includes',
22 | '@babel/plugin-transform-runtime',
23 | '@babel/plugin-transform-async-to-generator',
24 | '@babel/plugin-proposal-class-properties',
25 | '@babel/plugin-syntax-dynamic-import',
26 | '@babel/plugin-syntax-import-meta',
27 | '@babel/plugin-proposal-json-strings',
28 | [
29 | '@babel/plugin-proposal-decorators',
30 | {
31 | legacy: true,
32 | },
33 | ],
34 | ],
35 | env: {
36 | production: {
37 | plugins: [
38 | 'babel-plugin-add-module-exports',
39 | '@babel/plugin-transform-modules-commonjs',
40 | ],
41 | },
42 | test: {
43 | plugins: [
44 | '@babel/plugin-transform-modules-commonjs',
45 | 'babel-plugin-dynamic-import-node',
46 | ],
47 | },
48 | },
49 | }, fs.existsSync(ext) && require(ext)); // eslint-disable-line
50 |
--------------------------------------------------------------------------------
/babel.ext.json:
--------------------------------------------------------------------------------
1 | {
2 | "presets": [],
3 | "plugins": [
4 | "babel-plugin-inline-react-svg"
5 | ]
6 | }
--------------------------------------------------------------------------------
/declination.json:
--------------------------------------------------------------------------------
1 | {
2 | "globals": {
3 | },
4 | "external": [
5 | ]
6 | }
7 |
--------------------------------------------------------------------------------
/docs/commands.md:
--------------------------------------------------------------------------------
1 | Build project:
2 |
3 | ```bash
4 | $ npm run build
5 | ```
6 |
7 | Run unit test:
8 |
9 | ```bash
10 | $ npm test
11 | ```
12 |
13 | Watch unit test:
14 |
15 | ```bash
16 | $ npm run test:watch
17 | ```
18 |
19 | Build the `/lib` directory:
20 |
21 | ```bash
22 | $ npm run build:lib
23 | ```
24 |
25 | Watch the `/lib` directory:
26 |
27 | ```bash
28 | $ npm run build:lib:watch
29 | ```
30 |
31 | Start a documentation server and watch the `/docs` directory:
32 |
33 | ```bash
34 | $ npm run styleguide
35 | ```
36 |
37 | Build documentation in `/public` directory:
38 |
39 | ```bash
40 | $ npm run styleguide:build
41 | ```
42 |
43 | Build the JSdoc documentation
44 |
45 | ```bash
46 | $ npm run jsdoc
47 | ```
48 |
--------------------------------------------------------------------------------
/docs/contribute.md:
--------------------------------------------------------------------------------
1 | We highly encourage contribution, any feature request and merge request will be reviewed.
2 |
--------------------------------------------------------------------------------
/docs/installation.md:
--------------------------------------------------------------------------------
1 | ```bash
2 | npm install $PACKAGE_NAME --save
3 | ```
4 |
--------------------------------------------------------------------------------
/docs/introduction.md:
--------------------------------------------------------------------------------
1 | [](https://travis-ci.org/yeutech-lab/react-cookiebot)
2 | [](https://www.npmjs.com/package/react-cookiebot)
3 | [](https://www.npmjs.com/package/react-cookiebot)
4 | [](https://www.npmjs.com/package/react-cookiebot)
5 | [](https://www.npmjs.com/package/react-cookiebot)
6 |
7 |
8 | $PACKAGE_DESCRIPTION
9 |
10 | > That will definitely work. It's also a good way to dynamically add/modify attributes.
11 | > It's important that the script is the first to load though, to make sure nothing else loads first and can cause issues.
12 | > Richard, Cookiebot Support
13 |
14 |
15 | ## COOKIEBOT HELPS MAKE YOUR USE OF COOKIES AND ONLINE TRACKING COMPLIANT.
16 |
17 | The General Data Protection Regulation (GDPR) applies to all websites with users from the EU. Check if your website’s use of cookies and online tracking is compliant with GDPR and the ePrivacy Directive (ePR).
18 |
19 | See what data your website collects and shares with 3rd parties – also useful for CCPA compliance (California Consumer Privacy Act).
20 |
21 | Visit Cookiebot [website](https://www.cookiebot.com)
22 |
--------------------------------------------------------------------------------
/docs/js/jsdoc.md:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/docs/prerequisite.md:
--------------------------------------------------------------------------------
1 | If you don't have them, install all the `peerDependencies` in your project:
2 |
3 | ```bash
4 | $PACKAGE_PEERS
5 | ```
6 |
7 | You need to [create an account on cookiebot](https://manage.cookiebot.com/en/signup) and get a `domainGroupId` for your web site:
8 |
9 | 
10 |
11 | Create the account
12 |
13 | 
14 |
15 | Create the domain cookie bot will handle
16 |
17 | 
18 |
19 | Configure the cookie bot layout
20 |
21 | 
22 |
23 | Configure the cookie bot language
24 |
25 | 
26 |
27 | Get your domain group id
28 |
29 | **Don't forget to save**
30 |
31 | 
32 |
33 | You will have this cookie consent displayed on your website:
34 |
35 | 
36 |
--------------------------------------------------------------------------------
/docs/release.md:
--------------------------------------------------------------------------------
1 | Merge `dev` into `master` will release the documentation and tag a new version.
2 |
--------------------------------------------------------------------------------
/internals/testing/test-bundler.js:
--------------------------------------------------------------------------------
1 | require('@babel/polyfill');
2 | require('es6-promise').polyfill();
3 | require('@yeutech-lab/test-polyfill').polyfill();
4 | const Enzyme = require('enzyme');
5 | const Adapter = require('enzyme-adapter-react-16');
6 | Enzyme.configure({ adapter: new Adapter() });
7 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "react-cookiebot",
3 | "version": "1.0.10",
4 | "description": "A simple react cookie bot component that configure Cookiebot in your react or react-native-web application.",
5 | "main": "lib/index.js",
6 | "homepage": "https://yeutech-lab.github.io/react-cookiebot",
7 | "engines": {
8 | "node": ">=8"
9 | },
10 | "browserslist": [
11 | "IE >= 9",
12 | "last 2 versions"
13 | ],
14 | "author": "Dimitri Kopriwa (https://github.com/kopax)",
15 | "scripts": {
16 | "prebuild": "npm run build:clean",
17 | "build": "npm run build:lib && npm run build:dist",
18 | "prebuild:lib": "rimraf lib/*",
19 | "build:lib": "BABEL_ENV=production babel --out-dir lib src --copy-files",
20 | "prebuild:dist": "rimraf dist/*",
21 | "build:clean": "rimraf lib/* dist/*",
22 | "build:dist:dev": "rollup -c",
23 | "build:dist": "rollup -c --environment PRODUCTION",
24 | "build:readme": "toctoc README.md -w",
25 | "build:dist:watch": "rollup -c --watch",
26 | "build:lib:watch": "npm run build:lib -- --watch",
27 | "test": "npm run lint && npm run test:web",
28 | "test:web": "NODE_ENV=test jest --coverage",
29 | "test:clean": "rimraf ./coverage",
30 | "test:watch": "npm run test -- --watch",
31 | "lint": "eslint src",
32 | "prepublish": "npm run build",
33 | "lint-staged": "lint-staged",
34 | "jsdoc-documentation": "jsdoc-documentation",
35 | "jsdoc": "jsdoc-documentation --file",
36 | "prestyleguide": "npm run jsdoc",
37 | "styleguide": "styleguidist server",
38 | "styleguide:build": "styleguidist build"
39 | },
40 | "repository": {
41 | "type": "git",
42 | "url": "https://github.com/yeutech-lab/react-cookiebot.git"
43 | },
44 | "bugs": {
45 | "url": "https://github.com/yeutech-lab/react-cookiebot/issues"
46 | },
47 | "keywords": [
48 | "react",
49 | "yeutech.vn",
50 | "react",
51 | "cookiebot"
52 | ],
53 | "license": "MIT",
54 | "eslintConfig": {
55 | "parser": "babel-eslint",
56 | "extends": "airbnb",
57 | "env": {
58 | "browser": true,
59 | "node": true,
60 | "jest": true,
61 | "es6": true
62 | },
63 | "parserOptions": {
64 | "ecmaVersion": 6,
65 | "sourceType": "module"
66 | },
67 | "rules": {
68 | "arrow-parens": [
69 | "error",
70 | "always"
71 | ],
72 | "arrow-body-style": [
73 | 2,
74 | "as-needed"
75 | ],
76 | "comma-dangle": [
77 | 2,
78 | "always-multiline"
79 | ],
80 | "import/extensions": [
81 | "error",
82 | "always",
83 | {
84 | "js": "never",
85 | "mjs": "never"
86 | }
87 | ],
88 | "import/imports-first": 0,
89 | "import/newline-after-import": 0,
90 | "import/no-dynamic-require": 0,
91 | "import/no-extraneous-dependencies": 0,
92 | "import/no-named-as-default": 0,
93 | "import/no-unresolved": 2,
94 | "import/prefer-default-export": 0,
95 | "indent": [
96 | 2,
97 | 2,
98 | {
99 | "SwitchCase": 1
100 | }
101 | ],
102 | "max-len": 0,
103 | "newline-per-chained-call": 0,
104 | "no-confusing-arrow": 0,
105 | "no-console": 1,
106 | "no-use-before-define": 0,
107 | "prefer-template": 2,
108 | "class-methods-use-this": 0,
109 | "require-yield": 0,
110 | "no-await-in-loop": 0,
111 | "jsx-a11y/aria-props": 2,
112 | "jsx-a11y/heading-has-content": 0,
113 | "jsx-a11y/href-no-hash": "off",
114 | "jsx-a11y/anchor-is-valid": [
115 | "warn",
116 | {
117 | "aspects": [
118 | "invalidHref"
119 | ]
120 | }
121 | ],
122 | "jsx-a11y/label-has-for": 2,
123 | "jsx-a11y/mouse-events-have-key-events": 2,
124 | "jsx-a11y/role-has-required-aria-props": 2,
125 | "jsx-a11y/role-supports-aria-props": 2,
126 | "react/forbid-prop-types": 0,
127 | "react/jsx-first-prop-new-line": [
128 | 2,
129 | "multiline"
130 | ],
131 | "react/jsx-filename-extension": 0,
132 | "react/jsx-no-target-blank": 0,
133 | "react/require-extension": 0,
134 | "react/self-closing-comp": 0,
135 | "react/jsx-props-no-spreading": 0,
136 | "react/static-property-placement": 0,
137 | "react/state-in-constructor": 0
138 | },
139 | "settings": {
140 | "import/resolver": {
141 | "node": {
142 | "extensions": [
143 | ".js",
144 | ".mjs"
145 | ]
146 | }
147 | }
148 | },
149 | "plugins": [
150 | "react"
151 | ]
152 | },
153 | "jestSonar": {
154 | "reportPath": "reports",
155 | "reportFile": "test-report.xml",
156 | "indent": 2
157 | },
158 | "lint-staged": {
159 | "*.js": [
160 | "eslint --fix",
161 | "git add"
162 | ]
163 | },
164 | "pre-commit": [
165 | "build:readme",
166 | "lint-staged"
167 | ],
168 | "devDependencies": {
169 | "@babel/cli": "^7.12.10",
170 | "@babel/core": "^7.12.10",
171 | "@babel/plugin-external-helpers": "^7.12.1",
172 | "@babel/plugin-proposal-class-properties": "^7.12.1",
173 | "@babel/plugin-proposal-decorators": "^7.12.1",
174 | "@babel/plugin-proposal-json-strings": "^7.12.1",
175 | "@babel/plugin-proposal-object-rest-spread": "^7.12.1",
176 | "@babel/plugin-syntax-dynamic-import": "^7.8.3",
177 | "@babel/plugin-syntax-import-meta": "^7.10.4",
178 | "@babel/plugin-transform-async-to-generator": "^7.12.1",
179 | "@babel/plugin-transform-modules-commonjs": "^7.12.1",
180 | "@babel/plugin-transform-react-constant-elements": "^7.12.1",
181 | "@babel/plugin-transform-react-inline-elements": "^7.12.1",
182 | "@babel/plugin-transform-runtime": "^7.12.10",
183 | "@babel/polyfill": "^7.12.1",
184 | "@babel/preset-env": "^7.12.11",
185 | "@babel/preset-react": "^7.12.10",
186 | "@rollup-umd/build": "^1.1.1",
187 | "@rollup-umd/deploy": "^1.2.5",
188 | "@rollup-umd/documentation": "^2.1.1",
189 | "@rollup-umd/ncu": "^1.0.9",
190 | "@rollup-umd/rollup": "^1.1.1",
191 | "@rollup-umd/test": "^1.1.2",
192 | "@semantic-release/changelog": "^5.0.1",
193 | "@semantic-release/git": "^9.0.0",
194 | "@semantic-release/github": "^7.2.0",
195 | "@semantic-release/npm": "^7.0.9",
196 | "@yeutech-lab/documentation": "^2.0.2",
197 | "@yeutech-lab/test-polyfill": "^1.1.5",
198 | "babel-eslint": "^10.1.0",
199 | "babel-jest": "^26.6.3",
200 | "babel-loader": "^8.2.2",
201 | "babel-merge": "^3.0.0",
202 | "babel-plugin-add-module-exports": "^1.0.4",
203 | "babel-plugin-array-includes": "^2.0.3",
204 | "babel-plugin-dynamic-import-node": "^2.3.3",
205 | "babel-plugin-inline-react-svg": "^1.1.2",
206 | "babel-plugin-react-transform": "^3.0.0",
207 | "babel-plugin-transform-react-remove-prop-types": "^0.4.24",
208 | "cz-conventional-changelog": "^3.3.0",
209 | "enzyme": "^3.11.0",
210 | "enzyme-adapter-react-16": "^1.15.5",
211 | "es6-promise": "^4.2.8",
212 | "eslint": "^7.16.0",
213 | "eslint-config-airbnb": "^18.2.1",
214 | "eslint-plugin-import": "^2.22.1",
215 | "eslint-plugin-jsx-a11y": "^6.4.1",
216 | "eslint-plugin-react": "^7.21.5",
217 | "exports-loader": "^1.1.1",
218 | "istanbul-api": "^3.0.0",
219 | "istanbul-reports": "^3.0.2",
220 | "jest-cli": "^26.6.3",
221 | "jest-sonar-reporter": "^2.0.0",
222 | "lint-staged": "^10.5.3",
223 | "pre-commit": "^1.2.2",
224 | "raf": "^3.4.1",
225 | "react": "^16.12.0",
226 | "react-test-renderer": "^17.0.1",
227 | "semantic-release": "^17.3.0",
228 | "toctoc": "^0.3.2",
229 | "webpack": "^5.11.0"
230 | },
231 | "dependencies": {
232 | "@babel/runtime": "^7.12.5",
233 | "prop-types": "^15.7.2"
234 | },
235 | "peerDependencies": {
236 | "react": "*"
237 | },
238 | "publishConfig": {
239 | "registry": "https://registry.npmjs.org",
240 | "tag": "latest",
241 | "access": "public"
242 | },
243 | "release": {
244 | "branch": "master",
245 | "npmPublish": true,
246 | "verifyConditions": [
247 | "@semantic-release/changelog",
248 | "@semantic-release/npm",
249 | "@semantic-release/git",
250 | "@semantic-release/github"
251 | ],
252 | "prepare": [
253 | "@semantic-release/changelog",
254 | "@semantic-release/npm",
255 | {
256 | "path": "@semantic-release/git",
257 | "assets": [
258 | "package.json",
259 | "src/**/*.js",
260 | "CHANGELOG.md",
261 | "README.md",
262 | "LICENSE.md"
263 | ]
264 | }
265 | ],
266 | "publish": [
267 | "@semantic-release/npm",
268 | {
269 | "path": "@semantic-release/github",
270 | "assets": [
271 | {
272 | "path": "package.json"
273 | },
274 | {
275 | "path": "LICENSE.md"
276 | },
277 | {
278 | "path": "CHANGELOG.md"
279 | },
280 | {
281 | "path": "README.md"
282 | },
283 | {
284 | "path": "dist/*.esm.js",
285 | "label": "ES module"
286 | },
287 | {
288 | "path": "dist/*.esm.js.map",
289 | "label": "ES module source map"
290 | },
291 | {
292 | "path": "dist/*.min.js",
293 | "label": "UMD compressed"
294 | },
295 | {
296 | "path": "dist/*.min.js.map",
297 | "label": "UMD compressed source map"
298 | },
299 | {
300 | "path": "dist/*.cjs.min.js",
301 | "label": "CJS compressed"
302 | },
303 | {
304 | "path": "dist/*.cjs.min.js.map",
305 | "label": "CJS compressed source map"
306 | },
307 | {
308 | "path": "lib/*.js",
309 | "label": "CJS folder"
310 | }
311 | ]
312 | }
313 | ]
314 | },
315 | "config": {
316 | "commitizen": {
317 | "path": "./node_modules/cz-conventional-changelog"
318 | }
319 | },
320 | "jest": {
321 | "testURL": "http://localhost",
322 | "roots": [
323 | "/src/"
324 | ],
325 | "testPathIgnorePatterns": [
326 | "/dist/",
327 | "/lib/"
328 | ],
329 | "collectCoverageFrom": [
330 | "src/**/*.{js,jsx}",
331 | "!src/**/*.test.{js,jsx}"
332 | ],
333 | "transformIgnorePatterns": [
334 | "/node_modules",
335 | "/internals"
336 | ],
337 | "coverageThreshold": {
338 | "global": {
339 | "statements": 100,
340 | "branches": 100,
341 | "functions": 100,
342 | "lines": 100
343 | }
344 | },
345 | "moduleDirectories": [
346 | "node_modules",
347 | "src"
348 | ],
349 | "testRegex": "tests/.*\\.test\\.js$",
350 | "testResultsProcessor": "jest-sonar-reporter",
351 | "setupFilesAfterEnv": [
352 | "/internals/testing/test-bundler.js"
353 | ],
354 | "setupFiles": [
355 | "raf/polyfill"
356 | ]
357 | },
358 | "declinationId": "react",
359 | "contributors": []
360 | }
361 |
--------------------------------------------------------------------------------
/rollup.config.js:
--------------------------------------------------------------------------------
1 | import { createConfig } from '@rollup-umd/rollup';
2 |
3 | export default createConfig();
4 |
--------------------------------------------------------------------------------
/sonar-project.properties:
--------------------------------------------------------------------------------
1 | sonar.testExecutionReportPaths=reports/test-report.xml
2 | sonar.projectKey=com.github.yeutech-lab.react-cookiebot
3 | sonar.projectName=com.github.yeutech-lab.react-cookiebot
4 | sonar.sources=src
5 | sonar.exclusions=/src/**/tests/*.test.js
6 | sonar.test.exclusions=/src/**/tests/*.test.js
7 | sonar.dynamicAnalysis=reuseReports
8 | sonar.javascript.jstest.reportsPath=coverage
9 | sonar.javascript.lcov.reportPaths=coverage/lcov.info
10 | sonar.organization=yeutech-lab
11 |
--------------------------------------------------------------------------------
/src/CookieBot.js:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import PropTypes from 'prop-types';
3 |
4 | /**
5 | * Enable cookie bot on the website
6 | * @param {string} domainGroupId - Cookie bot domain group id
7 | * @param {string} language - Cookie bot data culture
8 | * @returns {*|null}
9 | * @constructor
10 | */
11 | function CookieBot({
12 | domainGroupId,
13 | language,
14 | }) {
15 | /* istanbul ignore next */
16 | if (typeof window === 'undefined') {
17 | return null;
18 | }
19 | if (!domainGroupId || !document) {
20 | return null;
21 | }
22 | if (domainGroupId.length !== 36) {
23 | console.warn(`The cookie bot domain group id is ${domainGroupId.length} characters, instead it should be 36 characters!`); // eslint-disable-line no-console
24 | }
25 | if (!document.getElementById('CookieBot')) {
26 | const script = document.createElement('script');
27 | script.setAttribute('id', 'CookieBot');
28 | script.setAttribute('src', 'https://consent.cookiebot.com/uc.js');
29 | script.setAttribute('data-cbid', domainGroupId);
30 | script.setAttribute('data-blockingmode', 'auto');
31 | script.setAttribute('type', 'text/javascript');
32 | if (language) {
33 | script.setAttribute('data-culture', language);
34 | }
35 | const head = document.querySelector('html > head');
36 | head.insertBefore(script, head.firstChild);
37 | }
38 | return (
39 |
46 | );
47 | }
48 |
49 | CookieBot.defaultProps = {
50 | domainGroupId: undefined,
51 | language: undefined,
52 | };
53 |
54 | CookieBot.propTypes = {
55 | /** Cookie bot domain group id */
56 | domainGroupId: PropTypes.string,
57 | /** Cookie bot language */
58 | language: PropTypes.string,
59 | };
60 |
61 | export default CookieBot;
62 |
--------------------------------------------------------------------------------
/src/CookieBot.md:
--------------------------------------------------------------------------------
1 | Just import ``, this example show how to use it and how to test if it is correctly injected in the page:
2 |
3 | ```js
4 |
5 | import React, { useState } from 'react';
6 | import { Button, View, Text } from 'react-native';
7 | const domainGroupId = 'ecff8d69-d1cb-416f-a86f-ba55b3f38707';
8 |
9 | function App() {
10 | const [hasCookieBot, setHasCookieBot] = useState(undefined);
11 | return (
12 |
13 |
14 | Click to test Cookiebot
15 |
20 | );
21 | }
22 |
23 |
24 | ```
25 |
26 | > React CookieBot work with react-native-web, configure your resolve extensions to resolve `.web.js` and `.js`.
27 |
--------------------------------------------------------------------------------
/src/CookieBot.native.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @component
3 | * CookieBot is not necessary on native app, this is why NoCookieBot is returned instead with `null` child
4 | * @returns {null}
5 | * @constructor
6 | */
7 | export default function NoCookieBot() {
8 | return null;
9 | }
10 |
--------------------------------------------------------------------------------
/src/index.js:
--------------------------------------------------------------------------------
1 | export { default } from './CookieBot';
2 |
--------------------------------------------------------------------------------
/src/tests/index.test.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Testing react-cookiebot
3 | */
4 | import { shallow } from 'enzyme';
5 | import React from 'react';
6 | import CookieBot from '../CookieBot.native';
7 | import CookieBotWeb from '../CookieBot';
8 |
9 | const renderComponentNative = ({ domainGroupId, ...rest } = {}) => shallow(
10 |
11 | );
12 |
13 | const renderComponentWeb = ({ domainGroupId, ...rest } = {}) => shallow(
14 |
15 | );
16 |
17 | /* eslint-disable no-console */
18 | describe('', () => {
19 | let saved;
20 | beforeEach(() => {
21 | saved = console.warn;
22 | console.warn = jest.fn();
23 | });
24 | afterEach(() => {
25 | console.warn = saved;
26 | });
27 |
28 | const props = {
29 | domainGroupId: '7d6b1a1e-8030-4f45-877e-21bb51e9233b',
30 | };
31 | it('should render a null on native', () => {
32 | const renderedComponent = renderComponentNative(props);
33 | const cookieDeclaration = renderedComponent.find('#CookieDeclaration');
34 | expect(renderedComponent.length).toBe(1);
35 | expect(cookieDeclaration.length).toBe(0);
36 | });
37 | it('should render on the web and inject #CookieBot script in the head', () => {
38 | const renderedComponent = renderComponentWeb(props);
39 | const cookieDeclaration = renderedComponent.find('#CookieDeclaration');
40 | expect(renderedComponent.length).toBe(1);
41 | expect(cookieDeclaration.length).toBe(1);
42 | expect(cookieDeclaration.prop('src')).toBe(`https://consent.cookiebot.com/${props.domainGroupId}/cd.js`);
43 | expect(console.warn).not.toHaveBeenCalled();
44 | expect(document.querySelector('html > head > #CookieBot').dataset.cbid).toBe(props.domainGroupId);
45 | });
46 | it('should render a null on web when no domainGroupId is passed', () => {
47 | const renderedComponent = renderComponentWeb();
48 | const cookieDeclaration = renderedComponent.find('#CookieDeclaration');
49 | expect(renderedComponent.length).toBe(1);
50 | expect(cookieDeclaration.length).toBe(0);
51 | });
52 | it('should produce a warning', () => {
53 | console.warn = jest.fn();
54 | const domainGroupId = '7d6b1a1e-8077e-21bb51e9233b';
55 | const renderedComponent = renderComponentWeb({
56 | domainGroupId,
57 | });
58 | expect(renderedComponent.length).toBe(1);
59 | expect(console.warn).toHaveBeenCalledWith(`The cookie bot domain group id is ${domainGroupId.length} characters, instead it should be 36 characters!`);
60 | });
61 | it('should render a culture', () => {
62 | const renderedComponent = renderComponentWeb({
63 | ...props,
64 | language: 'ES',
65 | });
66 | const cookieDeclaration = renderedComponent.find('#CookieDeclaration');
67 | expect(renderedComponent.length).toBe(1);
68 | expect(cookieDeclaration.length).toBe(1);
69 | expect(renderedComponent.prop('data-culture')).toBe('ES');
70 | expect(cookieDeclaration.prop('data-culture')).toBe('ES');
71 | });
72 | });
73 |
--------------------------------------------------------------------------------
/styleguide.config.js:
--------------------------------------------------------------------------------
1 | const { createConfig } = require('@rollup-umd/documentation');
2 | module.exports = createConfig();
3 |
--------------------------------------------------------------------------------
/styleguide/jsdoc.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | set -e
3 |
4 | ## Create documentation using JSdoc annotation here
5 | ## Run the command `npm run jsdoc-documentation