From 51d07070b377ffab29e524f7a71f748e1f29466b Mon Sep 17 00:00:00 2001 From: Nikita Date: Wed, 5 Jun 2024 17:56:15 +0100 Subject: [PATCH 1/3] feat: added url param --- packages/cookies-tooltip/cookies-tooltip.tsx | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/packages/cookies-tooltip/cookies-tooltip.tsx b/packages/cookies-tooltip/cookies-tooltip.tsx index cccb58f5..4cbd623f 100644 --- a/packages/cookies-tooltip/cookies-tooltip.tsx +++ b/packages/cookies-tooltip/cookies-tooltip.tsx @@ -1,4 +1,4 @@ -import { FC, useEffect, useState, useCallback } from 'react' +import { FC, useEffect, useState, useCallback, ComponentPropsWithoutRef } from 'react' import { getCrossDomainCookieClientSide } from '../utils/index.js' import { Wrap, @@ -12,7 +12,13 @@ import { import { allowCookies, declineCookies } from './utils.js' import { COOKIE_ALLOWED_KEY } from './constants.js' -export const CookiesTooltip: FC = () => { +export type CookiesTooltipProps = ComponentPropsWithoutRef<'div'> & { + privacyNoticeUrl?: string +} + +export const CookiesTooltip: FC = ({ + privacyNoticeUrl = 'https://lido.fi/privacy-notice' +}) => { const [isVisible, setVisibility] = useState(false) const checkCookieAllowedEarlier = useCallback(() => { @@ -44,7 +50,7 @@ export const CookiesTooltip: FC = () => { Cookies are used to collect anonymous site visitation data to improve website performance. For more info, read  - + Privacy Notice From 782bf546d4a45cb1300401dd7bbdea11847414cb Mon Sep 17 00:00:00 2001 From: Nikita Date: Wed, 5 Jun 2024 18:03:23 +0100 Subject: [PATCH 2/3] feat: changed to default content --- packages/cookies-tooltip/cookies-tooltip.tsx | 35 ++++++++++++-------- 1 file changed, 22 insertions(+), 13 deletions(-) diff --git a/packages/cookies-tooltip/cookies-tooltip.tsx b/packages/cookies-tooltip/cookies-tooltip.tsx index 4cbd623f..a51ff59c 100644 --- a/packages/cookies-tooltip/cookies-tooltip.tsx +++ b/packages/cookies-tooltip/cookies-tooltip.tsx @@ -1,4 +1,10 @@ -import { FC, useEffect, useState, useCallback, ComponentPropsWithoutRef } from 'react' +import { + FC, + useEffect, + useState, + useCallback, + ComponentPropsWithoutRef, +} from 'react' import { getCrossDomainCookieClientSide } from '../utils/index.js' import { Wrap, @@ -12,12 +18,21 @@ import { import { allowCookies, declineCookies } from './utils.js' import { COOKIE_ALLOWED_KEY } from './constants.js' -export type CookiesTooltipProps = ComponentPropsWithoutRef<'div'> & { - privacyNoticeUrl?: string -} +const DefaultContent = () => ( + <> + Cookies are used to collect anonymous site visitation data to improve + website performance. For more info, read  + + Privacy Notice + + +) + +export type CookiesTooltipProps = ComponentPropsWithoutRef<'div'> export const CookiesTooltip: FC = ({ - privacyNoticeUrl = 'https://lido.fi/privacy-notice' + children, + ...rest }) => { const [isVisible, setVisibility] = useState(false) @@ -45,15 +60,9 @@ export const CookiesTooltip: FC = ({ if (!isVisible) return <> return ( - + - - Cookies are used to collect anonymous site visitation data - to improve website performance. For more info, read  - - Privacy Notice - - + {children ?? } { From a3d6113b6bffe36bf3c835f00eaa487072c30ed8 Mon Sep 17 00:00:00 2001 From: Nikita Date: Wed, 5 Jun 2024 18:23:50 +0100 Subject: [PATCH 3/3] feat: configurable text & link --- packages/cookies-tooltip/cookies-tooltip.tsx | 35 ++++++++++++-------- 1 file changed, 22 insertions(+), 13 deletions(-) diff --git a/packages/cookies-tooltip/cookies-tooltip.tsx b/packages/cookies-tooltip/cookies-tooltip.tsx index a51ff59c..acfd09e8 100644 --- a/packages/cookies-tooltip/cookies-tooltip.tsx +++ b/packages/cookies-tooltip/cookies-tooltip.tsx @@ -4,6 +4,7 @@ import { useState, useCallback, ComponentPropsWithoutRef, + ReactNode, } from 'react' import { getCrossDomainCookieClientSide } from '../utils/index.js' import { @@ -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 improve - website performance. For more info, read  - - Privacy Notice - - -) - -export type CookiesTooltipProps = ComponentPropsWithoutRef<'div'> +export type CookiesTooltipProps = Omit< + ComponentPropsWithoutRef<'div'>, + 'children' +> & { + privacyText?: ReactNode + privacyLink?: string +} export const CookiesTooltip: FC = ({ - children, + privacyText, + privacyLink, ...rest }) => { const [isVisible, setVisibility] = useState(false) @@ -62,7 +60,18 @@ export const CookiesTooltip: FC = ({ return ( - {children ?? } + + {privacyText ?? ( + <> + Cookies are used to collect anonymous site visitation data + to improve website performance. For more info, + read  + + )} + + Privacy Notice + + {