-
Notifications
You must be signed in to change notification settings - Fork 1
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 #620 from CodeForAfrica/ft/posts-overview
Ft/Featured stories
- Loading branch information
Showing
9 changed files
with
260 additions
and
10 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
105 changes: 104 additions & 1 deletion
105
apps/codeforafrica/src/components/NewsAndStories/NewsAndStories.snap.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,3 +1,106 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`<NewsAndStories /> renders unchanged 1`] = `<div />`; | ||
exports[`<NewsAndStories /> renders unchanged 1`] = ` | ||
<div> | ||
<div | ||
class="MuiContainer-root MuiContainer-maxWidthLg MuiContainer-fixed MuiContainer-disableGutters css-1wsvydc-MuiContainer-root" | ||
> | ||
<div | ||
class="MuiBox-root css-dvxtzn" | ||
> | ||
<div | ||
class="MuiTypography-root MuiTypography-h4 css-1q524zl-MuiTypography-root" | ||
> | ||
News and Stories | ||
</div> | ||
<div | ||
class="MuiPaper-root MuiPaper-outlined MuiCard-root css-1486ctq-MuiPaper-root-MuiCard-root" | ||
> | ||
<a | ||
class="MuiTypography-root MuiTypography-inherit MuiLink-root MuiLink-underlineAlways MuiButtonBase-root MuiCardActionArea-root css-275i79-MuiTypography-root-MuiLink-root-MuiButtonBase-root-MuiCardActionArea-root" | ||
href="/stories/article-1" | ||
tabindex="0" | ||
> | ||
<div | ||
class="MuiGrid-root MuiGrid-container css-1xzqqmo-MuiGrid-root" | ||
> | ||
<div | ||
class="MuiGrid-root MuiGrid-item MuiGrid-grid-xs-12 MuiGrid-grid-md-12 css-18qart5-MuiGrid-root" | ||
> | ||
<img | ||
alt="Featured Article Image" | ||
class="MuiCardMedia-root MuiCardMedia-media MuiCardMedia-img css-1hjwis2-MuiCardMedia-root" | ||
src="https://res.cloudinary.com/code-for-africa/image/upload/v1650885664/codeforafrica/unsplash_L6hr1BptcNc_of23p3.png" | ||
/> | ||
</div> | ||
<div | ||
class="MuiGrid-root MuiGrid-item MuiGrid-grid-xs-12 MuiGrid-grid-md-true css-p8r8tv-MuiGrid-root" | ||
> | ||
<div | ||
class="MuiCardContent-root css-jq2jyh-MuiCardContent-root" | ||
> | ||
<p | ||
class="MuiTypography-root MuiTypography-body1 css-pdkb43-MuiTypography-root" | ||
> | ||
Battle for gender equality in African media continues | ||
</p> | ||
<p | ||
class="MuiTypography-root MuiTypography-body1 css-ajju11-MuiTypography-root" | ||
> | ||
Lorem ipsum dolor sit amet consectetur adipiscing elit mattis, vestibulum potenti rhoncus eget lacus fermentum taciti quam, quis curae accumsan viverra semper dapibus sed. | ||
</p> | ||
<button | ||
class="MuiButtonBase-root MuiButton-root MuiButton-contained MuiButton-containedPrimary MuiButton-sizeMedium MuiButton-containedSizeMedium MuiButton-root MuiButton-contained MuiButton-containedPrimary MuiButton-sizeMedium MuiButton-containedSizeMedium css-1it8s17-MuiButtonBase-root-MuiButton-root" | ||
tabindex="0" | ||
type="button" | ||
> | ||
Read Story | ||
</button> | ||
<span | ||
class="MuiTypography-root MuiTypography-caption css-13ob0ik-MuiTypography-root" | ||
> | ||
Jan 6, 2022 | ||
</span> | ||
</div> | ||
</div> | ||
<div | ||
class="MuiGrid-root MuiGrid-container MuiGrid-item MuiGrid-grid-xs-12 css-1uhca85-MuiGrid-root" | ||
> | ||
<div | ||
class="MuiGrid-root MuiGrid-item css-13i4rnv-MuiGrid-root" | ||
> | ||
<div | ||
class="MuiCardContent-root css-148nlxb-MuiCardContent-root" | ||
> | ||
<h1 | ||
class="MuiTypography-root MuiTypography-h1 css-gklt6i-MuiTypography-root" | ||
> | ||
Battle for gender equality in African media continues | ||
</h1> | ||
<button | ||
class="MuiButtonBase-root MuiButton-root MuiButton-contained-reverse MuiButton-contained-reversePrimary MuiButton-sizeLarge MuiButton-contained-reverseSizeLarge MuiButton-root MuiButton-contained-reverse MuiButton-contained-reversePrimary MuiButton-sizeLarge MuiButton-contained-reverseSizeLarge css-18nvokw-MuiButtonBase-root-MuiButton-root" | ||
tabindex="0" | ||
type="button" | ||
> | ||
READ STORY | ||
</button> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
<span | ||
class="MuiCardActionArea-focusHighlight css-1v2exvi-MuiCardActionArea-focusHighlight" | ||
/> | ||
</a> | ||
</div> | ||
<a | ||
class="MuiTypography-root MuiTypography-inherit MuiLink-root MuiLink-underlineAlways MuiButtonBase-root MuiButton-root MuiButton-contained MuiButton-containedPrimary MuiButton-sizeMedium MuiButton-containedSizeMedium MuiButton-root MuiButton-contained MuiButton-containedPrimary MuiButton-sizeMedium MuiButton-containedSizeMedium css-xtiyn3-MuiTypography-root-MuiLink-root-MuiButtonBase-root-MuiButton-root" | ||
href="/stories" | ||
tabindex="0" | ||
> | ||
Read Stories | ||
</a> | ||
</div> | ||
</div> | ||
</div> | ||
`; |
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
20 changes: 20 additions & 0 deletions
20
apps/codeforafrica/src/lib/data/blockify/featuredStories.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 |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { formatPost } from "@/codeforafrica/lib/data/utils/posts"; | ||
|
||
async function featuredStories(block) { | ||
const { | ||
primaryTag, | ||
featured: { story: featuredStory, action: featuredStoryActionLabel }, | ||
stories: { items, action }, | ||
...other | ||
} = block; | ||
return { | ||
...other, | ||
action, | ||
featured: formatPost(featuredStory, primaryTag), | ||
featuredStoryActionLabel, | ||
stories: items.map((item) => formatPost(item, primaryTag)), | ||
slug: "featured-stories", | ||
}; | ||
} | ||
|
||
export default featuredStories; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
import linkGroup from "../fields/links/linkGroup"; | ||
|
||
const FeaturedStories = { | ||
slug: "featured-stories", | ||
imageURL: "/images/cms/blocks/featured_stories.jpg", | ||
imageAltText: "Featured Stories", | ||
labels: { | ||
singular: { | ||
en: "Featured Stories", | ||
}, | ||
plural: { | ||
en: "Featured Stories", | ||
}, | ||
}, | ||
fields: [ | ||
{ | ||
name: "title", | ||
type: "text", | ||
required: true, | ||
}, | ||
{ | ||
name: "primaryTag", | ||
label: "Post Type", | ||
type: "text", | ||
defaultValue: "stories", | ||
admin: { | ||
hidden: true, | ||
}, | ||
}, | ||
{ | ||
name: "featured", | ||
label: "Featured Story", | ||
type: "group", | ||
fields: [ | ||
{ | ||
name: "story", | ||
type: "relationship", | ||
relationTo: "posts", | ||
hasMany: false, | ||
required: true, | ||
}, | ||
{ | ||
name: "action", | ||
label: "Action Label", | ||
type: "text", | ||
defaultValue: "Read Story", | ||
}, | ||
], | ||
}, | ||
{ | ||
name: "stories", | ||
label: "Stories", | ||
type: "group", | ||
fields: [ | ||
{ | ||
name: "items", | ||
label: "Stories", | ||
type: "relationship", | ||
relationTo: "posts", | ||
hasMany: true, | ||
minRows: 1, | ||
maxRows: 3, | ||
required: true, | ||
}, | ||
linkGroup({ | ||
overrides: { | ||
name: "action", | ||
label: "Browse More Action", | ||
}, | ||
}), | ||
], | ||
}, | ||
], | ||
}; | ||
|
||
export default FeaturedStories; |
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