forked from dis-moi/extension
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(profile): Show one, all, or none featured notices on contributor…
… profile
- Loading branch information
Showing
9 changed files
with
188 additions
and
45 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
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
53 changes: 53 additions & 0 deletions
53
src/app/profiles/App/Pages/Profiles/Profile/FeaturedNotices.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,53 @@ | ||
import React from 'react'; | ||
import styled from 'styled-components'; | ||
import FeaturedNotice from './FeaturedNotice'; | ||
import { LoadingRotator } from 'components/atoms'; | ||
import { LoadingBig } from 'components/atoms/icons'; | ||
import { NoticeWithContributor } from 'app/lmem/notice'; | ||
import { StatefulContributor } from 'app/lmem/contributor'; | ||
|
||
export interface FeaturedNoticesProps { | ||
loading?: boolean; | ||
notices: NoticeWithContributor[]; | ||
seeNoticeInContext: (notice: NoticeWithContributor) => () => void; | ||
contributor?: StatefulContributor; | ||
className?: string; | ||
} | ||
|
||
const FeatureNoticesContainer = styled.section` | ||
margin-bottom: 40px; | ||
`; | ||
|
||
const FeaturedNotices = ({ | ||
loading, | ||
notices, | ||
seeNoticeInContext, | ||
className | ||
}: FeaturedNoticesProps) => { | ||
if (typeof loading === 'undefined') { | ||
return null; | ||
} | ||
|
||
return ( | ||
<FeatureNoticesContainer className={className}> | ||
{loading ? ( | ||
<LoadingRotator> | ||
<LoadingBig /> | ||
</LoadingRotator> | ||
) : ( | ||
<> | ||
{notices.map(notice => ( | ||
<FeaturedNotice | ||
key={notice.id} | ||
loading={false} | ||
notice={notice} | ||
seeInContext={seeNoticeInContext(notice)} | ||
/> | ||
))} | ||
</> | ||
)} | ||
</FeatureNoticesContainer> | ||
); | ||
}; | ||
|
||
export default FeaturedNotices; |
23 changes: 23 additions & 0 deletions
23
src/app/profiles/App/Pages/Profiles/Profile/FeaturedNoticesTitle.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,23 @@ | ||
import React from 'react'; | ||
import { Title2 } from 'components/atoms'; | ||
import { StatefulContributor } from 'app/lmem/contributor'; | ||
|
||
export interface FeaturedNoticesTitleProps { | ||
plural: boolean; | ||
contributor?: StatefulContributor; | ||
className?: string; | ||
} | ||
|
||
const FeaturedNoticesTitle = ({ | ||
plural, | ||
contributor, | ||
className | ||
}: FeaturedNoticesTitleProps) => ( | ||
<Title2 className={className}> | ||
{`L${plural ? 'es' : 'a'} contribution${plural ? 's' : ''} phare${ | ||
plural ? 's' : '' | ||
} ${contributor && `de ${contributor.name}`}`} | ||
</Title2> | ||
); | ||
|
||
export default FeaturedNoticesTitle; |
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
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