Skip to content

Commit

Permalink
feat: add cookie component
Browse files Browse the repository at this point in the history
Adds a cookie component from react-cookie
  • Loading branch information
rikhall1515 authored Apr 21, 2024
2 parents 1f642d0 + 61372c6 commit d4a67a2
Showing 1 changed file with 49 additions and 0 deletions.
49 changes: 49 additions & 0 deletions components/cookies/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
"use client";

import { CookieConsent } from "react-cookie-consent";

import { useCookieContext } from "@/context/cookie";

export default function CookieBanner() {
const consent = useCookieContext();

return consent.hasConsentValue ? (
<></>
) : (
<>
<CookieConsent
enableDeclineButton
sameSite="strict"
flipButtons
cookieName="giftistguide_consent"
buttonText="Accept all"
declineButtonText="Decline all"
onAccept={() => {
consent.setHasConsentValue(true);
}}
onDecline={() => {
consent.setHasConsentValue(true);
}}
style={{
background: "hsl(var(--popover))",
color: "hsl(var(--popover-foreground))",
borderTop: "1px hsl(var(--border))",
}}
buttonStyle={{
background: "hsl(var(--primary))",
color: "white",
borderRadius: "0.35rem",
}}
declineButtonStyle={{
border: "1px hsl(var(--ring))",
background: "hsl(var(--secondary))",
color: "hsl(var(--secondary-foreground))",
}}
buttonClasses=""
declineButtonClasses=""
>
This website uses cookies to enhance the user experience.
</CookieConsent>
</>
);
}

0 comments on commit d4a67a2

Please sign in to comment.