-
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.
[B2BP-1059] [B2BP-1060] Add Press Releases (#509)
* Add Press Releases * Make PressRelease body required * Update obsolete comments --------- Co-authored-by: Simone Salsi <[email protected]>
- Loading branch information
Showing
27 changed files
with
806 additions
and
37 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"strapi-cms": minor | ||
--- | ||
|
||
Add PressRelease CollectionType and Section |
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,5 @@ | ||
--- | ||
"nextjs-website": minor | ||
--- | ||
|
||
Add PressRelease component and fetch related Strapi CollectionType as pages |
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
92 changes: 92 additions & 0 deletions
92
apps/nextjs-website/react-components/components/PressRelease/PressRelease.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,92 @@ | ||
import React from 'react'; | ||
import { Box, Typography, Container, useTheme } from '@mui/material'; | ||
import { | ||
TextColor, | ||
BackgroundColor, | ||
ExtraTextColor, | ||
} from '../common/Common.helpers'; | ||
import { PressReleaseProps } from '@react-components/types'; | ||
|
||
const PressRelease = (props: PressReleaseProps) => { | ||
const { date, title, subtitle, body, sectionID } = props; | ||
const textColor = TextColor('light'); | ||
const eyeletColor = ExtraTextColor('light'); | ||
const backgroundColor = BackgroundColor('light'); | ||
const { palette } = useTheme(); | ||
|
||
return ( | ||
<Box | ||
component="section" | ||
{...(sectionID && { id: sectionID })} | ||
sx={{ | ||
width: '100%', | ||
bgcolor: backgroundColor, | ||
color: textColor, | ||
py: 10, | ||
px: 2, | ||
}} | ||
> | ||
<Container | ||
sx={{ | ||
width: { xs: '100%', md: '60%' }, | ||
mx: 'auto', | ||
ml: { xs: 'auto', md: 16 }, | ||
mr: { xs: 'auto' }, | ||
}} | ||
> | ||
<Typography | ||
variant="overline" | ||
component="div" | ||
sx={{ | ||
color: eyeletColor, | ||
fontSize: { xs: '16px', md: '16px' }, | ||
fontWeight: 400, | ||
}} | ||
> | ||
{date} | ||
</Typography> | ||
<Typography | ||
variant="h4" | ||
component="h2" | ||
sx={{ fontSize: { xs: '32px', md: '38px' }, color: textColor }} | ||
> | ||
{title} | ||
</Typography> | ||
{subtitle && ( | ||
<Typography | ||
variant="h6" | ||
component="h3" | ||
sx={{ | ||
fontSize: { xs: '22px', md: '24px' }, | ||
mt: 2, | ||
color: textColor, | ||
}} | ||
> | ||
{subtitle} | ||
</Typography> | ||
)} | ||
<Typography | ||
component="div" | ||
variant="body1" | ||
sx={{ | ||
fontSize: { xs: '14px', md: '16px' }, | ||
mt: 1, | ||
color: textColor, | ||
'& a': { | ||
color: palette.primary.main, | ||
textDecoration: 'underline', | ||
'&:hover': { | ||
color: palette.primary.main, | ||
textDecoration: 'underline', | ||
}, | ||
}, | ||
}} | ||
> | ||
{body} | ||
</Typography> | ||
</Container> | ||
</Box> | ||
); | ||
}; | ||
|
||
export default PressRelease; |
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
7 changes: 7 additions & 0 deletions
7
apps/nextjs-website/react-components/types/PressRelease/PressRelease.types.ts
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,7 @@ | ||
export interface PressReleaseProps { | ||
title: string; | ||
subtitle?: string; | ||
body: JSX.Element; | ||
sectionID: string | null; | ||
date: string; | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
'use client'; | ||
import MarkdownRenderer from './MarkdownRenderer'; | ||
import { SiteWidePageData } from '@/lib/fetch/siteWideSEO'; | ||
import { PressReleaseSection } from '@/lib/fetch/types/PageSection'; | ||
import { PressRelease as PressReleaseRC } from '@react-components/components'; | ||
import { PressReleaseProps } from '@react-components/types'; | ||
|
||
const makeTextSectionProps = ({ | ||
locale, | ||
defaultLocale, | ||
subtitle, | ||
body, | ||
...rest | ||
}: PressReleaseSection & | ||
Omit<SiteWidePageData, 'themeVariant'>): PressReleaseProps => ({ | ||
...(subtitle && { subtitle }), | ||
body: MarkdownRenderer({ markdown: body, locale, defaultLocale }), | ||
...rest, | ||
}); | ||
|
||
const PressRelease = ( | ||
props: PressReleaseSection & Omit<SiteWidePageData, 'themeVariant'> | ||
) => <PressReleaseRC {...makeTextSectionProps(props)} />; | ||
|
||
export default PressRelease; |
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,89 @@ | ||
/* eslint-disable @typescript-eslint/no-non-null-assertion */ | ||
import { describe, it, expect } from 'vitest'; | ||
import { navigationToPageDataArray, PageData } from '../navigation'; | ||
import { Navigation } from '../fetch/navigation'; | ||
|
||
const navigation: Navigation = { | ||
data: [ | ||
{ | ||
id: 1, | ||
attributes: { | ||
slug: 'homepage', | ||
seo: { | ||
metaTitle: 'title', | ||
metaDescription: 'description', | ||
keywords: null, | ||
canonicalURL: null, | ||
ogTitle: null, | ||
ogDescription: null, | ||
structuredData: null, | ||
}, | ||
sections: [ | ||
{ | ||
__component: 'sections.stripe-link', | ||
theme: 'dark', | ||
subtitle: 'subtitle', | ||
icon: { | ||
data: null, | ||
}, | ||
link: { | ||
label: 'link', | ||
href: '/', | ||
}, | ||
sectionID: null, | ||
}, | ||
], | ||
}, | ||
}, | ||
{ | ||
id: 2, | ||
attributes: { | ||
slug: 'other-page', | ||
seo: { | ||
metaTitle: 'title', | ||
metaDescription: 'description', | ||
keywords: null, | ||
canonicalURL: null, | ||
ogTitle: null, | ||
ogDescription: null, | ||
structuredData: null, | ||
}, | ||
sections: [ | ||
{ | ||
__component: 'sections.stripe-link', | ||
theme: 'dark', | ||
subtitle: 'subtitle', | ||
icon: { | ||
data: null, | ||
}, | ||
link: { | ||
label: 'link', | ||
href: '/', | ||
}, | ||
sectionID: null, | ||
}, | ||
], | ||
}, | ||
}, | ||
], | ||
}; | ||
|
||
describe('navigationToPageDataArray', () => { | ||
it('should replace homepage slug with an empty string', () => { | ||
const actual = navigationToPageDataArray(navigation); | ||
const expected: ReadonlyArray<PageData> = [ | ||
{ | ||
seo: navigation.data[0]!.attributes.seo, | ||
sections: navigation.data[0]!.attributes.sections, | ||
slug: [''], | ||
}, | ||
{ | ||
seo: navigation.data[1]!.attributes.seo, | ||
sections: navigation.data[1]!.attributes.sections, | ||
slug: ['other-page'], | ||
}, | ||
]; | ||
|
||
expect(actual).toStrictEqual(expected); | ||
}); | ||
}); |
Oops, something went wrong.