|
1 | 1 | import React from "react"; |
2 | 2 | import CookieConsent from "react-cookie-consent"; |
3 | | -import styles from "./custom.css"; // Assuming you have a custom CSS file for styling |
4 | 3 |
|
5 | 4 | // Default implementation, that you can customize |
6 | 5 | export default function Root({ children }) { |
7 | | - // Custom styles for the CookieConsent component |
8 | | - const cookieConsentStyles = { |
9 | | - container: { |
10 | | - background: "#37454a", |
11 | | - color: "#fff", |
12 | | - padding: "10px", |
13 | | - }, |
14 | | - button: { |
15 | | - color: "#fff", |
16 | | - fontSize: "16px", |
17 | | - background: "#4CAF50", |
18 | | - borderRadius: "5px", |
19 | | - padding: "10px 20px", |
20 | | - }, |
21 | | - declineButton: { |
22 | | - color: "#fff", |
23 | | - background: "#f44336", |
24 | | - fontSize: "16px", |
25 | | - borderRadius: "5px", |
26 | | - padding: "10px 20px", |
27 | | - }, |
28 | | - content: { |
29 | | - margin: "10px", |
30 | | - }, |
31 | | - overlay: { |
32 | | - background: "rgba(0,0,0,0.7)", |
33 | | - }, |
34 | | - }; |
| 6 | + // Custom styles for the CookieConsent component |
| 7 | + const cookieConsentStyles = { |
| 8 | + container: { |
| 9 | + background: "#37454a", |
| 10 | + color: "#fff", |
| 11 | + padding: "10px", |
| 12 | + }, |
| 13 | + button: { |
| 14 | + color: "#fff", |
| 15 | + fontSize: "16px", |
| 16 | + background: "#4CAF50", |
| 17 | + borderRadius: "5px", |
| 18 | + padding: "10px 20px", |
| 19 | + }, |
| 20 | + declineButton: { |
| 21 | + color: "#fff", |
| 22 | + background: "#f44336", |
| 23 | + fontSize: "16px", |
| 24 | + borderRadius: "5px", |
| 25 | + padding: "10px 20px", |
| 26 | + }, |
| 27 | + content: { |
| 28 | + margin: "10px", |
| 29 | + }, |
| 30 | + overlay: { |
| 31 | + background: "rgba(0,0,0,0.7)", |
| 32 | + }, |
| 33 | + }; |
35 | 34 |
|
36 | | - return ( |
37 | | - <> |
38 | | - <CookieConsent |
39 | | - visible="byCookieValue" |
40 | | - location="bottom" |
41 | | - buttonText="Accept" |
42 | | - declineButtonText="Decline" |
43 | | - cookieName="TypeWriterCookieConcent" |
44 | | - style={cookieConsentStyles.container} |
45 | | - buttonStyle={cookieConsentStyles.button} |
46 | | - declineButtonStyle={cookieConsentStyles.declineButton} |
47 | | - contentStyle={cookieConsentStyles.content} |
48 | | - overlay |
49 | | - overlayStyle={cookieConsentStyles.overlay} |
50 | | - expires={150} |
51 | | - onAccept={() => { |
52 | | - try { |
53 | | - // Custom accept logic |
54 | | - console.log("Cookies accepted!"); |
55 | | - } catch (error) { |
56 | | - console.error("Error accepting cookies:", error); |
57 | | - } |
58 | | - }} |
59 | | - onDecline={() => { |
60 | | - try { |
61 | | - // Custom decline logic |
62 | | - console.log("Cookies declined!"); |
63 | | - window.location.href = "/leave"; |
64 | | - } catch (error) { |
65 | | - console.error("Error declining cookies:", error); |
66 | | - } |
67 | | - }} |
68 | | - enableDeclineButton |
69 | | - flipButtons |
70 | | - ariaAcceptLabel="Accept cookies" |
71 | | - ariaDeclineLabel="Decline cookies" |
72 | | - > |
73 | | - This website uses cookies to enhance the user experience.{" "} |
74 | | - <span style={{ fontSize: "10px" }}> |
75 | | - <a href="/privacy-policy" style={{ color: "#f1d600" }}> |
76 | | - Learn more |
77 | | - </a> |
78 | | - </span> |
79 | | - </CookieConsent> |
80 | | - {children} |
81 | | - </> |
82 | | - ); |
| 35 | + return ( |
| 36 | + <> |
| 37 | + <CookieConsent |
| 38 | + visible="byCookieValue" |
| 39 | + location="bottom" |
| 40 | + buttonText="Accept" |
| 41 | + declineButtonText="Decline" |
| 42 | + cookieName="TypeWriterCookieConcent" |
| 43 | + style={cookieConsentStyles.container} |
| 44 | + buttonStyle={cookieConsentStyles.button} |
| 45 | + declineButtonStyle={cookieConsentStyles.declineButton} |
| 46 | + contentStyle={cookieConsentStyles.content} |
| 47 | + overlay |
| 48 | + overlayStyle={cookieConsentStyles.overlay} |
| 49 | + expires={150} |
| 50 | + onAccept={() => { |
| 51 | + try { |
| 52 | + // Custom accept logic |
| 53 | + console.log("Cookies accepted!"); |
| 54 | + } catch (error) { |
| 55 | + console.error("Error accepting cookies:", error); |
| 56 | + } |
| 57 | + }} |
| 58 | + onDecline={() => { |
| 59 | + try { |
| 60 | + // Custom decline logic |
| 61 | + console.log("Cookies declined!"); |
| 62 | + window.location.href = "/leave"; |
| 63 | + } catch (error) { |
| 64 | + console.error("Error declining cookies:", error); |
| 65 | + } |
| 66 | + }} |
| 67 | + enableDeclineButton |
| 68 | + flipButtons |
| 69 | + ariaAcceptLabel="Accept cookies" |
| 70 | + ariaDeclineLabel="Decline cookies" |
| 71 | + > |
| 72 | + This website uses cookies to enhance the user experience.{" "} |
| 73 | + <span style={{ fontSize: "10px" }}> |
| 74 | + <a href="/privacy-policy" style={{ color: "#f1d600" }}> |
| 75 | + Learn more |
| 76 | + </a> |
| 77 | + </span> |
| 78 | + </CookieConsent> |
| 79 | + {children} |
| 80 | + </> |
| 81 | + ); |
83 | 82 | } |
0 commit comments