File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+
2+ import React , { useEffect , useState } from "react" ;
3+ import {
4+ Snackbar ,
5+ Typography ,
6+ Box ,
7+ Paper ,
8+ Stack ,
9+ } from "@mui/material" ;
10+
11+
12+ import Button from "../../reusecore/Button" ;
13+
14+ const CookieConsent = ( ) => {
15+ const [ open , setOpen ] = useState ( false ) ;
16+
17+ useEffect ( ( ) => {
18+ const consent = localStorage . getItem ( "cookie_consent" ) ;
19+ if ( ! consent ) {
20+ setOpen ( true ) ;
21+ }
22+ } , [ ] ) ;
23+
24+ const handleResponse = ( ) => {
25+ localStorage . setItem ( "cookie_consent" , response ) ;
26+ setOpen ( false ) ;
27+ } ;
28+
29+ return (
30+ < Snackbar
31+ open = { open }
32+ anchorOrigin = { { vertical : "bottom" , horizontal : "center" } }
33+ >
34+ < Paper
35+ elevation = { 6 }
36+ sx = { {
37+ p : 2 ,
38+ maxWidth : 420 ,
39+ borderRadius : 2 ,
40+ } }
41+ >
42+ < Stack spacing = { 2 } >
43+ < Typography variant = "body1" fontWeight = "500" >
44+ 🍪 We value your privacy
45+ </ Typography >
46+ < Typography variant = "body2" color = "text.secondary" >
47+ We use cookies to enhance your browsing experience. By clicking
48+ "Accept", you consent to our use of cookies. Read more in our{ " " }
49+ < a href = "/privacy" target = "_blank" rel = "noopener noreferrer" >
50+ Privacy Policy
51+ </ a >
52+ .
53+ </ Typography >
54+
55+ < Box display = "flex" justifyContent = "flex-end" gap = { 1 } >
56+ < Button
57+ variant = "outlined"
58+ size = "small"
59+ $outlined
60+ onClick = { ( ) => handleResponse ( "declined" ) }
61+ >
62+ Decline
63+ </ Button >
64+ < Button
65+ variant = "contained"
66+ size = "small"
67+ $secondary
68+ onClick = { ( ) => handleResponse ( "accepted" ) }
69+ >
70+ Accept
71+ </ Button >
72+ </ Box >
73+ </ Stack >
74+ </ Paper >
75+ </ Snackbar >
76+ ) ;
77+ } ;
78+
79+ export default CookieConsent ;
80+
Original file line number Diff line number Diff line change @@ -14,6 +14,7 @@ import Navigation from "../sections/General/Navigation";
1414import Footer from "../sections/General/Footer" ;
1515// import TopPromotionalBanner from "./TopPromotionalBanner";
1616import { GlobalStyle } from "../sections/app.style" ;
17+ import CookieConsent from "./CookieConsent" ;
1718
1819const Layout = ( { children } ) => {
1920
@@ -22,6 +23,7 @@ const Layout = ({ children }) => {
2223 < GlobalStyle />
2324 { /* <TopPromotionalBanner /> */ }
2425 < Navigation />
26+ < CookieConsent />
2527 { children }
2628 < ScrollToTopBtn />
2729 < Footer location = { children . props . location } />
@@ -33,4 +35,4 @@ Layout.propTypes = {
3335 children : PropTypes . node . isRequired
3436} ;
3537
36- export default Layout ;
38+ export default Layout ;
Original file line number Diff line number Diff line change @@ -35,6 +35,21 @@ const ButtonStyle = styled.button`
3535 margin-left: 8px;
3636 }
3737
38+ ${ props => props . $outlined && css `
39+ background: transparent;
40+ border: 2px solid ${ props => props . theme . blackFourToWhiteFour } ;
41+ color: ${ props => props . theme . blackToWhite } ;
42+ &:hover{
43+ box-shadow: 0 2px 10px ${ props . theme . whiteFourToBlackFour } ;
44+ }
45+ &:active{
46+ background: ${ props => props . theme . lightGrey } ;
47+ box-shadow: 0 2px 10px ${ props . theme . blackFourToWhiteFour } ;
48+ transform: scale(0.98);
49+ }
50+ ` }
51+
52+
3853 ${ props => props . $primary && css `
3954 color: ${ props => props . theme . black } ;
4055 background: ${ props => props . theme . highlightColor } ;
You can’t perform that action at this time.
0 commit comments