From f112f9813de6869d4c057ad6842c53435e968ad0 Mon Sep 17 00:00:00 2001 From: janWilejan <119548498+janWilejan@users.noreply.github.com> Date: Fri, 21 Jul 2023 22:58:14 +0000 Subject: [PATCH] NotifyReminderPopup uses a custom Popover (#3194) * NotifyReminderPopup uses a custom Popover * fix Popover resizing in storybook * Prettified Code! --------- Co-authored-by: janWilejan <> Co-authored-by: janWilejan --- .../NotifyReminderPopup.module.scss | 5 ++- .../NotifyReminderPopup.tsx | 28 ++------------ web/components/ui/Popover/Popover.module.scss | 37 +++++++++++++++++++ web/components/ui/Popover/Popover.tsx | 36 ++++++++++++++++++ 4 files changed, 80 insertions(+), 26 deletions(-) create mode 100644 web/components/ui/Popover/Popover.module.scss create mode 100644 web/components/ui/Popover/Popover.tsx diff --git a/web/components/ui/NotifyReminderPopup/NotifyReminderPopup.module.scss b/web/components/ui/NotifyReminderPopup/NotifyReminderPopup.module.scss index eb6410d08..1130e0aee 100644 --- a/web/components/ui/NotifyReminderPopup/NotifyReminderPopup.module.scss +++ b/web/components/ui/NotifyReminderPopup/NotifyReminderPopup.module.scss @@ -3,6 +3,7 @@ } .contentbutton { + width: 150px; background-color: transparent; border: none; text-align: left; @@ -12,8 +13,8 @@ .closebutton { position: absolute; - right: 10px; - top: 10px; + right: 0; + top: 0; background-color: transparent; border: none; font-size: 1.3rem; diff --git a/web/components/ui/NotifyReminderPopup/NotifyReminderPopup.tsx b/web/components/ui/NotifyReminderPopup/NotifyReminderPopup.tsx index 333ca74ea..9b3c79142 100644 --- a/web/components/ui/NotifyReminderPopup/NotifyReminderPopup.tsx +++ b/web/components/ui/NotifyReminderPopup/NotifyReminderPopup.tsx @@ -1,7 +1,7 @@ -import { Popover } from 'antd'; import React, { useState, useEffect, FC } from 'react'; import dynamic from 'next/dynamic'; import styles from './NotifyReminderPopup.module.scss'; +import { Popover } from '../Popover/Popover'; // Lazy loaded components @@ -34,13 +34,6 @@ export const NotifyReminderPopup: FC = ({ }, []); const title =
Stay updated!
; - const popupStyle = { - borderRadius: '5px', - cursor: 'pointer', - paddingTop: '10px', - paddingRight: '10px', - fontSize: '14px', - }; const popupClicked = e => { e.stopPropagation(); @@ -58,27 +51,14 @@ export const NotifyReminderPopup: FC = ({ -
- Click and never miss -
- future streams! -
+
Click and never miss future streams!
); return ( mounted && ( - -
{children}
+ + {children} ) ); diff --git a/web/components/ui/Popover/Popover.module.scss b/web/components/ui/Popover/Popover.module.scss new file mode 100644 index 000000000..5fe429315 --- /dev/null +++ b/web/components/ui/Popover/Popover.module.scss @@ -0,0 +1,37 @@ + +.anchor { + position: relative; + left: 50%; + width: 0; + height: 0; +} + +.popover { + background-color: var(--theme-color-components-primary-button-background); + position: absolute; + bottom: 10px; + right: -20px; + border-radius: 5px; + width: max-content; +} + +.popover>.title { + padding: 10px; + padding-bottom: 0; +} + +.popover>.content { + padding: 10px; + padding-top: 0; +} + +// Popover tail +.popover::after { + content: ''; + border: 10px solid transparent; + border-top-color: var(--theme-color-components-primary-button-background); + right: 10px; + position: absolute; +} + + diff --git a/web/components/ui/Popover/Popover.tsx b/web/components/ui/Popover/Popover.tsx new file mode 100644 index 000000000..a7d004bd4 --- /dev/null +++ b/web/components/ui/Popover/Popover.tsx @@ -0,0 +1,36 @@ +import React, { FC, ReactNode } from 'react'; +import styles from './Popover.module.scss'; + +export type PopoverProps = { + open: boolean; + title: ReactNode; + content: ReactNode; + children?: ReactNode; +}; + +/// Replace Popover from antd with a custom popover implementation. +/// +/// The popover is positioned relative to its parent (unlike antd's popover, +/// which uses absolute positioning on the page). +// +// TODO the following properties of antd's popover have not been implemented +// placement ("topRight" is used as default) +// defaultOpen +// destroyTooltipOnHide +// overlayInnerStyle +// color (it uses var(--theme-color-components-primary-button-background)) + +export const Popover: FC = ({ open, title, content, children }) => ( +
+ {open && ( +
+
+
{title}
+
+
{content}
+
+
+ )} + {children} +
+);