0.3.2 • Published 4 years ago

react-cookie-law-customizable v0.3.2

Weekly downloads
15
License
MIT
Repository
github
Last release
4 years ago

React Cookie Law (Customizable defaults)

npm version Build Status

This is a fork of React Cookie Banner component GDPR compliance. It has an additional feature to configure default check for all cookies.

Install

yarn add react-cookie-law-customizable

or

npm install --save react-cookie-law-customizable

Usage

import { CookieBanner } from "react-cookie-law-customizable";

React.renderComponent(
  <div>
    <CookieBanner
      message="Cookie banner message"
      onAccept={() => {}}
      onAcceptPreferences={() => {}}
      onAcceptStatistics={() => {}}
      onAcceptMarketing={() => {}}
    />
  </div>,
  document.body
);

Options

NameTypeDefaultDescription
classNamestringoptional. Classes
messagestringRequired. Custom text of the banner
policyLinkstring"/#"optional. Link to privacy policy page
privacyPolicyLinkTextstring"Privacy Policy"optional. Text for the privacy policy link
necessaryOptionTextstring"Necessary"optional. Text for the necessary cookies checkbox
preferencesOptionTextstring"Preferences"optional. Text for the preferences cookies checkbox
statisticsOptionTextstring"Statistics"optional. Text for the statistics cookies checkbox
marketingOptionTextstring"Marketing"optional. Text for the marketing cookies checkbox
acceptButtonTextstring"Accept"optional. Text for the accept button
declineButtonTextstring"Decline"optional. Text for the decline button
showDeclineButtonboolfalseoptional. Show or hide the decline button
dismissOnScrollboolfalseoptional. Enable or disable the dismissing on scroll of the banner
showPreferencesOptionbooltrueoptional. Show or hide the preferences checkbox
showStatisticsOptionbooltrueoptional. Show or hide the statistics checkbox
showMarketingOptionbooltrueoptional. Show or hide the marketing checkbox
marketingDefaultbooltrueoptional. Checks the marketing checkbox if true
preferencesDefaultbooltrueoptional. Checks the preferences checkbox if true
statisticsDefaultbooltrueoptional. Checks the statistics checkbox if true
onAcceptfunctionFunctionoptional. Callback called when the consent is given
onAcceptPreferencesfunctionFunctionoptional. Callback called if preferences cookies is accepted
onAcceptStatisticsfunctionFunctionoptional. Callback called if statistics cookies is accepted
onAcceptMarketingfunctionFunctionoptional. Callback called if marketing cookies is accepted
onDeclinePreferencesfunctionFunctionoptional. Callback called if preferences cookies is declined
onDeclineStatisticsfunctionFunctionoptional. Callback called if statistics cookies is declined
onDeclineMarketingfunctionFunctionoptional. Callback called if marketing cookies is declined

Style

<CookieBanner
  message="Cookie banner message"
  styles={{
    dialog: { backgroundColor: "red" }
  }}
/>
Style optionDescription
dialogStyle that override .react-cookie-law-dialog class
container.react-cookie-law-container class
messageStyle for banner text (.react-cookie-law-message class)
policyStyle for cookie policy link (.react-cookie-law-policy class)
selectPaneStyle for select pane (.react-cookie-law-select-pane class)
optionWrapperStyle for option checkbox wrapper (.react-cookie-law-option-wrapper class)
optionLabelStyle for the text of checkbox labels
checkboxStyle for checkboxes (.react-cookie-law-option-checkbox class)
buttonWrapperStyle for buttons wrapper (.react-cookie-law-dialog class)
buttonStyle for buttons (.react-cookie-law-dialog class)

Test

yarn test

or

npm test

Author

Original: Palmabit Update: Ramon Cardena

Licence

See the MIT License