Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add cookie component #42

Merged
merged 1 commit into from
Apr 21, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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>
</>
);
}
Loading