diff --git a/packages/components/src/ArticleCallToAction/ArticleCallToAction.tsx b/packages/components/src/ArticleCallToAction/ArticleCallToAction.tsx index 8f3910a9b3..3f824d3e72 100644 --- a/packages/components/src/ArticleCallToAction/ArticleCallToAction.tsx +++ b/packages/components/src/ArticleCallToAction/ArticleCallToAction.tsx @@ -1,5 +1,5 @@ import { useTheme } from '@emotion/react' -import { Card, Flex, Heading, Text } from 'theme-ui' +import { Flex, Heading, Text } from 'theme-ui' import { Username } from '../' @@ -14,52 +14,50 @@ export interface Props { export const ArticleCallToAction = (props: Props) => { const theme = useTheme() as any return ( - + + + Made by + + + {props.contributors && props?.contributors.length ? ( + + With contributions from:{' '} + {props.contributors.map((contributor, key) => ( + + ))} + + ) : null} + Like what you see? 👇 - - Made by - - - {props.contributors && props?.contributors.length ? ( - - With contributions from:{' '} - {props.contributors.map((contributor, key) => ( - - ))} - - ) : null} - Like what you see? 👇 - - {props.children} - + {props.children} - + ) } diff --git a/packages/components/src/UserEngagementWrapper/UserEngagementWrapper.stories.tsx b/packages/components/src/UserEngagementWrapper/UserEngagementWrapper.stories.tsx new file mode 100644 index 0000000000..71d7bc8d5f --- /dev/null +++ b/packages/components/src/UserEngagementWrapper/UserEngagementWrapper.stories.tsx @@ -0,0 +1,37 @@ +import { Box, Button } from 'theme-ui' + +import { ArticleCallToAction, UsefulStatsButton } from '..' +import { UserEngagementWrapper } from './UserEngagementWrapper' + +import type { Meta, StoryFn } from '@storybook/react' + +export default { + title: 'Components/UserEngagementWrapper', + component: UserEngagementWrapper, +} as Meta + +export const Default: StoryFn = () => ( + + + + + + null} + /> + + + + +) diff --git a/packages/components/src/UserEngagementWrapper/UserEngagementWrapper.test.tsx b/packages/components/src/UserEngagementWrapper/UserEngagementWrapper.test.tsx new file mode 100644 index 0000000000..1316dfbe13 --- /dev/null +++ b/packages/components/src/UserEngagementWrapper/UserEngagementWrapper.test.tsx @@ -0,0 +1,12 @@ +import { render } from '../tests/utils' +import { Default } from './UserEngagementWrapper.stories' + +import type { Props } from './UserEngagementWrapper' + +describe('UserEngagementWrapper', () => { + it('renders the children', () => { + const { getByText } = render() + + expect(getByText('Mark as useful')).toBeInTheDocument() + }) +}) diff --git a/packages/components/src/UserEngagementWrapper/UserEngagementWrapper.tsx b/packages/components/src/UserEngagementWrapper/UserEngagementWrapper.tsx new file mode 100644 index 0000000000..967cddfa6c --- /dev/null +++ b/packages/components/src/UserEngagementWrapper/UserEngagementWrapper.tsx @@ -0,0 +1,26 @@ +import { Flex } from 'theme-ui' + +import whiteBubble from '../../assets/images/white-bubble_1.svg' + +export interface Props { + children: React.ReactNode +} + +export const UserEngagementWrapper = ({ children }: Props) => { + return ( + + {children} + + ) +} diff --git a/packages/components/src/index.ts b/packages/components/src/index.ts index 14b7534227..8df25427e3 100644 --- a/packages/components/src/index.ts +++ b/packages/components/src/index.ts @@ -51,3 +51,4 @@ export { ContentStatistics } from './ContentStatistics/ContentStatistics' export { Tab, TabsList, TabPanel, Tabs } from './TabbedContent/TabbedContent' export { DiscussionContainer } from './DiscussionContainer/DiscussionContainer' export { DiscussionTitle } from './DiscussionTitle/DiscussionTitle' +export { UserEngagementWrapper } from './UserEngagementWrapper/UserEngagementWrapper' diff --git a/src/pages/Howto/Content/Howto/HowToComments/HowToComments.tsx b/src/pages/Howto/Content/Howto/HowToComments/HowToComments.tsx index 33a43f3777..d770aaa3f3 100644 --- a/src/pages/Howto/Content/Howto/HowToComments/HowToComments.tsx +++ b/src/pages/Howto/Content/Howto/HowToComments/HowToComments.tsx @@ -77,11 +77,11 @@ export const HowToComments = ({ comments }: IProps) => { data-cy="howto-comments" > diff --git a/src/pages/Howto/Content/Howto/Howto.tsx b/src/pages/Howto/Content/Howto/Howto.tsx index 4dee74b888..af39594d7d 100644 --- a/src/pages/Howto/Content/Howto/Howto.tsx +++ b/src/pages/Howto/Content/Howto/Howto.tsx @@ -6,6 +6,7 @@ import { Button, Loader, UsefulStatsButton, + UserEngagementWrapper, } from 'oa-components' import { trackEvent } from 'src/common/Analytics' import { isUserVerifiedWithStore } from 'src/common/isUserVerified' @@ -128,14 +129,7 @@ export const Howto = observer(() => { ))} - + { /> )} - - + + ) }) diff --git a/src/pages/Research/Content/ResearchArticle.tsx b/src/pages/Research/Content/ResearchArticle.tsx index 0221e9b1cb..c8c26fd2cc 100644 --- a/src/pages/Research/Content/ResearchArticle.tsx +++ b/src/pages/Research/Content/ResearchArticle.tsx @@ -7,6 +7,7 @@ import { FollowButton, Loader, UsefulStatsButton, + UserEngagementWrapper, } from 'oa-components' import { trackEvent } from 'src/common/Analytics' import { useContributorsData } from 'src/common/hooks/contributorsData' @@ -229,7 +230,7 @@ const ResearchArticle = observer(() => { .length || 0 } /> - + {item && getPublicUpdates(item).map((update, index) => ( { /> ))} - - {researchAuthor && ( - - {item.moderation === 'accepted' && ( - + + {researchAuthor && ( + + {item.moderation === 'accepted' && ( + + onUsefulClick(item._id, item.slug, 'ArticleCallToAction') + } + /> + )} + - onUsefulClick(item._id, item.slug, 'ArticleCallToAction') - } - /> - )} - onFollowClick(item.slug)} - > - - )} - + hasUserSubscribed={researchStore.userHasSubscribed} + onFollowClick={() => onFollowClick(item.slug)} + > + + )} + + + {isEditable && (