Skip to content

Commit 59c258d

Browse files
committed
Allow displaying a link base on the props values
1 parent 547e5dc commit 59c258d

File tree

3 files changed

+23
-2
lines changed

3 files changed

+23
-2
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ class Example extends Component {
3838
* `message` Message that will be show to the user: (Type `String`, Default value: 'Cookies help us deliver our services. By using our services, you agree to our use of cookies.')
3939
* `buttonMessage` Text of the submit action button: (Type: `String`, Default value: 'OK')
4040
* `expiresIn` Time needed for the cookie to expire: (Type: `Number`, Default value: 365)
41+
* `link` Link for more information pages: (Type: `Object`, Default values: { url: undefined, text: undefined, target: '_blank'})
4142

4243
## Styling
4344

@@ -49,6 +50,7 @@ class Example extends Component {
4950
1. `.cookies-consent`: Entire Component container.
5051
2. `.cookies-consent-text`: Container of the message showed to the user.
5152
3. `.cookies-consent-button` Container of the Button for accepting the use of cookies.
53+
4. `.cookies-consent-link` Container of the `a` tag for the link.
5254

5355
## License
5456

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@cuban-engineer/react-cookies-consent",
3-
"version": "1.0.2",
3+
"version": "1.0.3",
44
"description": "React component for the managing the user awareness regarding cookies usage",
55
"main": "lib/index.js",
66
"module": "lib/index.es.js",

src/index.js

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,22 @@ export default class CookiesConsent extends Component {
3636
};
3737

3838
render() {
39-
const { message, buttonMessage } = this.props;
39+
const { message, buttonMessage, link } = this.props;
4040
const { cookiesConsent } = this.state;
4141
return (
4242
<div>
4343
{cookiesConsent === false && (
4444
<div className="cookies-consent">
4545
<span className="cookies-consent-text">{message}</span>
46+
{link &&
47+
link.url &&
48+
link.text && (
49+
<span className="cookies-consent-link">
50+
<a href={link.url} target={link.target}>
51+
{link.text}
52+
</a>
53+
</span>
54+
)}
4655
<span>
4756
<button
4857
type="button"
@@ -63,11 +72,21 @@ CookiesConsent.propTypes = {
6372
message: PropTypes.string,
6473
buttonMessage: PropTypes.string,
6574
expiresIn: PropTypes.number,
75+
link: PropTypes.shape({
76+
url: PropTypes.string,
77+
text: PropTypes.string,
78+
target: PropTypes.string,
79+
}),
6680
};
6781

6882
CookiesConsent.defaultProps = {
6983
cookieId: COOKIES_ID,
7084
message: COOKIES_CONSENT_DEFAULT_MESSAGE,
7185
buttonMessage: COOKIES_CONSENT_BUTTON_MESSAGE,
7286
expiresIn: COOKIES_EXPIRES,
87+
link: {
88+
url: undefined,
89+
text: undefined,
90+
target: '_blank',
91+
},
7392
};

0 commit comments

Comments
 (0)