-
-
Notifications
You must be signed in to change notification settings - Fork 389
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3095 from benfurber/component-user-engagement-wra…
…pper New component: Add user engagement wrapper
- Loading branch information
Showing
8 changed files
with
159 additions
and
85 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
packages/components/src/UserEngagementWrapper/UserEngagementWrapper.stories.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<typeof UserEngagementWrapper> | ||
|
||
export const Default: StoryFn<typeof UserEngagementWrapper> = () => ( | ||
<Box sx={{ maxWidth: '1000px', margin: '0 auto' }}> | ||
<UserEngagementWrapper> | ||
<Box sx={{ margin: 3 }}> | ||
<ArticleCallToAction | ||
author={{ | ||
userName: 'howto._createdBy', | ||
countryCode: 'howto.creatorCountry', | ||
isVerified: true, | ||
}} | ||
> | ||
<Button sx={{ fontSize: 2 }} onClick={() => null}> | ||
Leave a comment | ||
</Button> | ||
<UsefulStatsButton | ||
votedUsefulCount={28} | ||
hasUserVotedUseful={false} | ||
isLoggedIn={false} | ||
onUsefulClick={() => null} | ||
/> | ||
</ArticleCallToAction> | ||
</Box> | ||
</UserEngagementWrapper> | ||
</Box> | ||
) |
12 changes: 12 additions & 0 deletions
12
packages/components/src/UserEngagementWrapper/UserEngagementWrapper.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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(<Default {...(Default.args as Props)} />) | ||
|
||
expect(getByText('Mark as useful')).toBeInTheDocument() | ||
}) | ||
}) |
26 changes: 26 additions & 0 deletions
26
packages/components/src/UserEngagementWrapper/UserEngagementWrapper.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 ( | ||
<Flex | ||
sx={{ | ||
backgroundImage: `url("${whiteBubble}")`, | ||
backgroundPosition: 'top center', | ||
backgroundRepeat: 'no-repeat', | ||
backgroundSize: ['150% auto', '125% auto', '80% auto'], | ||
flexDirection: 'column', | ||
marginTop: [1, 2, 4], | ||
paddingBottom: [1, 1, 8], | ||
paddingTop: [4, 5, 6], | ||
}} | ||
> | ||
{children} | ||
</Flex> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters