项目作者: awibox

项目描述 :
:cake: The package will help you to display a notification about the use of cookies on the site
高级语言: JavaScript
项目地址: git://github.com/awibox/react-cookie-disclaimer.git
创建时间: 2019-12-21T21:23:59Z
项目社区:https://github.com/awibox/react-cookie-disclaimer

开源协议:MIT License

下载




react-cookie-disclaimer

Version
Build
Coverage
Minified size
Downloads
Dependabot
PRs Welcome
Tested with jest

Table of contents

Installation

You need to install package:

  1. npm install react-cookie-disclaimer

You can use yarn:

  1. yarn add react-cookie-disclaimer

Getting started

You should import the component:

  1. import CookieDisclaimer from 'react-cookie-disclaimer';

Then use the component in your application. For example:
```typescript jsx

  1. <a name="settings"></a>
  2. ## The settings of the component
  3. |Parameter|Type|Description|Default|
  4. |--------------------|--------|-----------|-------|
  5. |**background**|string|Sets the notification background color in any format that supports css|``` #fff ```|
  6. |**bottomPosition**|boolean|By default notification is displayed at the top of the page. If set to ```true```, the notification will be displayed at the bottom|``` false ```|
  7. |**color**|string|Sets the text color|``` #000 ```|
  8. |**cookiePolicyName**|string|Sets the name of cookie policy link|``` Cookie Policy ```|
  9. |**cookiePolicyText**|string|Sets the text before the cookie policy link. It is recommended to set value because default text may change in future versions|``` By continuing to use the service, you agree to our use of cookies as described in the ```|
  10. |**cookiePolicyLink**|string|Link to your cookie policy. If the link value is not set, the link with the name (cookiePolicyName) and the text before the link (cookiePolicyText) will not be displayed|-|
  11. |**text**|string|This is the main text that will be displayed in the notification. It is recommended to set value because default text may change in future versions|``` This website uses cookies to improve service, for analytical and advertising purposes. ```|
  12. |**closeIconSize**|number|Sets the icon size to close the notification|``` 28 ```|
  13. |**closeIconPositionTop**|boolean|By default the icon for closing is displayed in the middle relative to the height of the notification and the value of this parameter is ```false```. If set to ```true```, the closing icon will be displayed on the top|``` false ```|
  14. |**padding**|number|Sets padding for cookie notification|``` 20 ```|
  15. <a name="custom"></a>
  16. ## Custom content
  17. You can place your own content in the notification. You should call the component as follows:
  18. ```typescript jsx
  19. <CookieDisclaimer background='#000' color='#fff'>JSX custom content</CookieDisclaimer>

Custom styles

You can also add custom styles by passing the className parameter:
```typescript jsx

JSX custom content

  1. <a name="example"></a>
  2. ## Example
  3. ```typescript jsx
  4. import CookieDisclaimer from 'react-cookie-disclaimer';
  5. const App = () => (
  6. <div className="app">
  7. ...
  8. <CookieDisclaimer
  9. background='#0079c1'
  10. bottomPosition={false}
  11. closeIconSize={30}
  12. closeIconPositionTop={false}
  13. color='#fff'
  14. cookiePolicyName='Cookie Policy'
  15. cookiePolicyLink='/cookie-policy'
  16. cookiePolicyText='By continuing to use the service, you agree to our'
  17. text='This website uses cookies to improve service.'
  18. ></CookieDisclaimer>
  19. </div>
  20. );
  21. export default App;

Contributing

Please read through our CONTRIBUTING.md.