-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(docs): update cookie consent ui changes (#1019)
* fix(docs): update cookie consent ui changes * fix(docs): move zIndex value away from sprinkles * fix(docs): make cookie consent sticky * fix(docs): move title header outside of the main content area * fix(docs): tile header global variables * fix(react-ui): move padding to notification content wrapper
- Loading branch information
1 parent
9f80bb5
commit 57a8da2
Showing
8 changed files
with
89 additions
and
123 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
--- | ||
--- |
77 changes: 0 additions & 77 deletions
77
packages/apps/docs/src/components/ConsentModal/ConsentModal.tsx
This file was deleted.
Oops, something went wrong.
40 changes: 0 additions & 40 deletions
40
packages/apps/docs/src/components/ConsentModal/styles.css.ts
This file was deleted.
Oops, something went wrong.
66 changes: 66 additions & 0 deletions
66
packages/apps/docs/src/components/CookieConsent/CookieConsent.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
import { Notification, Text } from '@kadena/react-ui'; | ||
|
||
import { notificationClass } from './styles.css'; | ||
|
||
import { updateConsent } from '@/utils/analytics'; | ||
import type { FC } from 'react'; | ||
import React, { useCallback, useEffect, useState } from 'react'; | ||
|
||
export const CookieConsent: FC = () => { | ||
const [cookieConsent, setCookieConsent] = useState<boolean | null>(null); | ||
|
||
useEffect(() => { | ||
const stickyValue = localStorage.getItem('cookie_consent'); | ||
if (stickyValue === null) return; | ||
setCookieConsent(JSON.parse(stickyValue)); | ||
}, []); | ||
|
||
useEffect(() => { | ||
if (cookieConsent === null) return; | ||
updateConsent(cookieConsent); | ||
}, [cookieConsent]); | ||
|
||
const handleAccept = useCallback(() => { | ||
setCookieConsent(true); | ||
}, []); | ||
|
||
const handleReject = useCallback(() => { | ||
setCookieConsent(false); | ||
}, []); | ||
|
||
if (cookieConsent !== null) return null; | ||
|
||
return ( | ||
<div className={notificationClass}> | ||
<Notification.Root | ||
title="Cookie Consent" | ||
color="info" | ||
expanded | ||
variant="standard" | ||
icon="Cookie" | ||
> | ||
<Text> | ||
This notification concerns the cookie policy requirement to ask users | ||
for their consent to use <strong>Google Analytics</strong> or other | ||
tracking tools for better optimizations/performances. | ||
</Text> | ||
<Notification.Actions> | ||
<Notification.Button | ||
icon="Check" | ||
color={'positive'} | ||
onClick={handleAccept} | ||
> | ||
Accept | ||
</Notification.Button> | ||
<Notification.Button | ||
icon="Close" | ||
color={'negative'} | ||
onClick={handleReject} | ||
> | ||
Reject | ||
</Notification.Button> | ||
</Notification.Actions> | ||
</Notification.Root> | ||
</div> | ||
); | ||
}; |
13 changes: 13 additions & 0 deletions
13
packages/apps/docs/src/components/CookieConsent/styles.css.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { sprinkles } from '@kadena/react-ui/theme'; | ||
|
||
import { style } from '@vanilla-extract/css'; | ||
|
||
export const notificationClass = style([ | ||
sprinkles({ | ||
position: 'sticky', | ||
top: '$17', | ||
}), | ||
{ | ||
zIndex: 1000, | ||
}, | ||
]); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters