Skip to content

Commit

Permalink
Merge branch 'padms/2280'
Browse files Browse the repository at this point in the history
  • Loading branch information
padms committed May 28, 2024
2 parents 307955a + 5ee4cc4 commit 5f5affa
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 15 deletions.
10 changes: 4 additions & 6 deletions web/pageComponents/pageTemplates/Event.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import type { EventSchema } from '../../types/types'
import { EventJsonLd } from 'next-seo'
import Blocks from '../../pageComponents/shared/portableText/Blocks'
import { twMerge } from 'tailwind-merge'
import CallToActions from '@sections/CallToActions'
import RelatedContent from 'pageComponents/shared/RelatedContent'

Check failure on line 16 in web/pageComponents/pageTemplates/Event.tsx

View workflow job for this annotation

GitHub Actions / check-code

Unable to resolve path to module 'pageComponents/shared/RelatedContent'

export default function Event({ data }: { data: EventSchema }): JSX.Element {
const { title } = data
Expand Down Expand Up @@ -84,17 +84,15 @@ export default function Event({ data }: { data: EventSchema }): JSX.Element {
{contactList && <ContactList data={contactList} className="my-12" />}

{relatedLinks?.links && relatedLinks.links.length > 0 && (
<CallToActions
<RelatedContent
data={relatedLinks}
className={twMerge(`
px-layout-lg
max-w-viewport
my-3xl
mx-auto
pb-page-content
`)}
callToActions={relatedLinks.links}
overrideButtonStyle={true}
splitList={false}
/>
)}
</article>
Expand Down
17 changes: 8 additions & 9 deletions web/pageComponents/pageTemplates/News.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ import { metaTitleSuffix } from '../../languages'
import type { NewsSchema } from '../../types/types'
import { toPlainText } from '@portabletext/react'
import Blocks from '../shared/portableText/Blocks'
import CallToActions from '@sections/CallToActions'
import { twMerge } from 'tailwind-merge'
import RelatedContent from 'pageComponents/shared/RelatedContent'

Check failure on line 18 in web/pageComponents/pageTemplates/News.tsx

View workflow job for this annotation

GitHub Actions / check-code

Unable to resolve path to module 'pageComponents/shared/RelatedContent'

const NewsLayout = styled.div`
--banner-paddingHorizontal: clamp(16px, calc(-69.1942px + 22.7184vw), 367px);
Expand Down Expand Up @@ -222,15 +222,14 @@ const NewsPage = ({ data: news }: ArticleProps) => {
{iframe && <BasicIFrame data={iframe} />}

{relatedLinks?.links && relatedLinks.links.length > 0 && (
<CallToActions
<RelatedContent
data={relatedLinks}
className={twMerge(`
px-layout-lg
max-w-viewport
my-3xl
`)}
callToActions={relatedLinks.links}
overrideButtonStyle={true}
splitList={false}
px-layout-lg
max-w-viewport
my-3xl
mx-auto
`)}
/>
)}

Expand Down
43 changes: 43 additions & 0 deletions web/pageComponents/shared/RelatedContent.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import { Fragment, HTMLAttributes } from 'react'
import { Heading, List } from '@components'
import type { RelatedLinksData, LinkData } from '../../types/types'
import { ResourceLink } from '@core/Link'
import { getUrlFromAction } from '../../common/helpers'
import { getLocaleFromName } from '../../lib/localization'

const { Item } = List

type RelatedContentProps = {
data: RelatedLinksData
} & HTMLAttributes<HTMLDivElement>

const RelatedContent = ({ data, ...rest }: RelatedContentProps) => {
return (
<aside {...rest}>
<Heading className="pb-4 text-left" size="xl" level="h2">
{data.title}
</Heading>
<List unstyled>
{data.links.length > 0 &&
data.links.map((item: LinkData) => {
const url = getUrlFromAction(item)
return (
<Fragment key={item.id}>
<Item>
<ResourceLink
href={url as string}
{...(item.link?.lang && { locale: getLocaleFromName(item.link?.lang) })}
type={item.type}
>
{`${item.label} ${item.extension ? `(${item.extension.toUpperCase()})` : ''}`}
</ResourceLink>
</Item>
</Fragment>
)
})}
</List>
</aside>
)
}

export default RelatedContent

0 comments on commit 5f5affa

Please sign in to comment.