Skip to content

Commit

Permalink
feat: configurable text & link
Browse files Browse the repository at this point in the history
  • Loading branch information
hexnickk4997 committed Jun 5, 2024
1 parent 782bf54 commit a3d6113
Showing 1 changed file with 22 additions and 13 deletions.
35 changes: 22 additions & 13 deletions packages/cookies-tooltip/cookies-tooltip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
useState,
useCallback,
ComponentPropsWithoutRef,
ReactNode,
} from 'react'
import { getCrossDomainCookieClientSide } from '../utils/index.js'
import {
Expand All @@ -18,20 +19,17 @@ import {
import { allowCookies, declineCookies } from './utils.js'
import { COOKIE_ALLOWED_KEY } from './constants.js'

const DefaultContent = () => (
<>
Cookies are used to collect anonymous site visitation data to&nbsp;improve
website performance. For&nbsp;more info, read&nbsp;
<ExternalLink href='https://lido.fi/privacy-notice'>
Privacy Notice
</ExternalLink>
</>
)

export type CookiesTooltipProps = ComponentPropsWithoutRef<'div'>
export type CookiesTooltipProps = Omit<
ComponentPropsWithoutRef<'div'>,
'children'
> & {
privacyText?: ReactNode
privacyLink?: string
}

export const CookiesTooltip: FC<CookiesTooltipProps> = ({
children,
privacyText,
privacyLink,
...rest
}) => {
const [isVisible, setVisibility] = useState(false)
Expand Down Expand Up @@ -62,7 +60,18 @@ export const CookiesTooltip: FC<CookiesTooltipProps> = ({
return (
<Wrap {...rest}>
<Box>
<Text>{children ?? <DefaultContent />}</Text>
<Text>
{privacyText ?? (
<>
Cookies are used to collect anonymous site visitation data
to&nbsp;improve website performance. For&nbsp;more info,
read&nbsp;
</>
)}
<ExternalLink href={privacyLink ?? 'https://lido.fi/privacy-notice'}>
Privacy Notice
</ExternalLink>
</Text>
<ButtonsWrap>
<AllowButton
onClick={() => {
Expand Down

0 comments on commit a3d6113

Please sign in to comment.