From ef7a24d571475eb40bb7cadb4efe2e25e5fadbc3 Mon Sep 17 00:00:00 2001 From: Ilya Y <75578537+ilya-bkv@users.noreply.github.com> Date: Mon, 15 Jan 2024 16:22:43 +0300 Subject: [PATCH] fix article card actions (#364) * fix invite modal * change FeedArticlePopup hide logic * resolve conversation --- .../Feed/ArticleCard/ArticleCard.tsx | 4 +-- .../FeedArticlePopup/FeedArticlePopup.tsx | 34 +++++++++++++++---- src/components/Views/Feed/Feed.tsx | 3 ++ src/components/_shared/Popup/Popup.tsx | 13 +++++-- 4 files changed, 43 insertions(+), 11 deletions(-) diff --git a/src/components/Feed/ArticleCard/ArticleCard.tsx b/src/components/Feed/ArticleCard/ArticleCard.tsx index cd1ae0ed..ff275635 100644 --- a/src/components/Feed/ArticleCard/ArticleCard.tsx +++ b/src/components/Feed/ArticleCard/ArticleCard.tsx @@ -52,6 +52,7 @@ export type ArticleCardProps = { desktopCoverSize?: 'XS' | 'S' | 'M' | 'L' article: Shout onShare?: (article: Shout) => void + onInvite?: () => void } const desktopCoverImageWidths: Record = { @@ -368,7 +369,7 @@ export const ArticleCard = (props: ArticleCardProps) => { isOwner={canEdit()} containerCssClass={stylesHeader.control} onShareClick={() => props.onShare(props.article)} - onInviteClick={() => showModal('inviteCoAuthors')} + onInviteClick={props.onInvite} onVisibilityChange={(isVisible) => setIsActionPopupActive(isVisible)} trigger={ @@ -33,6 +47,7 @@ export const FeedArticlePopup = (props: FeedArticlePopupProps) => { role="button" onClick={() => { alert('Help to edit') + setHidden(true) }} > {t('Help to edit')} @@ -40,7 +55,14 @@ export const FeedArticlePopup = (props: FeedArticlePopupProps) => {
  • -
  • diff --git a/src/components/Views/Feed/Feed.tsx b/src/components/Views/Feed/Feed.tsx index 6914a6c7..3ac0a0ef 100644 --- a/src/components/Views/Feed/Feed.tsx +++ b/src/components/Views/Feed/Feed.tsx @@ -17,6 +17,7 @@ import { getImageUrl } from '../../../utils/getImageUrl' import { getServerDate } from '../../../utils/getServerDate' import { DropDown } from '../../_shared/DropDown' import { Icon } from '../../_shared/Icon' +import { InviteCoAuthorsModal } from '../../_shared/InviteCoAuthorsModal' import { Loading } from '../../_shared/Loading' import { ShareModal } from '../../_shared/ShareModal' import { CommentDate } from '../../Article/CommentDate' @@ -290,6 +291,7 @@ export const Feed = (props: Props) => { {(article) => ( handleShare(shared)} + onInvite={() => showModal('inviteCoAuthors')} article={article} settings={{ isFeedMode: true }} desktopCoverSize="M" @@ -416,6 +418,7 @@ export const Feed = (props: Props) => { shareUrl={getShareUrl({ pathname: `/${shareData().slug}` })} /> + ) } diff --git a/src/components/_shared/Popup/Popup.tsx b/src/components/_shared/Popup/Popup.tsx index c0b04aec..4cd31afd 100644 --- a/src/components/_shared/Popup/Popup.tsx +++ b/src/components/_shared/Popup/Popup.tsx @@ -15,6 +15,7 @@ export type PopupProps = { onVisibilityChange?: (isVisible: boolean) => void horizontalAnchor?: HorizontalAnchor variant?: 'bordered' | 'tiny' + closePopup?: (isVisible: boolean) => void } export const Popup = (props: PopupProps) => { @@ -29,13 +30,19 @@ export const Popup = (props: PopupProps) => { const containerRef: { current: HTMLElement } = { current: null } + const closePopup = () => { + setIsVisible(false) + if (props.closePopup) { + props.closePopup + } + } + useOutsideClickHandler({ containerRef, predicate: () => isVisible(), - handler: () => { - setIsVisible(false) - }, + handler: () => closePopup(), }) + const toggle = () => setIsVisible((oldVisible) => !oldVisible) return ( (containerRef.current = el)}>