0.7.1 • Published 1 year ago

@kubide.dev/react-cookie-law-full v0.7.1

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

React Cookie Law

npm version Build Status Coverage Status

A React Cookie Banner component GDPR compliance.

Preview

Install

npm install --save @kubide.dev/react-cookie-law-full

Usage

import { CookieBanner } from "@palmabit/react-cookie-law";

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

  document.body
);

Options

NameTypeDefaultDescription
classNamestringoptional. Classes
messagestringRequired. Custom text of the banner
wholeDomainboolfalseoptional. Enable or disable the root path '/' option when a cookie is set
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
managePreferencesButtonTextstring"Decline"optional. Text for the manage preferences button
savePreferencesButtonTextstring"Decline"optional. Text for the save and close* 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
preferencesDefaultCheckedbooltrueoptional. Check the preferences checkbox as default
statisticsDefaultCheckedbooltrueoptional. Check the statistics checkbox as default
marketingDefaultCheckedbooltrueoptional. Check the marketing checkbox as default
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
coryphaUserIdstring"1"optional. User ID of the current user
coryphaDocumentCodestring"my-app"*optional**. The unique document code assigned to the application
coryphaDocumentLanguagestring"en"optional**. Callback called if marketing* cookies is declined
coryphaApiKeystring"12345678-abcd-dcba-abcd-1234567890ab"*optional**. Your Corypha API Key
onAcceptCoryphaPreferencesfunctionFunctionoptional. Callback called when Corypha cookies are accepted
onDeclineCoryphaPreferencesfunctionFunctionoptional. Callback called when Corypha cookies are declined

*NOTE: coryphaDocumentCode, coryphaDocumentLanguage and coryphaApiKey are required when setting up the Corypha integration.

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

npm test

Author

Palmabit

Licence

See the MIT License