Skip to content

Commit

Permalink
Merge pull request #929 from prezly/feature/dev-13192-add-support-for…
Browse files Browse the repository at this point in the history
…-rendering-coverage-cards-in-sites

[DEV-13192] Add support for coverage cards
  • Loading branch information
kudlajz authored Aug 2, 2024
2 parents 60600c8 + 0ba1817 commit 0c35b1c
Show file tree
Hide file tree
Showing 6 changed files with 98 additions and 43 deletions.
1 change: 1 addition & 0 deletions components/ContactCard/ContactCard.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@
@include border-radius-lg;

padding: $spacing-4;
background: $color-base-white;
border: 1px solid $color-borders;
}
}
Expand Down
6 changes: 6 additions & 0 deletions components/ContentRenderer/ContentRenderer.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,12 @@
}
}
}

.prezly-slate-coverage,
.prezly-slate-bookmark,
.prezly-slate-story-bookmark {
background-color: $color-base-white;
}
/* stylelint-enable selector-class-pattern, max-nesting-depth, selector-max-compound-selectors */
}
}
Expand Down
16 changes: 14 additions & 2 deletions components/ContentRenderer/ContentRenderer.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Component, Elements, Renderer } from '@prezly/content-renderer-react-js';
import type { ExtendedStory } from '@prezly/sdk';
import type { Node } from '@prezly/story-content-format';
import {
AttachmentNode,
Expand All @@ -20,6 +21,7 @@ import {
VideoNode,
} from '@prezly/story-content-format';
import { useEffect } from 'react';
import { FormattedDate } from 'react-intl';

import {
Heading,
Expand Down Expand Up @@ -47,9 +49,14 @@ import styles from './ContentRenderer.module.scss';

interface Props {
nodes: Node | Node[];
story?: ExtendedStory;
}

function ContentRenderer({ nodes }: Props) {
function ContentRenderer({ nodes, story }: Props) {
function renderDate(date: string) {
return <FormattedDate value={date} year="numeric" month="long" day="numeric" />;
}

useEffect(() => {
document.body.classList.add(styles.body);

Expand All @@ -60,7 +67,12 @@ function ContentRenderer({ nodes }: Props) {

return (
<div className={styles.renderer}>
<Renderer nodes={nodes} defaultComponents>
<Renderer
nodes={nodes}
defaultComponents
coverageEntries={story?.referenced_entities.coverages}
renderDate={renderDate}
>
<Component match={AttachmentNode.isAttachmentNode} component={Attachment} />
<Component
match={ButtonBlockNode.isButtonBlockNode}
Expand Down
2 changes: 1 addition & 1 deletion modules/Story/Story.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ function Story({ story }: Props) {
</p>
)}
{isTablet && url && visibility === 'public' && <StoryLinks url={url} />}
<ContentRenderer nodes={nodes} />
<ContentRenderer nodes={nodes} story={story} />
</div>
</article>
{!isTablet && url && visibility === 'public' && <StoryLinks url={url} />}
Expand Down
108 changes: 72 additions & 36 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@
"@headlessui/react": "1.7.18",
"@playwright/test": "^1.33.0",
"@prezly/analytics-nextjs": "3.0.0",
"@prezly/content-renderer-react-js": "0.38.4",
"@prezly/sdk": "21.6.0",
"@prezly/content-renderer-react-js": "0.39.0",
"@prezly/sdk": "21.12.0",
"@prezly/story-content-format": "0.65.1",
"@prezly/theme-kit-core": "7.6.0",
"@prezly/theme-kit-core": "7.7.0",
"@prezly/theme-kit-intl": "7.5.1",
"@prezly/theme-kit-nextjs": "7.6.0",
"@prezly/theme-kit-nextjs": "7.7.0",
"@prezly/uploadcare": "2.4.4",
"@prezly/uploadcare-image": "0.3.2",
"@react-hookz/web": "14.7.1",
Expand Down

0 comments on commit 0c35b1c

Please sign in to comment.