diff --git a/packages/shared/src/components/Feed.spec.tsx b/packages/shared/src/components/Feed.spec.tsx index 31091a0d5f..96b39dffcc 100644 --- a/packages/shared/src/components/Feed.spec.tsx +++ b/packages/shared/src/components/Feed.spec.tsx @@ -75,14 +75,28 @@ import { acquisitionKey } from './cards/AcquisitionForm/common/common'; const showLogin = jest.fn(); let nextCallback: (value: PostsEngaged) => unknown = null; -jest.mock('../hooks/useBookmarkProvider', () => ({ - __esModule: true, - default: jest - .fn() - .mockImplementation((): { highlightBookmarkedPost: boolean } => ({ +jest.mock('../hooks', () => { + const originalModule = jest.requireActual('../hooks'); + return { + __esModule: true, + ...originalModule, + useBookmarkProvider: (): { highlightBookmarkedPost: boolean } => ({ highlightBookmarkedPost: false, - })), -})); + }), + useSubscription: { + default: jest + .fn() + .mockImplementation( + ( + request: () => OperationOptions, + { next }: SubscriptionCallbacks, + ): void => { + nextCallback = next; + }, + ), + }, + }; +}); jest.mock('../hooks/useSubscription', () => ({ __esModule: true, @@ -108,6 +122,7 @@ beforeEach(() => { jest.restoreAllMocks(); jest.clearAllMocks(); nock.cleanAll(); + jest.clearAllMocks(); variables = defaultVariables; }); diff --git a/packages/shared/src/components/FeedItemComponent.tsx b/packages/shared/src/components/FeedItemComponent.tsx index 2316a18d39..b2780b237f 100644 --- a/packages/shared/src/components/FeedItemComponent.tsx +++ b/packages/shared/src/components/FeedItemComponent.tsx @@ -1,24 +1,19 @@ import React, { FunctionComponent, ReactElement } from 'react'; import dynamic from 'next/dynamic'; import { FeedItem } from '../hooks/useFeed'; -import { ArticlePostCard } from './cards/ArticlePostCard'; -import { ArticlePostList } from './cards/list/ArticlePostList'; -import { PlaceholderCard } from './cards/PlaceholderCard'; -import { PlaceholderList } from './cards/list/PlaceholderList'; +import { PlaceholderGrid } from './cards/placeholder/PlaceholderGrid'; +import { PlaceholderList } from './cards/placeholder/PlaceholderList'; import { Ad, Post, PostItem, PostType } from '../graphql/posts'; import { LoggedUser } from '../lib/user'; import { CommentOnData } from '../graphql/comments'; import useLogImpression from '../hooks/feed/useLogImpression'; import { FeedPostClick } from '../hooks/feed/useFeedOnPostClick'; -import { SharePostCard } from './cards/SharePostCard'; -import { SharePostList } from './cards/list/SharePostList'; import { Origin } from '../lib/log'; import { useFeedLayout, UseVotePost } from '../hooks'; -import { CollectionCard } from './cards/CollectionCard'; -import { CollectionList } from './cards/list/CollectionList'; +import { CollectionList } from './cards/collection/CollectionList'; import { MarketingCtaCard } from './marketingCta'; import { MarketingCtaList } from './marketingCta/MarketingCtaList'; -import { FeedItemType } from './cards/common'; +import { FeedItemType } from './cards/common/common'; import { AdGrid } from './cards/ad/AdGrid'; import { AdList } from './cards/ad/AdList'; import { AcquisitionFormGrid } from './cards/AcquisitionForm/AcquisitionFormGrid'; @@ -26,9 +21,17 @@ import { AcquisitionFormList } from './cards/AcquisitionForm/AcquisitionFormList import { FreeformGrid } from './cards/Freeform/FreeformGrid'; import { FreeformList } from './cards/Freeform/FreeformList'; import { PostClick } from '../lib/click'; +import { ArticleList } from './cards/article/ArticleList'; +import { ArticleGrid } from './cards/article/ArticleGrid'; +import { ShareGrid } from './cards/share/ShareGrid'; +import { ShareList } from './cards/share/ShareList'; +import { CollectionGrid } from './cards/collection'; const CommentPopup = dynamic( - () => import(/* webpackChunkName: "commentPopup" */ './cards/CommentPopup'), + () => + import( + /* webpackChunkName: "commentPopup" */ './cards/common/CommentPopup' + ), ); export type FeedItemComponentProps = { @@ -90,20 +93,20 @@ export function getFeedItemKey(item: FeedItem, index: number): string { } const PostTypeToTagCard: Record = { - [PostType.Article]: ArticlePostCard, - [PostType.Share]: SharePostCard, + [PostType.Article]: ArticleGrid, + [PostType.Share]: ShareGrid, [PostType.Welcome]: FreeformGrid, [PostType.Freeform]: FreeformGrid, - [PostType.VideoYouTube]: ArticlePostCard, - [PostType.Collection]: CollectionCard, + [PostType.VideoYouTube]: ArticleGrid, + [PostType.Collection]: CollectionGrid, }; const PostTypeToTagList: Record = { - [PostType.Article]: ArticlePostList, - [PostType.Share]: SharePostList, + [PostType.Article]: ArticleList, + [PostType.Share]: ShareList, [PostType.Welcome]: FreeformList, [PostType.Freeform]: FreeformList, - [PostType.VideoYouTube]: ArticlePostList, + [PostType.VideoYouTube]: ArticleList, [PostType.Collection]: CollectionList, }; @@ -121,10 +124,10 @@ const getTags = ({ const useListCards = isListFeedLayout || shouldUseListMode; return { PostTag: useListCards - ? PostTypeToTagList[postType] ?? ArticlePostList - : PostTypeToTagCard[postType] ?? ArticlePostCard, + ? PostTypeToTagList[postType] ?? ArticleList + : PostTypeToTagCard[postType] ?? ArticleGrid, AdTag: useListCards ? AdList : AdGrid, - PlaceholderTag: useListCards ? PlaceholderList : PlaceholderCard, + PlaceholderTag: useListCards ? PlaceholderList : PlaceholderGrid, MarketingCtaTag: useListCards ? MarketingCtaList : MarketingCtaCard, AcquisitionFormTag: useListCards ? AcquisitionFormList diff --git a/packages/shared/src/components/cards/AcquisitionForm/AcquisitionFormGrid.tsx b/packages/shared/src/components/cards/AcquisitionForm/AcquisitionFormGrid.tsx index 2e65ab07d0..d108c77250 100644 --- a/packages/shared/src/components/cards/AcquisitionForm/AcquisitionFormGrid.tsx +++ b/packages/shared/src/components/cards/AcquisitionForm/AcquisitionFormGrid.tsx @@ -1,5 +1,5 @@ import React, { ReactElement } from 'react'; -import { Card } from '../Card'; +import { Card } from '../common/Card'; import { AcquisitionFormInner } from './common/AcquisitionFormInner'; export function AcquisitionFormGrid(): ReactElement { diff --git a/packages/shared/src/components/cards/AcquisitionForm/AcquisitionFormList.tsx b/packages/shared/src/components/cards/AcquisitionForm/AcquisitionFormList.tsx index 177b7810f2..7e7e888759 100644 --- a/packages/shared/src/components/cards/AcquisitionForm/AcquisitionFormList.tsx +++ b/packages/shared/src/components/cards/AcquisitionForm/AcquisitionFormList.tsx @@ -1,5 +1,5 @@ import React, { ReactElement } from 'react'; -import { ListCard } from '../list/ListCard'; +import { ListCard } from '../common/list/ListCard'; import { AcquisitionFormInner } from './common/AcquisitionFormInner'; export function AcquisitionFormList(): ReactElement { diff --git a/packages/shared/src/components/cards/CollectionCard/index.ts b/packages/shared/src/components/cards/CollectionCard/index.ts deleted file mode 100644 index 4eb2989b68..0000000000 --- a/packages/shared/src/components/cards/CollectionCard/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './CollectionCard'; diff --git a/packages/shared/src/components/cards/FeedbackCard.tsx b/packages/shared/src/components/cards/FeedbackCard.tsx deleted file mode 100644 index 60c48216ab..0000000000 --- a/packages/shared/src/components/cards/FeedbackCard.tsx +++ /dev/null @@ -1,65 +0,0 @@ -import React, { MouseEventHandler, ReactElement } from 'react'; -import { - Button, - ButtonColor, - ButtonSize, - ButtonVariant, -} from '../buttons/Button'; -import { DownvoteIcon, UpvoteIcon } from '../icons'; -import { Post, UserVote } from '../../graphql/posts'; -import { usePostFeedback } from '../../hooks'; -import CloseButton from '../CloseButton'; - -interface FeedbackCardProps { - post: Post; - onUpvoteClick: MouseEventHandler; - onDownvoteClick: MouseEventHandler; -} - -export const FeedbackCard = ({ - post, - onUpvoteClick, - onDownvoteClick, -}: FeedbackCardProps): ReactElement => { - const { dismissFeedback } = usePostFeedback({ post }); - - return ( -
-
-

- Want to see more posts like this? -

- -
-
-
-
- ); -}; diff --git a/packages/shared/src/components/cards/Freeform/FreeformGrid.tsx b/packages/shared/src/components/cards/Freeform/FreeformGrid.tsx index 007d65a674..06b89ba6f2 100644 --- a/packages/shared/src/components/cards/Freeform/FreeformGrid.tsx +++ b/packages/shared/src/components/cards/Freeform/FreeformGrid.tsx @@ -1,18 +1,18 @@ import React, { forwardRef, ReactElement, Ref, useRef } from 'react'; import classNames from 'classnames'; -import { Container, generateTitleClamp, PostCardProps } from '../common'; +import { Container, generateTitleClamp, PostCardProps } from '../common/common'; import { usePostImage } from '../../../hooks/post/usePostImage'; import { useSquadChecklist } from '../../../hooks/useSquadChecklist'; import { Squad } from '../../../graphql/sources'; import { PostType } from '../../../graphql/posts'; import { ActionType } from '../../../graphql/actions'; -import FeedItemContainer from '../FeedItemContainer'; -import { FreeformCardTitle, getPostClassNames } from '../Card'; +import FeedItemContainer from '../common/FeedItemContainer'; +import { FreeformCardTitle, getPostClassNames } from '../common/Card'; import CardOverlay from '../common/CardOverlay'; import OptionsButton from '../../buttons/OptionsButton'; import { SquadPostCardHeader } from '../common/SquadPostCardHeader'; -import PostMetadata from '../PostMetadata'; -import { WelcomePostCardFooter } from '../WelcomePostCardFooter'; +import PostMetadata from '../common/PostMetadata'; +import { WelcomePostCardFooter } from '../common/WelcomePostCardFooter'; import ActionButtons from '../ActionsButtons/ActionButtons'; export const FreeformGrid = forwardRef(function SharePostCard( diff --git a/packages/shared/src/components/cards/Freeform/FreeformList.tsx b/packages/shared/src/components/cards/Freeform/FreeformList.tsx index f36696ae9a..05b71c6790 100644 --- a/packages/shared/src/components/cards/Freeform/FreeformList.tsx +++ b/packages/shared/src/components/cards/Freeform/FreeformList.tsx @@ -2,7 +2,7 @@ import React, { forwardRef, ReactElement, Ref, useMemo, useRef } from 'react'; import classNames from 'classnames'; import { sanitize } from 'dompurify'; -import { Container, generateTitleClamp, PostCardProps } from '../common'; +import { Container, generateTitleClamp, PostCardProps } from '../common/common'; import { useSquadChecklist } from '../../../hooks/useSquadChecklist'; import { Squad } from '../../../graphql/sources'; import { ActionType } from '../../../graphql/actions'; @@ -11,11 +11,11 @@ import { useFeedPreviewMode, useTruncatedSummary } from '../../../hooks'; import { usePostImage } from '../../../hooks/post/usePostImage'; import SquadHeaderPicture from '../common/SquadHeaderPicture'; import { PostContentReminder } from '../../post/common/PostContentReminder'; -import FeedItemContainer from '../list/FeedItemContainer'; -import { CardContainer, CardContent, CardTitle } from '../list/ListCard'; -import { PostCardHeader } from '../list/PostCardHeader'; -import { CardCoverList } from '../list/CardCover'; -import ActionButtons from '../list/ActionButtons'; +import FeedItemContainer from '../common/list/FeedItemContainer'; +import { CardContainer, CardContent, CardTitle } from '../common/list/ListCard'; +import { PostCardHeader } from '../common/list/PostCardHeader'; +import { CardCoverList } from '../common/list/CardCover'; +import ActionButtons from '../common/list/ActionButtons'; export const FreeformList = forwardRef(function SharePostCard( { diff --git a/packages/shared/src/components/cards/SimilarPosts/PostEngagementCounts.tsx b/packages/shared/src/components/cards/SimilarPosts/PostEngagementCounts.tsx index 6ca76b3928..f077f91ffd 100644 --- a/packages/shared/src/components/cards/SimilarPosts/PostEngagementCounts.tsx +++ b/packages/shared/src/components/cards/SimilarPosts/PostEngagementCounts.tsx @@ -1,6 +1,6 @@ import React, { ReactElement } from 'react'; import classNames from 'classnames'; -import { separatorCharacter } from '../common'; +import { separatorCharacter } from '../common/common'; import { largeNumberFormat } from '../../../lib'; interface PostEngagementCountsProps { diff --git a/packages/shared/src/components/cards/ad/AdGrid.tsx b/packages/shared/src/components/cards/ad/AdGrid.tsx index f115038962..b566a35fb2 100644 --- a/packages/shared/src/components/cards/ad/AdGrid.tsx +++ b/packages/shared/src/components/cards/ad/AdGrid.tsx @@ -5,7 +5,7 @@ import { CardSpace, CardTextContainer, CardTitle, -} from '../Card'; +} from '../common/Card'; import AdLink from './common/AdLink'; import AdAttribution from './common/AdAttribution'; import { AdImage } from './common/AdImage'; diff --git a/packages/shared/src/components/cards/ad/AdList.tsx b/packages/shared/src/components/cards/ad/AdList.tsx index 08a133ec95..413705b5ac 100644 --- a/packages/shared/src/components/cards/ad/AdList.tsx +++ b/packages/shared/src/components/cards/ad/AdList.tsx @@ -4,9 +4,14 @@ import React, { ReactElement, Ref, } from 'react'; -import { CardContent, CardImage, CardSpace, CardTitle } from '../list/ListCard'; +import { + CardContent, + CardImage, + CardSpace, + CardTitle, +} from '../common/list/ListCard'; import AdAttribution from './common/AdAttribution'; -import FeedItemContainer from '../list/FeedItemContainer'; +import FeedItemContainer from '../common/list/FeedItemContainer'; import type { AdCardProps } from './common/common'; import { AdImage } from './common/AdImage'; import { AdPixel } from './common/AdPixel'; diff --git a/packages/shared/src/components/cards/ad/common/AdLink.tsx b/packages/shared/src/components/cards/ad/common/AdLink.tsx index 6248f5e8b7..78ce9a9e85 100644 --- a/packages/shared/src/components/cards/ad/common/AdLink.tsx +++ b/packages/shared/src/components/cards/ad/common/AdLink.tsx @@ -1,6 +1,6 @@ import React, { ReactElement } from 'react'; import { Ad } from '../../../../graphql/posts'; -import { CardLink } from '../../Card'; +import { CardLink } from '../../common/Card'; import { combinedClicks } from '../../../../lib/click'; export type AdLinkProps = { diff --git a/packages/shared/src/components/cards/ArticlePostCard.spec.tsx b/packages/shared/src/components/cards/article/ArticleGrid.spec.tsx similarity index 93% rename from packages/shared/src/components/cards/ArticlePostCard.spec.tsx rename to packages/shared/src/components/cards/article/ArticleGrid.spec.tsx index 362c425ac0..7a079a6534 100644 --- a/packages/shared/src/components/cards/ArticlePostCard.spec.tsx +++ b/packages/shared/src/components/cards/article/ArticleGrid.spec.tsx @@ -7,11 +7,11 @@ import { waitFor, } from '@testing-library/react'; import { QueryClient } from '@tanstack/react-query'; -import { ArticlePostCard } from './ArticlePostCard'; -import post from '../../../__tests__/fixture/post'; -import { PostCardProps, visibleOnGroupHover } from './common'; -import { PostType } from '../../graphql/posts'; -import { TestBootProvider } from '../../../__tests__/helpers/boot'; +import post from '../../../../__tests__/fixture/post'; +import { PostCardProps, visibleOnGroupHover } from '../common/common'; +import { PostType } from '../../../graphql/posts'; +import { TestBootProvider } from '../../../../__tests__/helpers/boot'; +import { ArticleGrid } from './ArticleGrid'; const defaultProps: PostCardProps = { post, @@ -31,7 +31,7 @@ beforeEach(() => { const renderComponent = (props: Partial = {}): RenderResult => { return render( - + , ); }; diff --git a/packages/shared/src/components/cards/ArticlePostCard.tsx b/packages/shared/src/components/cards/article/ArticleGrid.tsx similarity index 79% rename from packages/shared/src/components/cards/ArticlePostCard.tsx rename to packages/shared/src/components/cards/article/ArticleGrid.tsx index 1d4776caf6..7abd213c6e 100644 --- a/packages/shared/src/components/cards/ArticlePostCard.tsx +++ b/packages/shared/src/components/cards/article/ArticleGrid.tsx @@ -1,28 +1,28 @@ import React, { forwardRef, ReactElement, Ref } from 'react'; import classNames from 'classnames'; +import { Container, PostCardProps } from '../common/common'; +import { useBlockPostPanel } from '../../../hooks/post/useBlockPostPanel'; +import { usePostFeedback } from '../../../hooks'; +import { isVideoPost } from '../../../graphql/posts'; +import { PostTagsPanel } from '../../post/block/PostTagsPanel'; +import FeedItemContainer from '../common/FeedItemContainer'; import { CardSpace, CardTextContainer, CardTitle, getPostClassNames, -} from './Card'; -import PostMetadata from './PostMetadata'; -import ActionButtons from './ActionsButtons/ActionButtons'; -import { PostCardHeader } from './PostCardHeader'; -import { PostCardFooter } from './PostCardFooter'; -import { Container, PostCardProps } from './common'; -import FeedItemContainer from './FeedItemContainer'; -import { useBlockPostPanel } from '../../hooks/post/useBlockPostPanel'; -import { PostTagsPanel } from '../post/block/PostTagsPanel'; -import { usePostFeedback } from '../../hooks'; -import styles from './Card.module.css'; -import { FeedbackCard } from './FeedbackCard'; -import { Origin } from '../../lib/log'; -import { isVideoPost } from '../../graphql/posts'; -import CardOverlay from './common/CardOverlay'; -import PostTags from './PostTags'; +} from '../common/Card'; +import CardOverlay from '../common/CardOverlay'; +import { Origin } from '../../../lib/log'; +import styles from '../common/Card.module.css'; +import { PostCardHeader } from '../common/PostCardHeader'; +import PostTags from '../common/PostTags'; +import PostMetadata from '../common/PostMetadata'; +import { PostCardFooter } from '../common/PostCardFooter'; +import ActionButtons from '../ActionsButtons'; +import { FeedbackGrid } from './feedback/FeedbackGrid'; -export const ArticlePostCard = forwardRef(function PostCard( +export const ArticleGrid = forwardRef(function ArticleGrid( { post, onPostClick, @@ -80,7 +80,7 @@ export const ArticlePostCard = forwardRef(function PostCard( onPostCardAuxClick={onPostCardAuxClick} /> {showFeedback && ( - onUpvoteClick(post, Origin.FeedbackCard)} onDownvoteClick={() => onDownvoteClick(post, Origin.FeedbackCard)} diff --git a/packages/shared/src/components/cards/list/ArticlePostList.tsx b/packages/shared/src/components/cards/article/ArticleList.tsx similarity index 86% rename from packages/shared/src/components/cards/list/ArticlePostList.tsx rename to packages/shared/src/components/cards/article/ArticleList.tsx index 17c9b4300c..ebe6d45906 100644 --- a/packages/shared/src/components/cards/list/ArticlePostList.tsx +++ b/packages/shared/src/components/cards/article/ArticleList.tsx @@ -1,27 +1,27 @@ import React, { forwardRef, ReactElement, Ref } from 'react'; import classNames from 'classnames'; -import Link from '../../utilities/Link'; -import { CardContainer, CardContent, CardTitle } from './ListCard'; -import ActionButtons from './ActionButtons'; -import { PostCardHeader } from './PostCardHeader'; -import { Container, PostCardProps } from '../common'; -import FeedItemContainer from './FeedItemContainer'; +import { Container, PostCardProps } from '../common/common'; +import { isVideoPost } from '../../../graphql/posts'; import { useFeedPreviewMode, usePostFeedback, useTruncatedSummary, } from '../../../hooks'; -import { FeedbackList } from './FeedbackList'; +import FeedItemContainer from '../common/list/FeedItemContainer'; +import { combinedClicks } from '../../../lib/click'; import { Origin } from '../../../lib/log'; -import SourceButton from '../SourceButton'; -import { isVideoPost } from '../../../graphql/posts'; -import PostReadTime from './PostReadTime'; -import PostTags from '../PostTags'; -import { CardCoverList } from './CardCover'; +import { CardContainer, CardContent, CardTitle } from '../common/list/ListCard'; +import { PostCardHeader } from '../common/list/PostCardHeader'; +import Link from '../../utilities/Link'; +import PostReadTime from '../common/list/PostReadTime'; +import SourceButton from '../common/SourceButton'; import { ProfileImageSize } from '../../ProfilePicture'; -import { combinedClicks } from '../../../lib/click'; +import PostTags from '../common/PostTags'; +import { CardCoverList } from '../common/list/CardCover'; +import ActionButtons from '../common/list/ActionButtons'; +import { FeedbackList } from './feedback/FeedbackList'; -export const ArticlePostList = forwardRef(function PostCard( +export const ArticleList = forwardRef(function ArticleList( { post, onPostClick, diff --git a/packages/shared/src/components/cards/article/feedback/FeedbackGrid.tsx b/packages/shared/src/components/cards/article/feedback/FeedbackGrid.tsx new file mode 100644 index 0000000000..d101208e7d --- /dev/null +++ b/packages/shared/src/components/cards/article/feedback/FeedbackGrid.tsx @@ -0,0 +1,35 @@ +import React, { ReactElement } from 'react'; +import { usePostFeedback } from '../../../../hooks'; +import CloseButton from '../../../CloseButton'; +import { ButtonSize } from '../../../buttons/common'; +import { FeedbackProps } from './common/common'; +import { FeedbackButtons } from './common/FeedbackButtons'; + +export const FeedbackGrid = ({ + post, + onUpvoteClick, + onDownvoteClick, +}: FeedbackProps): ReactElement => { + const { dismissFeedback } = usePostFeedback({ post }); + + return ( +
+
+

+ Want to see more posts like this? +

+ +
+ +
+ ); +}; diff --git a/packages/shared/src/components/cards/article/feedback/FeedbackList.tsx b/packages/shared/src/components/cards/article/feedback/FeedbackList.tsx new file mode 100644 index 0000000000..35f0952636 --- /dev/null +++ b/packages/shared/src/components/cards/article/feedback/FeedbackList.tsx @@ -0,0 +1,57 @@ +import React, { ReactElement } from 'react'; +import { usePostFeedback } from '../../../../hooks'; +import CloseButton from '../../../CloseButton'; +import { ButtonSize } from '../../../buttons/common'; +import { CardContent } from '../../common/list/ListCard'; +import { CardCoverList } from '../../common/list/CardCover'; +import { FeedbackProps } from './common/common'; +import { FeedbackButtons } from './common/FeedbackButtons'; + +export const FeedbackList = ({ + post, + onUpvoteClick, + onDownvoteClick, + isVideoType, +}: FeedbackProps): ReactElement => { + const { dismissFeedback } = usePostFeedback({ post }); + + return ( +
+
+

+ Want to see more posts like this? +

+ +
+ + +
+

{post.title}

+
+ + +
+
+ ); +}; diff --git a/packages/shared/src/components/cards/article/feedback/common/FeedbackButtons.tsx b/packages/shared/src/components/cards/article/feedback/common/FeedbackButtons.tsx new file mode 100644 index 0000000000..4392d6f1b4 --- /dev/null +++ b/packages/shared/src/components/cards/article/feedback/common/FeedbackButtons.tsx @@ -0,0 +1,36 @@ +import React, { ReactElement } from 'react'; +import { Button, ButtonColor, ButtonVariant } from '../../../../buttons/Button'; +import { UserVote } from '../../../../../graphql/posts'; +import { DownvoteIcon, UpvoteIcon } from '../../../../icons'; +import { FeedbackProps } from './common'; + +export const FeedbackButtons = ({ + post, + onUpvoteClick, + onDownvoteClick, +}: FeedbackProps): ReactElement => { + return ( +
+
+ ); +}; diff --git a/packages/shared/src/components/cards/article/feedback/common/common.tsx b/packages/shared/src/components/cards/article/feedback/common/common.tsx new file mode 100644 index 0000000000..1739f4a263 --- /dev/null +++ b/packages/shared/src/components/cards/article/feedback/common/common.tsx @@ -0,0 +1,9 @@ +import { MouseEventHandler } from 'react'; +import { Post } from '../../../../../graphql/posts'; + +export interface FeedbackProps { + post: Post; + onUpvoteClick: MouseEventHandler; + onDownvoteClick: MouseEventHandler; + isVideoType?: boolean; +} diff --git a/packages/shared/src/components/cards/CollectionCard/CollectionCardHeader.tsx b/packages/shared/src/components/cards/collection/CollectionCardHeader.tsx similarity index 92% rename from packages/shared/src/components/cards/CollectionCard/CollectionCardHeader.tsx rename to packages/shared/src/components/cards/collection/CollectionCardHeader.tsx index 99ac8d998b..40a990719f 100644 --- a/packages/shared/src/components/cards/CollectionCard/CollectionCardHeader.tsx +++ b/packages/shared/src/components/cards/collection/CollectionCardHeader.tsx @@ -3,11 +3,11 @@ import classNames from 'classnames'; import { SourceAvatarProps } from '../../profile/source'; import { CollectionPillSources } from '../../post/collection'; import OptionsButton from '../../buttons/OptionsButton'; -import useBookmarkProvider from '../../../hooks/useBookmarkProvider'; import { BookmakProviderHeader, headerHiddenClassName, -} from '../BookmarkProviderHeader'; +} from '../common/BookmarkProviderHeader'; +import { useBookmarkProvider } from '../../../hooks'; interface CollectionCardHeaderProps { sources: SourceAvatarProps['source'][]; diff --git a/packages/shared/src/components/cards/CollectionCard/CollectionCard.spec.tsx b/packages/shared/src/components/cards/collection/CollectionGrid.spec.tsx similarity index 87% rename from packages/shared/src/components/cards/CollectionCard/CollectionCard.spec.tsx rename to packages/shared/src/components/cards/collection/CollectionGrid.spec.tsx index a68eb38e4e..e4410171c6 100644 --- a/packages/shared/src/components/cards/CollectionCard/CollectionCard.spec.tsx +++ b/packages/shared/src/components/cards/collection/CollectionGrid.spec.tsx @@ -1,9 +1,9 @@ import React from 'react'; import { render, RenderResult, screen, waitFor } from '@testing-library/react'; import { QueryClient } from '@tanstack/react-query'; -import { CollectionCard } from './CollectionCard'; +import { CollectionGrid } from './CollectionGrid'; import { sharePost as collectionPost } from '../../../../__tests__/fixture/post'; -import { PostCardProps } from '../common'; +import { PostCardProps } from '../common/common'; import { TestBootProvider } from '../../../../__tests__/helpers/boot'; const post = collectionPost; @@ -17,14 +17,16 @@ const defaultProps: PostCardProps = { onReadArticleClick: jest.fn(), }; -jest.mock('../../../hooks/useBookmarkProvider', () => ({ - __esModule: true, - default: jest - .fn() - .mockImplementation((): { highlightBookmarkedPost: boolean } => ({ +jest.mock('../../../hooks', () => { + const originalModule = jest.requireActual('../../../hooks'); + return { + __esModule: true, + ...originalModule, + useBookmarkProvider: (): { highlightBookmarkedPost: boolean } => ({ highlightBookmarkedPost: false, - })), -})); + }), + }; +}); beforeEach(() => { jest.clearAllMocks(); @@ -33,7 +35,7 @@ beforeEach(() => { const renderComponent = (props: Partial = {}): RenderResult => { return render( - + , ); }; diff --git a/packages/shared/src/components/cards/CollectionCard/CollectionCard.tsx b/packages/shared/src/components/cards/collection/CollectionGrid.tsx similarity index 86% rename from packages/shared/src/components/cards/CollectionCard/CollectionCard.tsx rename to packages/shared/src/components/cards/collection/CollectionGrid.tsx index 47b9454baa..38c5f74b7f 100644 --- a/packages/shared/src/components/cards/CollectionCard/CollectionCard.tsx +++ b/packages/shared/src/components/cards/collection/CollectionGrid.tsx @@ -1,17 +1,21 @@ import React, { forwardRef, Ref } from 'react'; import classNames from 'classnames'; -import { Container, generateTitleClamp, PostCardProps } from '../common'; -import FeedItemContainer from '../FeedItemContainer'; +import { Container, generateTitleClamp, PostCardProps } from '../common/common'; +import FeedItemContainer from '../common/FeedItemContainer'; import { CollectionCardHeader } from './CollectionCardHeader'; -import { getPostClassNames, FreeformCardTitle, CardSpace } from '../Card'; -import { WelcomePostCardFooter } from '../WelcomePostCardFooter'; +import { + getPostClassNames, + FreeformCardTitle, + CardSpace, +} from '../common/Card'; +import { WelcomePostCardFooter } from '../common/WelcomePostCardFooter'; import ActionButtons from '../ActionsButtons/ActionButtons'; -import PostMetadata from '../PostMetadata'; +import PostMetadata from '../common/PostMetadata'; import { usePostImage } from '../../../hooks/post/usePostImage'; import CardOverlay from '../common/CardOverlay'; -import PostTags from '../PostTags'; +import PostTags from '../common/PostTags'; -export const CollectionCard = forwardRef(function CollectionCard( +export const CollectionGrid = forwardRef(function CollectionCard( { children, post, diff --git a/packages/shared/src/components/cards/list/CollectionList.tsx b/packages/shared/src/components/cards/collection/CollectionList.tsx similarity index 87% rename from packages/shared/src/components/cards/list/CollectionList.tsx rename to packages/shared/src/components/cards/collection/CollectionList.tsx index c1200ce7c7..7a3d4c68b8 100644 --- a/packages/shared/src/components/cards/list/CollectionList.tsx +++ b/packages/shared/src/components/cards/collection/CollectionList.tsx @@ -1,15 +1,20 @@ import React, { forwardRef, Ref } from 'react'; import classNames from 'classnames'; -import { Container, generateTitleClamp, PostCardProps } from '../common'; -import FeedItemContainer from './FeedItemContainer'; -import { CardTitle, CardSpace, CardContainer, CardContent } from './ListCard'; -import ActionButtons from './ActionButtons'; +import { Container, generateTitleClamp, PostCardProps } from '../common/common'; +import FeedItemContainer from '../common/list/FeedItemContainer'; +import { + CardTitle, + CardSpace, + CardContainer, + CardContent, +} from '../common/list/ListCard'; +import ActionButtons from '../common/list/ActionButtons'; import { usePostImage } from '../../../hooks/post/usePostImage'; -import { PostCardHeader } from './PostCardHeader'; +import { PostCardHeader } from '../common/list/PostCardHeader'; import { CollectionPillSources } from '../../post/collection'; import { useTruncatedSummary } from '../../../hooks'; -import PostTags from '../PostTags'; -import { CardCoverList } from './CardCover'; +import PostTags from '../common/PostTags'; +import { CardCoverList } from '../common/list/CardCover'; export const CollectionList = forwardRef(function CollectionCard( { diff --git a/packages/shared/src/components/cards/collection/index.ts b/packages/shared/src/components/cards/collection/index.ts new file mode 100644 index 0000000000..aec0722e45 --- /dev/null +++ b/packages/shared/src/components/cards/collection/index.ts @@ -0,0 +1 @@ +export * from './CollectionGrid'; diff --git a/packages/shared/src/components/cards/BookmarkProviderHeader.tsx b/packages/shared/src/components/cards/common/BookmarkProviderHeader.tsx similarity index 96% rename from packages/shared/src/components/cards/BookmarkProviderHeader.tsx rename to packages/shared/src/components/cards/common/BookmarkProviderHeader.tsx index dbc7e0afbb..b1f67b7d04 100644 --- a/packages/shared/src/components/cards/BookmarkProviderHeader.tsx +++ b/packages/shared/src/components/cards/common/BookmarkProviderHeader.tsx @@ -1,7 +1,7 @@ import classNames from 'classnames'; import React, { ReactElement } from 'react'; import { CardHeader } from './Card'; -import { BookmarkIcon } from '../icons'; +import { BookmarkIcon } from '../../icons'; export const bookmarkProviderText = 'Revisit this post you saved earlier?'; export const bookmarkProviderIcon = ; diff --git a/packages/shared/src/components/cards/Card.module.css b/packages/shared/src/components/cards/common/Card.module.css similarity index 100% rename from packages/shared/src/components/cards/Card.module.css rename to packages/shared/src/components/cards/common/Card.module.css diff --git a/packages/shared/src/components/cards/Card.tsx b/packages/shared/src/components/cards/common/Card.tsx similarity index 94% rename from packages/shared/src/components/cards/Card.tsx rename to packages/shared/src/components/cards/common/Card.tsx index 90b328d796..0c3d96d713 100644 --- a/packages/shared/src/components/cards/Card.tsx +++ b/packages/shared/src/components/cards/common/Card.tsx @@ -2,9 +2,9 @@ import React, { HTMLAttributes, ReactNode } from 'react'; import classNames from 'classnames'; import { ReactElement } from 'react-markdown/lib/react-markdown'; import styles from './Card.module.css'; -import classed from '../../lib/classed'; -import { Post } from '../../graphql/posts'; -import { Image } from '../image/Image'; +import classed from '../../../lib/classed'; +import { Post } from '../../../graphql/posts'; +import { Image } from '../../image/Image'; type TitleProps = HTMLAttributes & { lineClamp?: `line-clamp-${number}`; diff --git a/packages/shared/src/components/cards/common/CardCover.tsx b/packages/shared/src/components/cards/common/CardCover.tsx index 79c1e67d67..0b7fe2d560 100644 --- a/packages/shared/src/components/cards/common/CardCover.tsx +++ b/packages/shared/src/components/cards/common/CardCover.tsx @@ -1,6 +1,6 @@ import React, { ReactElement } from 'react'; import { ReusedCardCoverProps, SharedCardCover } from './SharedCardCover'; -import { CardImage } from '../Card'; +import { CardImage } from './Card'; export function CardCover(props: ReusedCardCoverProps): ReactElement { return ( diff --git a/packages/shared/src/components/cards/common/CardOverlay.tsx b/packages/shared/src/components/cards/common/CardOverlay.tsx index e686babf79..48c71597fc 100644 --- a/packages/shared/src/components/cards/common/CardOverlay.tsx +++ b/packages/shared/src/components/cards/common/CardOverlay.tsx @@ -1,5 +1,5 @@ import React, { ReactElement } from 'react'; -import { CardLink } from '../Card'; +import { CardLink } from './Card'; import { useFeedPreviewMode } from '../../../hooks'; import { Post } from '../../../graphql/posts'; import { webappUrl } from '../../../lib/constants'; diff --git a/packages/shared/src/components/cards/CommentPopup.tsx b/packages/shared/src/components/cards/common/CommentPopup.tsx similarity index 91% rename from packages/shared/src/components/cards/CommentPopup.tsx rename to packages/shared/src/components/cards/common/CommentPopup.tsx index fb745f667c..017365c4a5 100644 --- a/packages/shared/src/components/cards/CommentPopup.tsx +++ b/packages/shared/src/components/cards/common/CommentPopup.tsx @@ -1,10 +1,10 @@ import React, { KeyboardEvent, ReactElement, useState } from 'react'; import { requestIdleCallback } from 'next/dist/client/request-idle-callback'; import classNames from 'classnames'; -import commentPopupText from '../../commentPopupText'; -import { DiscussIcon as CommentIcon } from '../icons'; -import { Button, ButtonVariant } from '../buttons/Button'; -import { ModalClose } from '../modals/common/ModalClose'; +import commentPopupText from '../../../commentPopupText'; +import { DiscussIcon as CommentIcon } from '../../icons'; +import { Button, ButtonVariant } from '../../buttons/Button'; +import { ModalClose } from '../../modals/common/ModalClose'; const transitionDuration = 150; diff --git a/packages/shared/src/components/cards/FeedItemContainer.tsx b/packages/shared/src/components/cards/common/FeedItemContainer.tsx similarity index 89% rename from packages/shared/src/components/cards/FeedItemContainer.tsx rename to packages/shared/src/components/cards/common/FeedItemContainer.tsx index 5f70bf5be9..0aafe48938 100644 --- a/packages/shared/src/components/cards/FeedItemContainer.tsx +++ b/packages/shared/src/components/cards/common/FeedItemContainer.tsx @@ -6,16 +6,15 @@ import React, { Ref, } from 'react'; import classNames from 'classnames'; -import { Post } from '../../graphql/posts'; +import { Post } from '../../../graphql/posts'; import { Card } from './Card'; import { RaisedLabel, RaisedLabelContainer, RaisedLabelType, } from './RaisedLabel'; -import ConditionalWrapper from '../ConditionalWrapper'; -import { useFeedPreviewMode } from '../../hooks'; -import useBookmarkProvider from '../../hooks/useBookmarkProvider'; +import ConditionalWrapper from '../../ConditionalWrapper'; +import { useBookmarkProvider, useFeedPreviewMode } from '../../../hooks'; export interface FlagProps extends Pick { listMode?: boolean; diff --git a/packages/shared/src/components/cards/PostCardFooter.tsx b/packages/shared/src/components/cards/common/PostCardFooter.tsx similarity index 89% rename from packages/shared/src/components/cards/PostCardFooter.tsx rename to packages/shared/src/components/cards/common/PostCardFooter.tsx index f3fe79da8c..acb5059647 100644 --- a/packages/shared/src/components/cards/PostCardFooter.tsx +++ b/packages/shared/src/components/cards/common/PostCardFooter.tsx @@ -1,8 +1,8 @@ import React, { ReactElement } from 'react'; import classNames from 'classnames'; -import { isVideoPost, Post } from '../../graphql/posts'; +import { isVideoPost, Post } from '../../../graphql/posts'; import { CommonCardCoverProps } from './common'; -import { CardCover } from './common/CardCover'; +import { CardCover } from './CardCover'; interface PostCardFooterClassName { image?: string; diff --git a/packages/shared/src/components/cards/PostCardHeader.tsx b/packages/shared/src/components/cards/common/PostCardHeader.tsx similarity index 82% rename from packages/shared/src/components/cards/PostCardHeader.tsx rename to packages/shared/src/components/cards/common/PostCardHeader.tsx index 7fad76cde1..8efd32a08a 100644 --- a/packages/shared/src/components/cards/PostCardHeader.tsx +++ b/packages/shared/src/components/cards/common/PostCardHeader.tsx @@ -1,23 +1,22 @@ import React, { ReactElement, ReactNode } from 'react'; import classNames from 'classnames'; -import OptionsButton from '../buttons/OptionsButton'; +import OptionsButton from '../../buttons/OptionsButton'; import { CardHeader } from './Card'; import SourceButton from './SourceButton'; -import { Source } from '../../graphql/sources'; +import { Source } from '../../../graphql/sources'; import { ReadArticleButton } from './ReadArticleButton'; import { getGroupedHoverContainer } from './common'; -import { useFeedPreviewMode } from '../../hooks'; -import { getReadPostButtonText, Post } from '../../graphql/posts'; -import { ButtonVariant } from '../buttons/Button'; +import { useBookmarkProvider, useFeedPreviewMode } from '../../../hooks'; +import { getReadPostButtonText, Post } from '../../../graphql/posts'; +import { ButtonVariant } from '../../buttons/Button'; import { FlagProps } from './FeedItemContainer'; -import useBookmarkProvider from '../../hooks/useBookmarkProvider'; import { BookmakProviderHeader, headerHiddenClassName, } from './BookmarkProviderHeader'; -import { ProfileTooltip } from '../profile/ProfileTooltip'; -import { ProfileImageLink } from '../profile/ProfileImageLink'; -import { ProfileImageSize } from '../ProfilePicture'; +import { ProfileTooltip } from '../../profile/ProfileTooltip'; +import { ProfileImageLink } from '../../profile/ProfileImageLink'; +import { ProfileImageSize } from '../../ProfilePicture'; interface CardHeaderProps { post: Post; diff --git a/packages/shared/src/components/cards/PostMetadata.tsx b/packages/shared/src/components/cards/common/PostMetadata.tsx similarity index 87% rename from packages/shared/src/components/cards/PostMetadata.tsx rename to packages/shared/src/components/cards/common/PostMetadata.tsx index 8efdacc5cd..9efc5b7128 100644 --- a/packages/shared/src/components/cards/PostMetadata.tsx +++ b/packages/shared/src/components/cards/common/PostMetadata.tsx @@ -1,10 +1,10 @@ import React, { ReactElement, ReactNode } from 'react'; import classNames from 'classnames'; -import { TimeFormatType } from '../../lib/dateFormat'; +import { TimeFormatType } from '../../../lib/dateFormat'; import { Separator } from './common'; -import { Post } from '../../graphql/posts'; -import { formatReadTime, TruncateText, DateFormat } from '../utilities'; -import { largeNumberFormat } from '../../lib'; +import { Post } from '../../../graphql/posts'; +import { formatReadTime, TruncateText, DateFormat } from '../../utilities'; +import { largeNumberFormat } from '../../../lib'; interface PostMetadataProps extends Pick { diff --git a/packages/shared/src/components/cards/PostSummary.tsx b/packages/shared/src/components/cards/common/PostSummary.tsx similarity index 91% rename from packages/shared/src/components/cards/PostSummary.tsx rename to packages/shared/src/components/cards/common/PostSummary.tsx index 7f5a7429e4..2314a87d99 100644 --- a/packages/shared/src/components/cards/PostSummary.tsx +++ b/packages/shared/src/components/cards/common/PostSummary.tsx @@ -4,7 +4,7 @@ import React, { ReactElement, RefObject, } from 'react'; -import { SummaryContainer, TLDRText } from '../utilities'; +import { SummaryContainer, TLDRText } from '../../utilities'; import ShowMoreContent from './ShowMoreContent'; interface SummaryProps extends HTMLAttributes { diff --git a/packages/shared/src/components/cards/PostTags.tsx b/packages/shared/src/components/cards/common/PostTags.tsx similarity index 83% rename from packages/shared/src/components/cards/PostTags.tsx rename to packages/shared/src/components/cards/common/PostTags.tsx index a6755e331f..fd0e6b8ee5 100644 --- a/packages/shared/src/components/cards/PostTags.tsx +++ b/packages/shared/src/components/cards/common/PostTags.tsx @@ -1,9 +1,9 @@ import React, { ReactElement, useRef } from 'react'; import classNames from 'classnames'; -import { Post } from '../../graphql/posts'; -import Classed from '../../lib/classed'; -import { useFeedTags } from '../../hooks/feed/useFeedTags'; -import { useFeedLayout } from '../../hooks'; +import { Post } from '../../../graphql/posts'; +import Classed from '../../../lib/classed'; +import { useFeedTags } from '../../../hooks/feed/useFeedTags'; +import { useFeedLayout } from '../../../hooks'; type PostTagsProps = Pick; diff --git a/packages/shared/src/components/cards/RaisedLabel.tsx b/packages/shared/src/components/cards/common/RaisedLabel.tsx similarity index 94% rename from packages/shared/src/components/cards/RaisedLabel.tsx rename to packages/shared/src/components/cards/common/RaisedLabel.tsx index 6b37d4045f..fa50e82ef9 100644 --- a/packages/shared/src/components/cards/RaisedLabel.tsx +++ b/packages/shared/src/components/cards/common/RaisedLabel.tsx @@ -1,7 +1,7 @@ import React, { ReactElement } from 'react'; import classNames from 'classnames'; -import { SimpleTooltip } from '../tooltips/SimpleTooltip'; -import classed from '../../lib/classed'; +import { SimpleTooltip } from '../../tooltips/SimpleTooltip'; +import classed from '../../../lib/classed'; import styles from './Card.module.css'; export enum RaisedLabelType { diff --git a/packages/shared/src/components/cards/ReadArticleButton.tsx b/packages/shared/src/components/cards/common/ReadArticleButton.tsx similarity index 88% rename from packages/shared/src/components/cards/ReadArticleButton.tsx rename to packages/shared/src/components/cards/common/ReadArticleButton.tsx index d9731e3e9f..7bf9e41b3c 100644 --- a/packages/shared/src/components/cards/ReadArticleButton.tsx +++ b/packages/shared/src/components/cards/common/ReadArticleButton.tsx @@ -4,8 +4,8 @@ import { ButtonIconPosition, ButtonProps, ButtonSize, -} from '../buttons/Button'; -import { OpenLinkIcon } from '../icons'; +} from '../../buttons/Button'; +import { OpenLinkIcon } from '../../icons'; type ReadArticleButtonProps = ButtonProps<'a'> & { content: string; diff --git a/packages/shared/src/components/cards/common/SharedCardCover.tsx b/packages/shared/src/components/cards/common/SharedCardCover.tsx index be4f5cbf6d..0d1417284f 100644 --- a/packages/shared/src/components/cards/common/SharedCardCover.tsx +++ b/packages/shared/src/components/cards/common/SharedCardCover.tsx @@ -1,10 +1,10 @@ import React, { ReactElement, ReactNode } from 'react'; import classNames from 'classnames'; -import { CommonCardCoverProps } from '../common'; +import { CommonCardCoverProps } from './common'; import { ImageProps, ImageType } from '../../image/Image'; import VideoImage, { VideoImageProps } from '../../image/VideoImage'; import { useCardCover } from '../../../hooks/feed/useCardCover'; -import { CardImage } from '../Card'; +import { CardImage } from './Card'; interface RenderProps { overlay: ReactNode; diff --git a/packages/shared/src/components/cards/ShowMoreContent.tsx b/packages/shared/src/components/cards/common/ShowMoreContent.tsx similarity index 95% rename from packages/shared/src/components/cards/ShowMoreContent.tsx rename to packages/shared/src/components/cards/common/ShowMoreContent.tsx index 06ae40dbee..19ee76713f 100644 --- a/packages/shared/src/components/cards/ShowMoreContent.tsx +++ b/packages/shared/src/components/cards/common/ShowMoreContent.tsx @@ -1,5 +1,5 @@ import React, { ReactElement, ReactNode, useState } from 'react'; -import { ClickableText } from '../buttons/ClickableText'; +import { ClickableText } from '../../buttons/ClickableText'; interface ShowMoreContentProps { content: string; diff --git a/packages/shared/src/components/cards/SourceButton.tsx b/packages/shared/src/components/cards/common/SourceButton.tsx similarity index 77% rename from packages/shared/src/components/cards/SourceButton.tsx rename to packages/shared/src/components/cards/common/SourceButton.tsx index 2cc8cae42c..cef51df48a 100644 --- a/packages/shared/src/components/cards/SourceButton.tsx +++ b/packages/shared/src/components/cards/common/SourceButton.tsx @@ -1,10 +1,10 @@ import React, { CSSProperties, ReactElement } from 'react'; -import { TooltipPosition } from '../tooltips/BaseTooltipContainer'; -import { LinkWithTooltip } from '../tooltips/LinkWithTooltip'; -import { ProfileImageLink } from '../profile/ProfileImageLink'; -import { ProfileImageSize, ProfilePicture } from '../ProfilePicture'; -import { Source } from '../../graphql/sources'; -import { useFeedPreviewMode } from '../../hooks'; +import { TooltipPosition } from '../../tooltips/BaseTooltipContainer'; +import { LinkWithTooltip } from '../../tooltips/LinkWithTooltip'; +import { ProfileImageLink } from '../../profile/ProfileImageLink'; +import { ProfileImageSize, ProfilePicture } from '../../ProfilePicture'; +import { Source } from '../../../graphql/sources'; +import { useFeedPreviewMode } from '../../../hooks'; interface SourceButtonProps { source: Pick; diff --git a/packages/shared/src/components/cards/common/SquadHeaderPicture.tsx b/packages/shared/src/components/cards/common/SquadHeaderPicture.tsx index 7e2fc5fcfc..af8509a4ab 100644 --- a/packages/shared/src/components/cards/common/SquadHeaderPicture.tsx +++ b/packages/shared/src/components/cards/common/SquadHeaderPicture.tsx @@ -1,6 +1,6 @@ import React, { ReactElement } from 'react'; import { ProfileImageSize } from '../../ProfilePicture'; -import SourceButton from '../SourceButton'; +import SourceButton from './SourceButton'; import { Source } from '../../../graphql/sources'; interface SquadHeaderPictureProps { diff --git a/packages/shared/src/components/cards/common/SquadPostCardHeader.tsx b/packages/shared/src/components/cards/common/SquadPostCardHeader.tsx index 7734d23a81..d2d4e4513f 100644 --- a/packages/shared/src/components/cards/common/SquadPostCardHeader.tsx +++ b/packages/shared/src/components/cards/common/SquadPostCardHeader.tsx @@ -2,14 +2,14 @@ import React, { ReactElement } from 'react'; import classNames from 'classnames'; import { Post } from '../../../graphql/posts'; import { ProfileImageSize } from '../../ProfilePicture'; -import SourceButton from '../SourceButton'; -import useBookmarkProvider from '../../../hooks/useBookmarkProvider'; +import SourceButton from './SourceButton'; import { BookmakProviderHeader, headerHiddenClassName, -} from '../BookmarkProviderHeader'; +} from './BookmarkProviderHeader'; import { ProfileTooltip } from '../../profile/ProfileTooltip'; import { ProfileImageLink } from '../../profile/ProfileImageLink'; +import { useBookmarkProvider } from '../../../hooks'; type SquadPostCardHeaderProps = Pick< Post, diff --git a/packages/shared/src/components/cards/WelcomePostCardFooter.tsx b/packages/shared/src/components/cards/common/WelcomePostCardFooter.tsx similarity index 90% rename from packages/shared/src/components/cards/WelcomePostCardFooter.tsx rename to packages/shared/src/components/cards/common/WelcomePostCardFooter.tsx index 5e166eb4d5..c71e2a8272 100644 --- a/packages/shared/src/components/cards/WelcomePostCardFooter.tsx +++ b/packages/shared/src/components/cards/common/WelcomePostCardFooter.tsx @@ -1,9 +1,9 @@ import React, { ReactElement, useMemo } from 'react'; import { sanitize } from 'dompurify'; import { CardSpace } from './Card'; -import { Post } from '../../graphql/posts'; -import { CardCover } from './common/CardCover'; -import { useCardCover } from '../../hooks/feed/useCardCover'; +import { Post } from '../../../graphql/posts'; +import { CardCover } from './CardCover'; +import { useCardCover } from '../../../hooks/feed/useCardCover'; interface WelcomePostCardFooterProps { post: Post; diff --git a/packages/shared/src/components/cards/common.tsx b/packages/shared/src/components/cards/common/common.tsx similarity index 92% rename from packages/shared/src/components/cards/common.tsx rename to packages/shared/src/components/cards/common/common.tsx index a07fafcb0c..224d64ec0a 100644 --- a/packages/shared/src/components/cards/common.tsx +++ b/packages/shared/src/components/cards/common/common.tsx @@ -4,9 +4,9 @@ import React, { ReactHTML, ReactNode, } from 'react'; -import { Post } from '../../graphql/posts'; -import classed, { ClassedHTML } from '../../lib/classed'; -import { Origin } from '../../lib/log'; +import { Post } from '../../../graphql/posts'; +import classed, { ClassedHTML } from '../../../lib/classed'; +import { Origin } from '../../../lib/log'; export interface CommonCardCoverProps { post?: Post; diff --git a/packages/shared/src/components/cards/list/ActionButtons.tsx b/packages/shared/src/components/cards/common/list/ActionButtons.tsx similarity index 84% rename from packages/shared/src/components/cards/list/ActionButtons.tsx rename to packages/shared/src/components/cards/common/list/ActionButtons.tsx index b907ac89e2..f1712b185f 100644 --- a/packages/shared/src/components/cards/list/ActionButtons.tsx +++ b/packages/shared/src/components/cards/common/list/ActionButtons.tsx @@ -1,25 +1,25 @@ import React, { ReactElement } from 'react'; import classNames from 'classnames'; -import { Post, UserVote } from '../../../graphql/posts'; -import InteractionCounter from '../../InteractionCounter'; +import { Post, UserVote } from '../../../../graphql/posts'; +import InteractionCounter from '../../../InteractionCounter'; import { BookmarkIcon, DownvoteIcon, DiscussIcon as CommentIcon, LinkIcon, -} from '../../icons'; -import { Button, ButtonColor, ButtonVariant } from '../../buttons/Button'; -import { SimpleTooltip } from '../../tooltips/SimpleTooltip'; -import { useFeedPreviewMode } from '../../../hooks'; -import { combinedClicks } from '../../../lib/click'; -import { useBlockPostPanel } from '../../../hooks/post/useBlockPostPanel'; -import ConditionalWrapper from '../../ConditionalWrapper'; -import { PostTagsPanel } from '../../post/block/PostTagsPanel'; -import { IconSize } from '../../Icon'; -import { LinkWithTooltip } from '../../tooltips/LinkWithTooltip'; -import { ActionButtonsProps } from '../ActionsButtons'; -import { UpvoteButtonIcon } from '../ActionsButtons/UpvoteButtonIcon'; -import { BookmarkButton } from '../../buttons'; +} from '../../../icons'; +import { Button, ButtonColor, ButtonVariant } from '../../../buttons/Button'; +import { SimpleTooltip } from '../../../tooltips/SimpleTooltip'; +import { useFeedPreviewMode } from '../../../../hooks'; +import { combinedClicks } from '../../../../lib/click'; +import { useBlockPostPanel } from '../../../../hooks/post/useBlockPostPanel'; +import ConditionalWrapper from '../../../ConditionalWrapper'; +import { PostTagsPanel } from '../../../post/block/PostTagsPanel'; +import { IconSize } from '../../../Icon'; +import { LinkWithTooltip } from '../../../tooltips/LinkWithTooltip'; +import { ActionButtonsProps } from '../../ActionsButtons'; +import { UpvoteButtonIcon } from '../../ActionsButtons/UpvoteButtonIcon'; +import { BookmarkButton } from '../../../buttons'; interface ActionButtonsPropsList extends ActionButtonsProps { onDownvoteClick?: (post: Post) => unknown; diff --git a/packages/shared/src/components/cards/list/BookmarkProviderHeader.tsx b/packages/shared/src/components/cards/common/list/BookmarkProviderHeader.tsx similarity index 100% rename from packages/shared/src/components/cards/list/BookmarkProviderHeader.tsx rename to packages/shared/src/components/cards/common/list/BookmarkProviderHeader.tsx diff --git a/packages/shared/src/components/cards/list/CardCover.tsx b/packages/shared/src/components/cards/common/list/CardCover.tsx similarity index 85% rename from packages/shared/src/components/cards/list/CardCover.tsx rename to packages/shared/src/components/cards/common/list/CardCover.tsx index a1bf566413..eaf3b885e7 100644 --- a/packages/shared/src/components/cards/list/CardCover.tsx +++ b/packages/shared/src/components/cards/common/list/CardCover.tsx @@ -1,10 +1,7 @@ import React, { ReactElement } from 'react'; import classNames from 'classnames'; -import ConditionalWrapper from '../../ConditionalWrapper'; -import { - ReusedCardCoverProps, - SharedCardCover, -} from '../common/SharedCardCover'; +import ConditionalWrapper from '../../../ConditionalWrapper'; +import { ReusedCardCoverProps, SharedCardCover } from '../SharedCardCover'; import { CardImage } from './ListCard'; interface CardCoverProps extends ReusedCardCoverProps { diff --git a/packages/shared/src/components/cards/list/FeedItemContainer.tsx b/packages/shared/src/components/cards/common/list/FeedItemContainer.tsx similarity index 90% rename from packages/shared/src/components/cards/list/FeedItemContainer.tsx rename to packages/shared/src/components/cards/common/list/FeedItemContainer.tsx index a1fd07838d..d337155eb3 100644 --- a/packages/shared/src/components/cards/list/FeedItemContainer.tsx +++ b/packages/shared/src/components/cards/common/list/FeedItemContainer.tsx @@ -8,14 +8,13 @@ import React, { useState, } from 'react'; import classNames from 'classnames'; -import Link from '../../utilities/Link'; -import { Post } from '../../../graphql/posts'; +import Link from '../../../utilities/Link'; +import { Post } from '../../../../graphql/posts'; import { ListCard, CardLink } from './ListCard'; import { RaisedLabel, RaisedLabelType } from './RaisedLabel'; -import { useFeedPreviewMode } from '../../../hooks'; +import { useFeedPreviewMode, useBookmarkProvider } from '../../../../hooks'; import { TypeLabel } from './TypeLabel'; -import { bookmarkProviderListBg } from '../../../styles/custom'; -import useBookmarkProvider from '../../../hooks/useBookmarkProvider'; +import { bookmarkProviderListBg } from '../../../../styles/custom'; interface FeedItemContainerProps { flagProps?: FlagProps; diff --git a/packages/shared/src/components/cards/list/ListCard.tsx b/packages/shared/src/components/cards/common/list/ListCard.tsx similarity index 94% rename from packages/shared/src/components/cards/list/ListCard.tsx rename to packages/shared/src/components/cards/common/list/ListCard.tsx index 3ebcbf805e..7393203c7e 100644 --- a/packages/shared/src/components/cards/list/ListCard.tsx +++ b/packages/shared/src/components/cards/common/list/ListCard.tsx @@ -1,8 +1,8 @@ import React, { HTMLAttributes, ReactNode } from 'react'; import classNames from 'classnames'; import { ReactElement } from 'react-markdown/lib/react-markdown'; -import classed from '../../../lib/classed'; -import { Image } from '../../image/Image'; +import classed from '../../../../lib/classed'; +import { Image } from '../../../image/Image'; type TitleProps = HTMLAttributes & { lineClamp?: `line-clamp-${number}`; diff --git a/packages/shared/src/components/cards/list/PostCardHeader.tsx b/packages/shared/src/components/cards/common/list/PostCardHeader.tsx similarity index 84% rename from packages/shared/src/components/cards/list/PostCardHeader.tsx rename to packages/shared/src/components/cards/common/list/PostCardHeader.tsx index 0896f267ac..1f84e8cd82 100644 --- a/packages/shared/src/components/cards/list/PostCardHeader.tsx +++ b/packages/shared/src/components/cards/common/list/PostCardHeader.tsx @@ -1,20 +1,19 @@ import React, { ReactElement, ReactNode } from 'react'; import classNames from 'classnames'; -import OptionsButton from '../../buttons/OptionsButton'; +import OptionsButton from '../../../buttons/OptionsButton'; import { CardHeader } from './ListCard'; import { ReadArticleButton } from '../ReadArticleButton'; import { getGroupedHoverContainer } from '../common'; -import { useFeedPreviewMode } from '../../../hooks'; -import { Post, PostType } from '../../../graphql/posts'; -import { ButtonVariant } from '../../buttons/common'; +import { useBookmarkProvider, useFeedPreviewMode } from '../../../../hooks'; +import { Post, PostType } from '../../../../graphql/posts'; +import { ButtonVariant } from '../../../buttons/common'; import PostMetadata, { PostMetadataProps } from './PostMetadata'; -import { MenuIcon, OpenLinkIcon } from '../../icons'; +import { MenuIcon, OpenLinkIcon } from '../../../icons'; import { useReadPostButtonText } from './hooks'; -import useBookmarkProvider from '../../../hooks/useBookmarkProvider'; import { BookmakProviderHeader } from './BookmarkProviderHeader'; -import { ProfileImageSize } from '../../ProfilePicture'; -import { ProfileImageLink } from '../../profile/ProfileImageLink'; -import { ProfileTooltip } from '../../profile/ProfileTooltip'; +import { ProfileImageSize } from '../../../ProfilePicture'; +import { ProfileImageLink } from '../../../profile/ProfileImageLink'; +import { ProfileTooltip } from '../../../profile/ProfileTooltip'; interface CardHeaderProps { post: Post; diff --git a/packages/shared/src/components/cards/list/PostMetadata.tsx b/packages/shared/src/components/cards/common/list/PostMetadata.tsx similarity index 88% rename from packages/shared/src/components/cards/list/PostMetadata.tsx rename to packages/shared/src/components/cards/common/list/PostMetadata.tsx index 98e4fe3df7..92b8ac9c49 100644 --- a/packages/shared/src/components/cards/list/PostMetadata.tsx +++ b/packages/shared/src/components/cards/common/list/PostMetadata.tsx @@ -1,8 +1,8 @@ import React, { ReactElement } from 'react'; import classNames from 'classnames'; import { Separator } from '../common'; -import { DateFormat } from '../../utilities'; -import { TimeFormatType } from '../../../lib/dateFormat'; +import { DateFormat } from '../../../utilities'; +import { TimeFormatType } from '../../../../lib/dateFormat'; export interface PostMetadataProps { className?: string; diff --git a/packages/shared/src/components/cards/list/PostReadTime.tsx b/packages/shared/src/components/cards/common/list/PostReadTime.tsx similarity index 84% rename from packages/shared/src/components/cards/list/PostReadTime.tsx rename to packages/shared/src/components/cards/common/list/PostReadTime.tsx index 7db67b48af..90d6fcf226 100644 --- a/packages/shared/src/components/cards/list/PostReadTime.tsx +++ b/packages/shared/src/components/cards/common/list/PostReadTime.tsx @@ -1,6 +1,6 @@ import React, { ReactElement } from 'react'; -import { Post } from '../../../graphql/posts'; -import { formatReadTime } from '../../utilities'; +import { Post } from '../../../../graphql/posts'; +import { formatReadTime } from '../../../utilities'; interface PostReadTimeProps extends Pick { isVideoType?: boolean; diff --git a/packages/shared/src/components/cards/list/RaisedLabel.tsx b/packages/shared/src/components/cards/common/list/RaisedLabel.tsx similarity index 95% rename from packages/shared/src/components/cards/list/RaisedLabel.tsx rename to packages/shared/src/components/cards/common/list/RaisedLabel.tsx index f39cdf2a3b..c7ba4e00ba 100644 --- a/packages/shared/src/components/cards/list/RaisedLabel.tsx +++ b/packages/shared/src/components/cards/common/list/RaisedLabel.tsx @@ -1,6 +1,6 @@ import React, { ReactElement } from 'react'; import classNames from 'classnames'; -import { SimpleTooltip } from '../../tooltips/SimpleTooltip'; +import { SimpleTooltip } from '../../../tooltips/SimpleTooltip'; export enum RaisedLabelType { Hot = 'Hot', diff --git a/packages/shared/src/components/cards/list/SharedPostCardFooter.tsx b/packages/shared/src/components/cards/common/list/SharedPostCardFooter.tsx similarity index 93% rename from packages/shared/src/components/cards/list/SharedPostCardFooter.tsx rename to packages/shared/src/components/cards/common/list/SharedPostCardFooter.tsx index 8048e8cea0..a2d5272c5d 100644 --- a/packages/shared/src/components/cards/list/SharedPostCardFooter.tsx +++ b/packages/shared/src/components/cards/common/list/SharedPostCardFooter.tsx @@ -1,7 +1,7 @@ import classNames from 'classnames'; import React, { ReactElement } from 'react'; -import { Post } from '../../../graphql/posts'; -import { IconSize } from '../../Icon'; +import { Post } from '../../../../graphql/posts'; +import { IconSize } from '../../../Icon'; import { CommonCardCoverProps } from '../common'; import { CardCoverList } from './CardCover'; diff --git a/packages/shared/src/components/cards/list/TypeLabel.tsx b/packages/shared/src/components/cards/common/list/TypeLabel.tsx similarity index 96% rename from packages/shared/src/components/cards/list/TypeLabel.tsx rename to packages/shared/src/components/cards/common/list/TypeLabel.tsx index f9b1a159d4..eb26848173 100644 --- a/packages/shared/src/components/cards/list/TypeLabel.tsx +++ b/packages/shared/src/components/cards/common/list/TypeLabel.tsx @@ -1,6 +1,6 @@ import React, { ReactElement } from 'react'; import classNames from 'classnames'; -import { PostType } from '../../../graphql/posts'; +import { PostType } from '../../../../graphql/posts'; type TypeLabelType = PostType | ReactElement | string; diff --git a/packages/shared/src/components/cards/list/hooks.ts b/packages/shared/src/components/cards/common/list/hooks.ts similarity index 74% rename from packages/shared/src/components/cards/list/hooks.ts rename to packages/shared/src/components/cards/common/list/hooks.ts index 95117c7ceb..839e66957f 100644 --- a/packages/shared/src/components/cards/list/hooks.ts +++ b/packages/shared/src/components/cards/common/list/hooks.ts @@ -1,6 +1,6 @@ -import { Post, getReadPostButtonText } from '../../../graphql/posts'; -import { useMedia } from '../../../hooks'; -import { mobileL, mobileXL } from '../../../styles/media'; +import { Post, getReadPostButtonText } from '../../../../graphql/posts'; +import { useMedia } from '../../../../hooks'; +import { mobileL, mobileXL } from '../../../../styles/media'; const queries = [mobileXL, mobileL].map((q) => q.replace('@media ', '')); diff --git a/packages/shared/src/components/cards/index.ts b/packages/shared/src/components/cards/index.ts deleted file mode 100644 index 263c82631d..0000000000 --- a/packages/shared/src/components/cards/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './FeedbackCard'; diff --git a/packages/shared/src/components/cards/list/FeedbackList.tsx b/packages/shared/src/components/cards/list/FeedbackList.tsx deleted file mode 100644 index f3d3b82434..0000000000 --- a/packages/shared/src/components/cards/list/FeedbackList.tsx +++ /dev/null @@ -1,89 +0,0 @@ -import React, { MouseEventHandler, ReactElement } from 'react'; -import { - Button, - ButtonColor, - ButtonSize, - ButtonVariant, -} from '../../buttons/Button'; -import { DownvoteIcon, UpvoteIcon } from '../../icons'; -import { Post, UserVote } from '../../../graphql/posts'; -import { usePostFeedback } from '../../../hooks'; -import CloseButton from '../../CloseButton'; -import { CardContent } from './ListCard'; -import { CardCoverList } from './CardCover'; - -interface FeedbackCardProps { - post: Post; - onUpvoteClick: MouseEventHandler; - onDownvoteClick: MouseEventHandler; - isVideoType?: boolean; -} - -export const FeedbackList = ({ - post, - onUpvoteClick, - onDownvoteClick, - isVideoType, -}: FeedbackCardProps): ReactElement => { - const { dismissFeedback } = usePostFeedback({ post }); - - return ( -
-
-

- Want to see more posts like this? -

- -
-
-
- - -
-

{post.title}

-
- - -
-
- ); -}; diff --git a/packages/shared/src/components/cards/PlaceholderCard.tsx b/packages/shared/src/components/cards/placeholder/PlaceholderGrid.tsx similarity index 66% rename from packages/shared/src/components/cards/PlaceholderCard.tsx rename to packages/shared/src/components/cards/placeholder/PlaceholderGrid.tsx index 6c28ee842b..a9a4d68999 100644 --- a/packages/shared/src/components/cards/PlaceholderCard.tsx +++ b/packages/shared/src/components/cards/placeholder/PlaceholderGrid.tsx @@ -1,15 +1,14 @@ -import React, { forwardRef, HTMLAttributes, ReactElement, Ref } from 'react'; +import React, { forwardRef, ReactElement, Ref } from 'react'; import classNames from 'classnames'; -import { CardSpace, CardTextContainer } from './Card'; -import { ElementPlaceholder } from '../ElementPlaceholder'; -import classed from '../../lib/classed'; +import { CardSpace, CardTextContainer } from '../common/Card'; +import { ElementPlaceholder } from '../../ElementPlaceholder'; +import classed from '../../../lib/classed'; +import { PlaceholderProps } from './common/common'; const Text = classed(ElementPlaceholder, 'h-3 rounded-12 my-2'); -export type PlaceholderCardProps = HTMLAttributes; - -export const PlaceholderCard = forwardRef(function PlaceholderCard( - { className, ...props }: PlaceholderCardProps, +export const PlaceholderGrid = forwardRef(function PlaceholderCard( + { className, ...props }: PlaceholderProps, ref: Ref, ): ReactElement { return ( diff --git a/packages/shared/src/components/cards/list/PlaceholderList.tsx b/packages/shared/src/components/cards/placeholder/PlaceholderList.tsx similarity index 83% rename from packages/shared/src/components/cards/list/PlaceholderList.tsx rename to packages/shared/src/components/cards/placeholder/PlaceholderList.tsx index 88a89c77c8..73e4030aab 100644 --- a/packages/shared/src/components/cards/list/PlaceholderList.tsx +++ b/packages/shared/src/components/cards/placeholder/PlaceholderList.tsx @@ -1,15 +1,18 @@ -import React, { forwardRef, HTMLAttributes, ReactElement, Ref } from 'react'; +import React, { forwardRef, ReactElement, Ref } from 'react'; import classNames from 'classnames'; -import { ListCard, CardSpace, CardTextContainer } from './ListCard'; +import { + ListCard, + CardSpace, + CardTextContainer, +} from '../common/list/ListCard'; import { ElementPlaceholder } from '../../ElementPlaceholder'; import classed from '../../../lib/classed'; +import { PlaceholderProps } from './common/common'; const Text = classed(ElementPlaceholder, 'rounded-12'); -export type PlaceholderCardProps = HTMLAttributes; - export const PlaceholderList = forwardRef(function PlaceholderCard( - { className, ...props }: PlaceholderCardProps, + { className, ...props }: PlaceholderProps, ref: Ref, ): ReactElement { return ( diff --git a/packages/shared/src/components/cards/placeholder/common/common.tsx b/packages/shared/src/components/cards/placeholder/common/common.tsx new file mode 100644 index 0000000000..7279022d70 --- /dev/null +++ b/packages/shared/src/components/cards/placeholder/common/common.tsx @@ -0,0 +1,3 @@ +import { HTMLAttributes } from 'react'; + +export type PlaceholderProps = HTMLAttributes; diff --git a/packages/shared/src/components/cards/SharePostCard.spec.tsx b/packages/shared/src/components/cards/share/ShareGrid.spec.tsx similarity index 84% rename from packages/shared/src/components/cards/SharePostCard.spec.tsx rename to packages/shared/src/components/cards/share/ShareGrid.spec.tsx index 00d4b59ac2..da9e847364 100644 --- a/packages/shared/src/components/cards/SharePostCard.spec.tsx +++ b/packages/shared/src/components/cards/share/ShareGrid.spec.tsx @@ -1,11 +1,11 @@ import React from 'react'; import { render, RenderResult, screen, waitFor } from '@testing-library/react'; import { QueryClient } from '@tanstack/react-query'; -import { SharePostCard } from './SharePostCard'; -import { sharePost } from '../../../__tests__/fixture/post'; -import { PostCardProps } from './common'; -import { PostType } from '../../graphql/posts'; -import { TestBootProvider } from '../../../__tests__/helpers/boot'; +import { sharePost } from '../../../../__tests__/fixture/post'; +import { PostCardProps } from '../common/common'; +import { PostType } from '../../../graphql/posts'; +import { TestBootProvider } from '../../../../__tests__/helpers/boot'; +import { ShareGrid } from './ShareGrid'; const post = sharePost; const defaultProps: PostCardProps = { @@ -19,14 +19,16 @@ const defaultProps: PostCardProps = { onReadArticleClick: jest.fn(), }; -jest.mock('../../hooks/useBookmarkProvider', () => ({ - __esModule: true, - default: jest - .fn() - .mockImplementation((): { highlightBookmarkedPost: boolean } => ({ +jest.mock('../../../hooks', () => { + const originalModule = jest.requireActual('../../../hooks'); + return { + __esModule: true, + ...originalModule, + useBookmarkProvider: (): { highlightBookmarkedPost: boolean } => ({ highlightBookmarkedPost: false, - })), -})); + }), + }; +}); beforeEach(() => { jest.clearAllMocks(); @@ -35,7 +37,7 @@ beforeEach(() => { const renderComponent = (props: Partial = {}): RenderResult => { return render( - + , ); }; diff --git a/packages/shared/src/components/cards/SharePostCard.tsx b/packages/shared/src/components/cards/share/ShareGrid.tsx similarity index 81% rename from packages/shared/src/components/cards/SharePostCard.tsx rename to packages/shared/src/components/cards/share/ShareGrid.tsx index 4fba9c5321..0339262916 100644 --- a/packages/shared/src/components/cards/SharePostCard.tsx +++ b/packages/shared/src/components/cards/share/ShareGrid.tsx @@ -1,21 +1,21 @@ import React, { forwardRef, ReactElement, Ref, useRef } from 'react'; +import { Container, PostCardProps } from '../common/common'; +import { isVideoPost } from '../../../graphql/posts'; +import FeedItemContainer from '../common/FeedItemContainer'; import { CardSpace, CardTextContainer, CardTitle, getPostClassNames, -} from './Card'; -import ActionButtons from './ActionsButtons/ActionButtons'; -import { Container, PostCardProps } from './common'; -import FeedItemContainer from './FeedItemContainer'; -import { isVideoPost } from '../../graphql/posts'; -import CardOverlay from './common/CardOverlay'; -import { PostCardHeader } from './PostCardHeader'; -import { PostCardFooter } from './PostCardFooter'; -import PostMetadata from './PostMetadata'; -import PostTags from './PostTags'; +} from '../common/Card'; +import CardOverlay from '../common/CardOverlay'; +import { PostCardHeader } from '../common/PostCardHeader'; +import PostTags from '../common/PostTags'; +import PostMetadata from '../common/PostMetadata'; +import { PostCardFooter } from '../common/PostCardFooter'; +import ActionButtons from '../ActionsButtons'; -export const SharePostCard = forwardRef(function SharePostCard( +export const ShareGrid = forwardRef(function ShareGrid( { post, onPostClick, diff --git a/packages/shared/src/components/cards/list/SharePostList.tsx b/packages/shared/src/components/cards/share/ShareList.tsx similarity index 87% rename from packages/shared/src/components/cards/list/SharePostList.tsx rename to packages/shared/src/components/cards/share/ShareList.tsx index 7d4fbdba86..3515acf1cf 100644 --- a/packages/shared/src/components/cards/list/SharePostList.tsx +++ b/packages/shared/src/components/cards/share/ShareList.tsx @@ -1,19 +1,19 @@ import React, { forwardRef, ReactElement, Ref, useRef } from 'react'; import classNames from 'classnames'; -import Link from '../../utilities/Link'; -import ActionButtons from './ActionButtons'; -import { Container, PostCardProps } from '../common'; -import FeedItemContainer from './FeedItemContainer'; +import { Container, PostCardProps } from '../common/common'; import { useFeedPreviewMode, useTruncatedSummary } from '../../../hooks'; import { isVideoPost } from '../../../graphql/posts'; -import { PostCardHeader } from './PostCardHeader'; -import { CardCoverList } from './CardCover'; -import { CardContent, CardTitle } from './ListCard'; -import PostTags from '../PostTags'; -import SourceButton from '../SourceButton'; +import FeedItemContainer from '../common/list/FeedItemContainer'; +import { PostCardHeader } from '../common/list/PostCardHeader'; +import Link from '../../utilities/Link'; +import SourceButton from '../common/SourceButton'; import { ProfileImageSize } from '../../ProfilePicture'; +import { CardContent, CardTitle } from '../common/list/ListCard'; +import PostTags from '../common/PostTags'; +import { CardCoverList } from '../common/list/CardCover'; +import ActionButtons from '../common/list/ActionButtons'; -export const SharePostList = forwardRef(function SharePostCard( +export const ShareList = forwardRef(function ShareList( { post, onPostClick, diff --git a/packages/shared/src/components/cards/squad/PlaceholderSquadGrid.tsx b/packages/shared/src/components/cards/squad/PlaceholderSquadGrid.tsx index a11cd72491..f24ce11fd3 100644 --- a/packages/shared/src/components/cards/squad/PlaceholderSquadGrid.tsx +++ b/packages/shared/src/components/cards/squad/PlaceholderSquadGrid.tsx @@ -1,6 +1,6 @@ import React, { ComponentProps, ReactElement } from 'react'; import classNames from 'classnames'; -import { CardTextContainer } from '../Card'; +import { CardTextContainer } from '../common/Card'; import { ElementPlaceholder } from '../../ElementPlaceholder'; interface PlaceholderSquadGridProps extends ComponentProps<'div'> { diff --git a/packages/shared/src/components/cards/squad/SquadGrid.tsx b/packages/shared/src/components/cards/squad/SquadGrid.tsx index a86957ccad..7cae32f297 100644 --- a/packages/shared/src/components/cards/squad/SquadGrid.tsx +++ b/packages/shared/src/components/cards/squad/SquadGrid.tsx @@ -3,7 +3,7 @@ import classNames from 'classnames'; import { useRouter } from 'next/router'; import Link from 'next/link'; import SquadMemberShortList from '../../squads/SquadMemberShortList'; -import { Card, CardLink } from '../Card'; +import { Card, CardLink } from '../common/Card'; import { Image, ImageType } from '../../image/Image'; import { cloudinary } from '../../../lib/image'; import { UnFeaturedSquadCardProps } from './common/types'; diff --git a/packages/shared/src/components/cards/squad/SquadList.tsx b/packages/shared/src/components/cards/squad/SquadList.tsx index ce89a69b9a..27560bc120 100644 --- a/packages/shared/src/components/cards/squad/SquadList.tsx +++ b/packages/shared/src/components/cards/squad/SquadList.tsx @@ -7,9 +7,9 @@ import { TypographyColor, TypographyType, } from '../../typography/Typography'; -import { Separator } from '../common'; +import { Separator } from '../common/common'; import { largeNumberFormat } from '../../../lib'; -import { CardLink } from '../Card'; +import { CardLink } from '../common/Card'; import { SquadActionButton } from '../../squads/SquadActionButton'; import { Origin } from '../../../lib/log'; import { Image, ImageType } from '../../image/Image'; diff --git a/packages/shared/src/components/cards/squad/UnfeaturedSquadGrid.tsx b/packages/shared/src/components/cards/squad/UnfeaturedSquadGrid.tsx index 546bab4878..9d867a2382 100644 --- a/packages/shared/src/components/cards/squad/UnfeaturedSquadGrid.tsx +++ b/packages/shared/src/components/cards/squad/UnfeaturedSquadGrid.tsx @@ -1,7 +1,7 @@ import React, { ReactElement } from 'react'; import { useRouter } from 'next/router'; import classNames from 'classnames'; -import { Card, CardLink } from '../Card'; +import { Card, CardLink } from '../common/Card'; import { Typography, TypographyColor, @@ -9,7 +9,7 @@ import { TypographyType, } from '../../typography/Typography'; import { largeNumberFormat } from '../../../lib'; -import { Separator } from '../common'; +import { Separator } from '../common/common'; import { UnFeaturedSquadCardProps } from './common/types'; import { Origin } from '../../../lib/log'; import { SquadActionButton } from '../../squads/SquadActionButton'; diff --git a/packages/shared/src/components/checklist/ChecklistCard.tsx b/packages/shared/src/components/checklist/ChecklistCard.tsx index d45328951b..26449349d2 100644 --- a/packages/shared/src/components/checklist/ChecklistCard.tsx +++ b/packages/shared/src/components/checklist/ChecklistCard.tsx @@ -1,6 +1,6 @@ import React, { ReactElement } from 'react'; import classNames from 'classnames'; -import { ChecklistCardComponent } from '../cards/Card'; +import { ChecklistCardComponent } from '../cards/common/Card'; import { ChecklistStep } from './ChecklistStep'; import { ChecklistCardProps, diff --git a/packages/shared/src/components/comments/CommentContainer.tsx b/packages/shared/src/components/comments/CommentContainer.tsx index 2a16de50bc..7280e89a57 100644 --- a/packages/shared/src/components/comments/CommentContainer.tsx +++ b/packages/shared/src/components/comments/CommentContainer.tsx @@ -15,7 +15,7 @@ import CommentAuthor from './CommentAuthor'; import { CommentPublishDate } from './CommentPublishDate'; import { useMemberRoleForSource } from '../../hooks/useMemberRoleForSource'; import { CommentClassName } from '../fields/MarkdownInput/CommentMarkdownInput'; -import { CardLink } from '../cards/Card'; +import { CardLink } from '../cards/common/Card'; import { ReputationUserBadge } from '../ReputationUserBadge'; import { VerifiedCompanyUserBadge } from '../VerifiedCompanyUserBadge'; diff --git a/packages/shared/src/components/image/VideoImage.tsx b/packages/shared/src/components/image/VideoImage.tsx index d08c32c6a0..94f498d4b5 100644 --- a/packages/shared/src/components/image/VideoImage.tsx +++ b/packages/shared/src/components/image/VideoImage.tsx @@ -3,7 +3,7 @@ import classNames from 'classnames'; import { PlayIcon } from '../icons'; import { IconSize } from '../Icon'; import { ImageProps, ImageType } from './Image'; -import { CardImage } from '../cards/Card'; +import { CardImage } from '../cards/common/Card'; export interface VideoImageProps { size?: IconSize; diff --git a/packages/shared/src/components/index.ts b/packages/shared/src/components/index.ts index ff84280e8e..bc011e410f 100644 --- a/packages/shared/src/components/index.ts +++ b/packages/shared/src/components/index.ts @@ -3,7 +3,6 @@ export * from './search'; export * from './sources'; export * from './squads'; export * from './RenderMarkdown'; -export * from './cards'; export * from './withFeaturesBoundary'; export * from './KeyboardShortcutLabel'; export * from './ReputationUserBadge'; diff --git a/packages/shared/src/components/marketingCta/MarketingCtaCard.tsx b/packages/shared/src/components/marketingCta/MarketingCtaCard.tsx index fd46e32b23..b789d321ef 100644 --- a/packages/shared/src/components/marketingCta/MarketingCtaCard.tsx +++ b/packages/shared/src/components/marketingCta/MarketingCtaCard.tsx @@ -1,5 +1,5 @@ import React, { ReactElement, useCallback, useEffect, useRef } from 'react'; -import { Card } from '../cards/Card'; +import { Card } from '../cards/common/Card'; import { CardCover } from '../cards/common/CardCover'; import { CTAButton, Description, Header, MarketingCta, Title } from './common'; import { useBoot } from '../../hooks'; diff --git a/packages/shared/src/components/marketingCta/MarketingCtaList.tsx b/packages/shared/src/components/marketingCta/MarketingCtaList.tsx index 9c883a69ff..89a98be3bb 100644 --- a/packages/shared/src/components/marketingCta/MarketingCtaList.tsx +++ b/packages/shared/src/components/marketingCta/MarketingCtaList.tsx @@ -1,10 +1,10 @@ import React, { ReactElement, useCallback, useEffect, useRef } from 'react'; -import { ListCard } from '../cards/list/ListCard'; +import { ListCard } from '../cards/common/list/ListCard'; import { useBoot } from '../../hooks'; import { useLogContext } from '../../contexts/LogContext'; import { LogEvent, TargetType } from '../../lib/log'; import { CTAButton, Description, Header, MarketingCta, Title } from './common'; -import { CardCoverList } from '../cards/list/CardCover'; +import { CardCoverList } from '../cards/common/list/CardCover'; export function MarketingCtaList({ marketingCta, diff --git a/packages/shared/src/components/marketingCta/common.tsx b/packages/shared/src/components/marketingCta/common.tsx index 67d5c07d63..f98a74499d 100644 --- a/packages/shared/src/components/marketingCta/common.tsx +++ b/packages/shared/src/components/marketingCta/common.tsx @@ -1,7 +1,7 @@ import React, { ReactElement } from 'react'; import { Button, ButtonSize, ButtonVariant } from '../buttons/Button'; import { MiniCloseIcon } from '../icons'; -import { CardTitle } from '../cards/Card'; +import { CardTitle } from '../cards/common/Card'; import classed from '../../lib/classed'; import { anchorDefaultRel } from '../../lib/strings'; import { Pill, PillSize } from '../Pill'; diff --git a/packages/shared/src/components/modals/post/CreateSharedPostModal.tsx b/packages/shared/src/components/modals/post/CreateSharedPostModal.tsx index a92913a3ff..4a593cbc0e 100644 --- a/packages/shared/src/components/modals/post/CreateSharedPostModal.tsx +++ b/packages/shared/src/components/modals/post/CreateSharedPostModal.tsx @@ -12,7 +12,7 @@ import { } from '../../buttons/Button'; import { AtIcon } from '../../icons'; import { Divider, Justify } from '../../utilities'; -import SourceButton from '../../cards/SourceButton'; +import SourceButton from '../../cards/common/SourceButton'; import { Squad } from '../../../graphql/sources'; import { formToJson } from '../../../lib/form'; import { useDebouncedUrl } from '../../../hooks/input'; diff --git a/packages/shared/src/components/notifications/NotificationItemAvatar.tsx b/packages/shared/src/components/notifications/NotificationItemAvatar.tsx index 095f857bf0..9b94d7e08b 100644 --- a/packages/shared/src/components/notifications/NotificationItemAvatar.tsx +++ b/packages/shared/src/components/notifications/NotificationItemAvatar.tsx @@ -3,7 +3,7 @@ import { NotificationAvatar, NotificationAvatarType, } from '../../graphql/notifications'; -import SourceButton from '../cards/SourceButton'; +import SourceButton from '../cards/common/SourceButton'; import { ProfileTooltip } from '../profile/ProfileTooltip'; import { ProfileImageLink } from '../profile/ProfileImageLink'; import { ProfileImageSize } from '../ProfilePicture'; diff --git a/packages/shared/src/components/post/PostActions.tsx b/packages/shared/src/components/post/PostActions.tsx index 02f6a55719..e7c34ea8cf 100644 --- a/packages/shared/src/components/post/PostActions.tsx +++ b/packages/shared/src/components/post/PostActions.tsx @@ -12,7 +12,7 @@ import { QuaternaryButton } from '../buttons/QuaternaryButton'; import { PostOrigin } from '../../hooks/log/useLogContextData'; import { useVotePost } from '../../hooks'; import { Origin } from '../../lib/log'; -import { Card } from '../cards/Card'; +import { Card } from '../cards/common/Card'; import ConditionalWrapper from '../ConditionalWrapper'; import { PostTagsPanel } from './block/PostTagsPanel'; import { useBlockPostPanel } from '../../hooks/post/useBlockPostPanel'; diff --git a/packages/shared/src/components/post/PostContent.tsx b/packages/shared/src/components/post/PostContent.tsx index f3e9bc83b3..40377b7c82 100644 --- a/packages/shared/src/components/post/PostContent.tsx +++ b/packages/shared/src/components/post/PostContent.tsx @@ -2,8 +2,8 @@ import classNames from 'classnames'; import React, { ComponentProps, ReactElement, useEffect } from 'react'; import dynamic from 'next/dynamic'; import { isVideoPost } from '../../graphql/posts'; -import PostMetadata from '../cards/PostMetadata'; -import PostSummary from '../cards/PostSummary'; +import PostMetadata from '../cards/common/PostMetadata'; +import PostSummary from '../cards/common/PostSummary'; import { LazyImage } from '../LazyImage'; import { PostWidgets } from './PostWidgets'; import { TagLinks } from '../TagLinks'; diff --git a/packages/shared/src/components/post/PostItemCard.tsx b/packages/shared/src/components/post/PostItemCard.tsx index 1acb7684b1..1d574d8b6e 100644 --- a/packages/shared/src/components/post/PostItemCard.tsx +++ b/packages/shared/src/components/post/PostItemCard.tsx @@ -10,7 +10,7 @@ import { DownvoteIcon, } from '../icons'; import classed from '../../lib/classed'; -import PostMetadata from '../cards/PostMetadata'; +import PostMetadata from '../cards/common/PostMetadata'; import { ProfileImageSize, ProfilePicture } from '../ProfilePicture'; import { Image } from '../image/Image'; import ConditionalWrapper from '../ConditionalWrapper'; diff --git a/packages/shared/src/components/post/PostSourceInfo.tsx b/packages/shared/src/components/post/PostSourceInfo.tsx index e7471939a6..e45f820359 100644 --- a/packages/shared/src/components/post/PostSourceInfo.tsx +++ b/packages/shared/src/components/post/PostSourceInfo.tsx @@ -2,8 +2,8 @@ import classNames from 'classnames'; import React, { ReactElement } from 'react'; import Link from 'next/link'; import { Source } from '../../graphql/sources'; -import { Separator } from '../cards/common'; -import SourceButton from '../cards/SourceButton'; +import { Separator } from '../cards/common/common'; +import SourceButton from '../cards/common/SourceButton'; import { ProfileImageSize } from '../ProfilePicture'; interface SourceInfoProps { diff --git a/packages/shared/src/components/post/RelatedPostsWidget.tsx b/packages/shared/src/components/post/RelatedPostsWidget.tsx index 48a40c5909..dbf244e2f1 100644 --- a/packages/shared/src/components/post/RelatedPostsWidget.tsx +++ b/packages/shared/src/components/post/RelatedPostsWidget.tsx @@ -9,8 +9,8 @@ import { RELATED_POSTS_PER_PAGE_DEFAULT, } from '../../graphql/posts'; import { SourceAvatar } from '../profile/source'; -import PostMetadata from '../cards/PostMetadata'; -import { CardLink } from '../cards/Card'; +import PostMetadata from '../cards/common/PostMetadata'; +import { CardLink } from '../cards/common/Card'; import { useRelatedPosts } from '../../hooks/post'; import { ProfileImageSize } from '../ProfilePicture'; diff --git a/packages/shared/src/components/post/SharePostContent.tsx b/packages/shared/src/components/post/SharePostContent.tsx index 0a573e5cd4..052e99899b 100644 --- a/packages/shared/src/components/post/SharePostContent.tsx +++ b/packages/shared/src/components/post/SharePostContent.tsx @@ -1,6 +1,6 @@ import React, { ReactElement, useContext } from 'react'; import PostSourceInfo from './PostSourceInfo'; -import { ReadArticleButton } from '../cards/ReadArticleButton'; +import { ReadArticleButton } from '../cards/common/ReadArticleButton'; import { LazyImage } from '../LazyImage'; import { cloudinary } from '../../lib/image'; import { diff --git a/packages/shared/src/components/post/SquadPostAuthor.tsx b/packages/shared/src/components/post/SquadPostAuthor.tsx index fee9480969..b89e0c6647 100644 --- a/packages/shared/src/components/post/SquadPostAuthor.tsx +++ b/packages/shared/src/components/post/SquadPostAuthor.tsx @@ -9,7 +9,7 @@ import { import SquadMemberBadge from '../squads/SquadMemberBadge'; import { Author } from '../../graphql/comments'; import { SourceMemberRole } from '../../graphql/sources'; -import { Separator } from '../cards/common'; +import { Separator } from '../cards/common/common'; import { ReputationUserBadge } from '../ReputationUserBadge'; import { TruncateText, DateFormat } from '../utilities'; import { TimeFormatType } from '../../lib/dateFormat'; diff --git a/packages/shared/src/components/post/SquadPostWidgets.tsx b/packages/shared/src/components/post/SquadPostWidgets.tsx index b3a63ed23f..4fb1c86ece 100644 --- a/packages/shared/src/components/post/SquadPostWidgets.tsx +++ b/packages/shared/src/components/post/SquadPostWidgets.tsx @@ -6,7 +6,7 @@ import AuthContext, { useAuthContext } from '../../contexts/AuthContext'; import ShareBar from '../ShareBar'; import FurtherReading from '../widgets/FurtherReading'; import { PostHeaderActions } from './PostHeaderActions'; -import SourceButton from '../cards/SourceButton'; +import SourceButton from '../cards/common/SourceButton'; import { SourceMember, Squad } from '../../graphql/sources'; import { SquadActionButton } from '../squads/SquadActionButton'; import { Origin } from '../../lib/log'; diff --git a/packages/shared/src/components/post/collection/CollectionPostContent.tsx b/packages/shared/src/components/post/collection/CollectionPostContent.tsx index 51129cc051..01e79179d7 100644 --- a/packages/shared/src/components/post/collection/CollectionPostContent.tsx +++ b/packages/shared/src/components/post/collection/CollectionPostContent.tsx @@ -7,7 +7,7 @@ import PostContentContainer from '../PostContentContainer'; import usePostContent from '../../../hooks/usePostContent'; import { BasePostContent } from '../BasePostContent'; import { cloudinary } from '../../../lib/image'; -import { Separator } from '../../cards/common'; +import { Separator } from '../../cards/common/common'; import { TimeFormatType } from '../../../lib/dateFormat'; import Markdown from '../../Markdown'; import { CollectionPostWidgets } from './CollectionPostWidgets'; diff --git a/packages/shared/src/components/post/common/SharedLinkContainer.tsx b/packages/shared/src/components/post/common/SharedLinkContainer.tsx index 0d9f1c4933..1b791a73ea 100644 --- a/packages/shared/src/components/post/common/SharedLinkContainer.tsx +++ b/packages/shared/src/components/post/common/SharedLinkContainer.tsx @@ -1,6 +1,6 @@ import React, { ReactElement, ReactNode, useState } from 'react'; import classNames from 'classnames'; -import PostSummary from '../../cards/PostSummary'; +import PostSummary from '../../cards/common/PostSummary'; import { ArrowIcon } from '../../icons'; interface SharedLinkContainerProps { diff --git a/packages/shared/src/components/post/freeform/write/WritePostHeader.tsx b/packages/shared/src/components/post/freeform/write/WritePostHeader.tsx index 52bfbbc8c9..cdc40059e9 100644 --- a/packages/shared/src/components/post/freeform/write/WritePostHeader.tsx +++ b/packages/shared/src/components/post/freeform/write/WritePostHeader.tsx @@ -1,5 +1,5 @@ import React, { ReactElement } from 'react'; -import SourceButton from '../../../cards/SourceButton'; +import SourceButton from '../../../cards/common/SourceButton'; import { useWritePostContext } from '../../../../contexts'; interface WritePostHeaderProps { diff --git a/packages/shared/src/components/profile/SquadsList.tsx b/packages/shared/src/components/profile/SquadsList.tsx index ec442b9679..52391ff05c 100644 --- a/packages/shared/src/components/profile/SquadsList.tsx +++ b/packages/shared/src/components/profile/SquadsList.tsx @@ -6,7 +6,7 @@ import { SourceMember, SourceMemberRole } from '../../graphql/sources'; import { largeNumberFormat } from '../../lib/numberFormat'; import { Image } from '../image/Image'; import SquadMemberBadge from '../squads/SquadMemberBadge'; -import { CardLink } from '../cards/Card'; +import { CardLink } from '../cards/common/Card'; import { PlusIcon } from '../icons'; import { ButtonSize, ButtonVariant } from '../buttons/common'; import { Button } from '../buttons/Button'; diff --git a/packages/shared/src/components/profile/UserMetadata.tsx b/packages/shared/src/components/profile/UserMetadata.tsx index 1d322a1cfd..7d4b6f592a 100644 --- a/packages/shared/src/components/profile/UserMetadata.tsx +++ b/packages/shared/src/components/profile/UserMetadata.tsx @@ -2,7 +2,7 @@ import React, { ReactElement } from 'react'; import classNames from 'classnames'; import { PublicProfile } from '../../lib/user'; import JoinedDate from './JoinedDate'; -import { Separator } from '../cards/common'; +import { Separator } from '../cards/common/common'; import { ReputationUserBadge } from '../ReputationUserBadge'; import { IconSize } from '../Icon'; import { TruncateText, truncateTextClassNames } from '../utilities'; diff --git a/packages/shared/src/components/profile/devcard/DevCard.tsx b/packages/shared/src/components/profile/devcard/DevCard.tsx index 334f1d03c9..a3b188dca4 100644 --- a/packages/shared/src/components/profile/devcard/DevCard.tsx +++ b/packages/shared/src/components/profile/devcard/DevCard.tsx @@ -1,6 +1,6 @@ import React, { ReactElement } from 'react'; import classNames from 'classnames'; -import { Separator } from '../../cards/common'; +import { Separator } from '../../cards/common/common'; import { TimeFormatType } from '../../../lib/dateFormat'; import { DateFormat, Divider } from '../../utilities'; import ConditionalWrapper from '../../ConditionalWrapper'; diff --git a/packages/shared/src/components/profile/devcard/DevCardFooter.tsx b/packages/shared/src/components/profile/devcard/DevCardFooter.tsx index 4e8d2cab0f..2d0496a2ba 100644 --- a/packages/shared/src/components/profile/devcard/DevCardFooter.tsx +++ b/packages/shared/src/components/profile/devcard/DevCardFooter.tsx @@ -2,7 +2,7 @@ import React, { ReactElement } from 'react'; import classNames from 'classnames'; import { TagLinks } from '../../TagLinks'; import { ButtonVariant } from '../../buttons/common'; -import SourceButton from '../../cards/SourceButton'; +import SourceButton from '../../cards/common/SourceButton'; import Logo, { LogoPosition } from '../../Logo'; import { DevCardTheme, DevCardType } from './common'; import { Source } from '../../../graphql/sources'; diff --git a/packages/shared/src/components/search/SearchFeedback.tsx b/packages/shared/src/components/search/SearchFeedback.tsx index 17a6d2f296..feefaf1d08 100644 --- a/packages/shared/src/components/search/SearchFeedback.tsx +++ b/packages/shared/src/components/search/SearchFeedback.tsx @@ -2,7 +2,7 @@ import React, { ReactElement } from 'react'; import classNames from 'classnames'; import { WidgetContainer } from '../widgets/common'; import { FeedbackIcon, DocsIcon } from '../icons'; -import { ListCardDivider } from '../cards/Card'; +import { ListCardDivider } from '../cards/common/Card'; import { searchDocs, searchFeedback } from '../../lib/constants'; import { WithClassNameProps } from '../utilities'; import { Button, ButtonSize, ButtonVariant } from '../buttons/Button'; diff --git a/packages/shared/src/components/squads/PromotionTour.tsx b/packages/shared/src/components/squads/PromotionTour.tsx index 6e2b507fd2..d4895a3ee2 100644 --- a/packages/shared/src/components/squads/PromotionTour.tsx +++ b/packages/shared/src/components/squads/PromotionTour.tsx @@ -12,7 +12,7 @@ import { capitalize } from '../../lib/strings'; import { ProfileImageSize, ProfilePicture } from '../ProfilePicture'; import { useAuthContext } from '../../contexts/AuthContext'; import { IconSize } from '../Icon'; -import SourceButton from '../cards/SourceButton'; +import SourceButton from '../cards/common/SourceButton'; interface PromotionTourProps { onClose: React.EventHandler; diff --git a/packages/shared/src/components/squads/SharePostBar.tsx b/packages/shared/src/components/squads/SharePostBar.tsx index 296c787542..f6acb18915 100644 --- a/packages/shared/src/components/squads/SharePostBar.tsx +++ b/packages/shared/src/components/squads/SharePostBar.tsx @@ -4,7 +4,7 @@ import { ProfileImageSize, ProfilePicture } from '../ProfilePicture'; import { Button, ButtonColor, ButtonVariant } from '../buttons/Button'; import { useAuthContext } from '../../contexts/AuthContext'; import { LockIcon } from '../icons'; -import { Card } from '../cards/Card'; +import { Card } from '../cards/common/Card'; import { IconSize } from '../Icon'; import { usePostToSquad, useViewSize, ViewSize } from '../../hooks'; import { ClickableText } from '../buttons/ClickableText'; diff --git a/packages/shared/src/components/squads/SquadCommentJoinBanner.tsx b/packages/shared/src/components/squads/SquadCommentJoinBanner.tsx index e1464a4afd..aa49aa6017 100644 --- a/packages/shared/src/components/squads/SquadCommentJoinBanner.tsx +++ b/packages/shared/src/components/squads/SquadCommentJoinBanner.tsx @@ -9,7 +9,7 @@ import usePersistentContext from '../../hooks/usePersistentContext'; import { useJoinSquad, useViewSize, ViewSize } from '../../hooks'; import { labels } from '../../lib'; import { useToastNotification } from '../../hooks/useToastNotification'; -import SourceButton from '../cards/SourceButton'; +import SourceButton from '../cards/common/SourceButton'; import { SQUAD_COMMENT_JOIN_BANNER_KEY } from '../../graphql/squads'; import { Post } from '../../graphql/posts'; import { ProfileImageSize } from '../ProfilePicture'; diff --git a/packages/shared/src/components/squads/SquadPageHeader.tsx b/packages/shared/src/components/squads/SquadPageHeader.tsx index 97a3f1dbd8..b698238dd8 100644 --- a/packages/shared/src/components/squads/SquadPageHeader.tsx +++ b/packages/shared/src/components/squads/SquadPageHeader.tsx @@ -17,7 +17,7 @@ import classed from '../../lib/classed'; import ConditionalWrapper from '../ConditionalWrapper'; import { link } from '../../lib/links'; import SquadChecklistCard from '../checklist/SquadChecklistCard'; -import { Separator } from '../cards/common'; +import { Separator } from '../cards/common/common'; import { PrivilegedMemberItem } from './Members/PrivilegedMemberItem'; import { formatMonthYearOnly } from '../../lib/dateFormat'; import { diff --git a/packages/shared/src/components/squads/SquadPostListItem.tsx b/packages/shared/src/components/squads/SquadPostListItem.tsx index 6b022f3543..813b416cb5 100644 --- a/packages/shared/src/components/squads/SquadPostListItem.tsx +++ b/packages/shared/src/components/squads/SquadPostListItem.tsx @@ -7,13 +7,13 @@ import { ButtonVariant, } from '../buttons/Button'; import { BookmarkIcon } from '../icons'; -import styles from '../cards/Card.module.css'; +import styles from '../cards/common/Card.module.css'; import { SimpleTooltip } from '../tooltips/SimpleTooltip'; import { Post } from '../../graphql/posts'; import { ElementPlaceholder } from '../ElementPlaceholder'; import { TextPlaceholder } from '../widgets/common'; import SquadPostAuthor from '../post/SquadPostAuthor'; -import { CardLink } from '../cards/Card'; +import { CardLink } from '../cards/common/Card'; import { combinedClicks } from '../../lib/click'; import { ProfileImageSize } from '../ProfilePicture'; diff --git a/packages/shared/src/components/widgets/BestDiscussions.tsx b/packages/shared/src/components/widgets/BestDiscussions.tsx index cae0dfe4ca..d239f5320d 100644 --- a/packages/shared/src/components/widgets/BestDiscussions.tsx +++ b/packages/shared/src/components/widgets/BestDiscussions.tsx @@ -3,8 +3,8 @@ import classNames from 'classnames'; import Link from '../utilities/Link'; import { ArrowIcon } from '../icons'; import { Post } from '../../graphql/posts'; -import styles from '../cards/Card.module.css'; -import { CardLink } from '../cards/Card'; +import styles from '../cards/common/Card.module.css'; +import { CardLink } from '../cards/common/Card'; import { ElementPlaceholder } from '../ElementPlaceholder'; import classed from '../../lib/classed'; import { postLogEvent } from '../../lib/feed'; diff --git a/packages/shared/src/components/widgets/FurtherReading.spec.tsx b/packages/shared/src/components/widgets/FurtherReading.spec.tsx index 16b0f29fe4..b52b5fdcc1 100644 --- a/packages/shared/src/components/widgets/FurtherReading.spec.tsx +++ b/packages/shared/src/components/widgets/FurtherReading.spec.tsx @@ -28,14 +28,16 @@ import { ActionType } from '../../graphql/actions'; const showLogin = jest.fn(); -jest.mock('../../hooks/useBookmarkProvider', () => ({ - __esModule: true, - default: jest - .fn() - .mockImplementation((): { highlightBookmarkedPost: boolean } => ({ +jest.mock('../../hooks', () => { + const originalModule = jest.requireActual('../../hooks'); + return { + __esModule: true, + ...originalModule, + useBookmarkProvider: (): { highlightBookmarkedPost: boolean } => ({ highlightBookmarkedPost: false, - })), -})); + }), + }; +}); beforeEach(() => { jest.restoreAllMocks(); diff --git a/packages/shared/src/components/widgets/SimilarPosts.tsx b/packages/shared/src/components/widgets/SimilarPosts.tsx index dfbc282145..a389d25fe2 100644 --- a/packages/shared/src/components/widgets/SimilarPosts.tsx +++ b/packages/shared/src/components/widgets/SimilarPosts.tsx @@ -3,9 +3,9 @@ import classNames from 'classnames'; import Link from '../utilities/Link'; import { ArrowIcon, BookmarkIcon } from '../icons'; import { Post } from '../../graphql/posts'; -import styles from '../cards/Card.module.css'; +import styles from '../cards/common/Card.module.css'; import { LazyImage } from '../LazyImage'; -import { CardLink } from '../cards/Card'; +import { CardLink } from '../cards/common/Card'; import { ElementPlaceholder } from '../ElementPlaceholder'; import classed from '../../lib/classed'; import { postLogEvent } from '../../lib/feed'; diff --git a/packages/shared/src/hooks/index.ts b/packages/shared/src/hooks/index.ts index c35ba36c12..1169c8844f 100644 --- a/packages/shared/src/hooks/index.ts +++ b/packages/shared/src/hooks/index.ts @@ -28,3 +28,4 @@ export * from './useConditionalFeature'; export * from './useProgressAnimation'; export * from './feed'; export * from './useOnboardingChecklist'; +export * from './useBookmarkProvider'; diff --git a/packages/shared/src/hooks/useBookmarkProvider.ts b/packages/shared/src/hooks/useBookmarkProvider.ts index ef4129adce..e3c954e716 100644 --- a/packages/shared/src/hooks/useBookmarkProvider.ts +++ b/packages/shared/src/hooks/useBookmarkProvider.ts @@ -1,4 +1,4 @@ -import { useActiveFeedNameContext } from '../contexts'; +import { useActiveFeedNameContext } from '../contexts/ActiveFeedNameContext'; import { SharedFeedPage } from '../components/utilities'; import { UseBookmarkProviderProps, useJustBookmarked } from './bookmark'; @@ -6,7 +6,7 @@ interface UseBookmarkProviderReturn { highlightBookmarkedPost: boolean; } -const useBookmarkProvider = ({ +export const useBookmarkProvider = ({ bookmarked = false, }: UseBookmarkProviderProps): UseBookmarkProviderReturn => { const { feedName } = useActiveFeedNameContext(); @@ -20,5 +20,3 @@ const useBookmarkProvider = ({ highlightBookmarkedPost, }; }; - -export default useBookmarkProvider; diff --git a/packages/shared/src/hooks/useFeed.ts b/packages/shared/src/hooks/useFeed.ts index 2dfd9dae1e..92742e542b 100644 --- a/packages/shared/src/hooks/useFeed.ts +++ b/packages/shared/src/hooks/useFeed.ts @@ -22,7 +22,7 @@ import { updateCachedPagePost, } from '../lib/query'; import { MarketingCta } from '../components/marketingCta/common'; -import { FeedItemType } from '../components/cards/common'; +import { FeedItemType } from '../components/cards/common/common'; import { GARMR_ERROR, gqlClient } from '../graphql/common'; interface FeedItemBase { diff --git a/packages/storybook/stories/components/cards/ad/AdGrid.stories.tsx b/packages/storybook/stories/components/cards/ad/AdGrid.stories.tsx index 656453aedb..91cd1869fb 100644 --- a/packages/storybook/stories/components/cards/ad/AdGrid.stories.tsx +++ b/packages/storybook/stories/components/cards/ad/AdGrid.stories.tsx @@ -1,7 +1,5 @@ import type { Meta, StoryObj } from '@storybook/react'; import { AdGrid } from '@dailydotdev/shared/src/components/cards/ad/AdGrid'; -import YoutubeVideo - from '@dailydotdev/shared/src/components/video/YoutubeVideo'; const meta: Meta = { title: 'Components/Cards/Ads/AdGrid', diff --git a/packages/webapp/pages/account/invite.tsx b/packages/webapp/pages/account/invite.tsx index 336206bfb6..c69ef55f7f 100644 --- a/packages/webapp/pages/account/invite.tsx +++ b/packages/webapp/pages/account/invite.tsx @@ -18,7 +18,7 @@ import { gqlClient, } from '@dailydotdev/shared/src/graphql/common'; import { SocialShareList } from '@dailydotdev/shared/src/components/widgets/SocialShareList'; -import { Separator } from '@dailydotdev/shared/src/components/cards/common'; +import { Separator } from '@dailydotdev/shared/src/components/cards/common/common'; import { UserShortProfile } from '@dailydotdev/shared/src/lib/user'; import { format } from 'date-fns'; import { IconSize } from '@dailydotdev/shared/src/components/Icon'; diff --git a/packages/webapp/pages/squads/[handle]/[token].tsx b/packages/webapp/pages/squads/[handle]/[token].tsx index b130c889f8..817bde46c3 100644 --- a/packages/webapp/pages/squads/[handle]/[token].tsx +++ b/packages/webapp/pages/squads/[handle]/[token].tsx @@ -17,7 +17,7 @@ import { import { ProfileImageLink } from '@dailydotdev/shared/src/components/profile/ProfileImageLink'; import classed from '@dailydotdev/shared/src/lib/classed'; import { useAuthContext } from '@dailydotdev/shared/src/contexts/AuthContext'; -import SourceButton from '@dailydotdev/shared/src/components/cards/SourceButton'; +import SourceButton from '@dailydotdev/shared/src/components/cards/common/SourceButton'; import { ButtonSize, ButtonVariant,