-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Homepages: Use Community component in both DefaultHome and UserHome (#…
…6149) * import Community component into both DefaultHome and UserHome * remove prop-types warnings
- Loading branch information
1 parent
5bcd1c8
commit 968683c
Showing
7 changed files
with
107 additions
and
181 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
162 changes: 66 additions & 96 deletions
162
packages/lib-content/src/screens/Home/Community/Community.js
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 |
---|---|---|
@@ -1,117 +1,87 @@ | ||
import { Anchor, Box, Heading, ResponsiveContext } from 'grommet' | ||
import { useTranslation } from '../../../translations/i18n.js' | ||
import { SpacedHeading } from '@zooniverse/react-components' | ||
import styled from 'styled-components' | ||
import { useContext } from 'react' | ||
|
||
import Article from '../../../components/Article/Article.js' | ||
import SubHeading from '../../../components/HeadingForAboutNav/SubHeading.js' | ||
|
||
const ElevatedBox = styled(Box)` | ||
box-shadow: 0px 0px 8px rgba(0, 0, 0, 0.3); // Grommet elevation = 'medium' | ||
clip-path: inset(1px -30px 0px -30px); // don't put elevation top and bottom | ||
padding: 60px 0; | ||
// hides seam between DefaultHome or UserHome and this component | ||
position: relative; | ||
z-index: 99; | ||
margin-top: -3px; | ||
@media (width <= 90rem) { | ||
padding: 30px; | ||
} | ||
` | ||
|
||
export default function Community({ dailyZooPosts = [], zooBlogPosts = [] }) { | ||
const { t } = useTranslation() | ||
const size = useContext(ResponsiveContext) | ||
|
||
return ( | ||
<Box | ||
background={{ | ||
dark: 'dark-1', | ||
light: 'light-1' | ||
}} | ||
align='center' | ||
round='small' | ||
pad={size === 'small' ? '0' : 'large'} | ||
border={ | ||
size === 'small' | ||
? false | ||
: { | ||
color: { light: 'light-5', dark: 'black' }, | ||
size: 'xsmall' | ||
} | ||
} | ||
width='min(100%, calc(90rem - 160px))' // Like 80px horizontal padding, matches lib-user Layout | ||
> | ||
<ElevatedBox | ||
align='center' | ||
background={{ dark: 'dark-3', light: 'neutral-6' }} | ||
width='min(100%, 90rem)' | ||
<SpacedHeading | ||
color={{ light: 'neutral-1', dark: 'accent-1' }} | ||
level={2} | ||
size='1.5rem' | ||
alignSelf='center' | ||
textAlign='center' | ||
> | ||
<Box | ||
round='small' | ||
pad={size === 'small' ? '0' : 'large'} | ||
border={ | ||
size === 'small' | ||
? false | ||
: { | ||
color: { light: 'light-5', dark: 'black' }, | ||
size: 'xsmall' | ||
} | ||
} | ||
width='min(100%, calc(90rem - 160px))' // Like 80px horizontal padding, matches lib-user Layout | ||
> | ||
<SpacedHeading | ||
color={{ light: 'neutral-1', dark: 'accent-1' }} | ||
level={2} | ||
size='1.5rem' | ||
alignSelf='center' | ||
textAlign='center' | ||
> | ||
{t('Home.Community.heading')} | ||
</SpacedHeading> | ||
<SubHeading>{t('Home.Community.subheading')}</SubHeading> | ||
{t('Home.Community.heading')} | ||
</SpacedHeading> | ||
<SubHeading>{t('Home.Community.subheading')}</SubHeading> | ||
|
||
{/* The Daily Zooniverse */} | ||
<Box | ||
border={{ | ||
side: 'bottom', | ||
color: { light: 'light-4', dark: 'black' }, | ||
size: 'xsmall' | ||
}} | ||
direction='row' | ||
justify='between' | ||
align='center' | ||
margin={{ vertical: 'small' }} | ||
> | ||
<Heading level={3} size='1rem'> | ||
{t('Home.Community.feedOne')} | ||
</Heading> | ||
<Anchor href='https://daily.zooniverse.org' size='1rem'> | ||
{t('Home.Community.seeAll')} | ||
</Anchor> | ||
</Box> | ||
<Box gap='small' margin={{ bottom: 'medium' }}> | ||
{dailyZooPosts.length | ||
? dailyZooPosts.map(item => <Article key={item.id} {...item} />) | ||
: null} | ||
</Box> | ||
{/* The Daily Zooniverse */} | ||
<Box | ||
border={{ | ||
side: 'bottom', | ||
color: { light: 'light-4', dark: 'black' }, | ||
size: 'xsmall' | ||
}} | ||
direction='row' | ||
justify='between' | ||
align='center' | ||
margin={{ vertical: 'small' }} | ||
> | ||
<Heading level={3} size='1rem'> | ||
{t('Home.Community.feedOne')} | ||
</Heading> | ||
<Anchor href='https://daily.zooniverse.org' size='1rem'> | ||
{t('Home.Community.seeAll')} | ||
</Anchor> | ||
</Box> | ||
<Box gap='small' margin={{ bottom: 'medium' }}> | ||
{dailyZooPosts.length | ||
? dailyZooPosts.map(item => <Article key={item.id} {...item} />) | ||
: null} | ||
</Box> | ||
|
||
{/* The Zooniverse Blog */} | ||
<Box | ||
direction='row' | ||
justify='between' | ||
align='center' | ||
border={{ | ||
position: 'bottom', | ||
color: { light: 'light-1', dark: 'dark-1' } | ||
}} | ||
> | ||
<Heading level={3} size='1rem'> | ||
{t('Home.Community.feedTwo')} | ||
</Heading> | ||
<Anchor href='https://blog.zooniverse.org' size='1rem'> | ||
{t('Home.Community.seeAll')} | ||
</Anchor> | ||
</Box> | ||
<Box gap='small'> | ||
{zooBlogPosts.length | ||
? zooBlogPosts.map(item => <Article key={item.id} {...item} />) | ||
: null} | ||
</Box> | ||
</Box> | ||
</ElevatedBox> | ||
{/* The Zooniverse Blog */} | ||
<Box | ||
direction='row' | ||
justify='between' | ||
align='center' | ||
border={{ | ||
position: 'bottom', | ||
color: { light: 'light-1', dark: 'dark-1' } | ||
}} | ||
> | ||
<Heading level={3} size='1rem'> | ||
{t('Home.Community.feedTwo')} | ||
</Heading> | ||
<Anchor href='https://blog.zooniverse.org' size='1rem'> | ||
{t('Home.Community.seeAll')} | ||
</Anchor> | ||
</Box> | ||
<Box gap='small'> | ||
{zooBlogPosts.length | ||
? zooBlogPosts.map(item => <Article key={item.id} {...item} />) | ||
: null} | ||
</Box> | ||
</Box> | ||
) | ||
} |
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 |
---|---|---|
|
@@ -38,3 +38,4 @@ export default function CommunityContainer({ | |
/> | ||
) | ||
} | ||
|
66 changes: 0 additions & 66 deletions
66
packages/lib-content/src/screens/Home/Community/blogPosts.mock.json
This file was deleted.
Oops, something went wrong.
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
8 changes: 7 additions & 1 deletion
8
packages/lib-content/src/screens/Home/DefaultHome/DefaultHome.stories.js
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 |
---|---|---|
@@ -1,8 +1,14 @@ | ||
import dailyZooPosts from '../Community/dailyZooPosts.mock.json' | ||
import zooBlogPosts from '../Community/zooBlogPosts.mock.json' | ||
import DefaultHome from './DefaultHome.js' | ||
|
||
export default { | ||
title: 'Screens / Home / DefaultHome', | ||
component: DefaultHome | ||
component: DefaultHome, | ||
args: { | ||
dailyZooPosts, | ||
zooBlogPosts | ||
} | ||
} | ||
|
||
export const Default = {} |
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