Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import { isUndefined } from '@guardian/libs';
import type { ReporterCalloutBlockElement } from '../types/content';
import { Body } from './ExpandableAtom/Body';
import { Container } from './ExpandableAtom/Container';

/**
* A callout to readers to share tips with reporters
*
* ## TODO: check if this needs to be an island - possibly not as there's no user interaction beyond expanding the box
*
*/

export const ReporterCalloutBlockComponent = ({
callout,
}: {
callout: ReporterCalloutBlockElement;
}) => {
const {
id,
title,
description,
activeUntil,
// contacts, TODO: Render contacts
} = callout;
const isExpired = isUndefined(activeUntil)
? false
: Math.floor(new Date().getTime() / 1000) > activeUntil;

return isExpired ? (
<></>
) : (
<div data-gu-name="callout">
<Container
id={id}
title={title}
atomType="guide"
atomTypeTitle="Get in touch"
expandCallback={() => {
// do nothing - I don't think we want to track interactions with this component in ophan
}}
>
<Body
html={description}
image={
'https://i.guim.co.uk/img/media/ae475ccca7c94a4565f6b500a485479f08098383/788_0_4000_4000/4000.jpg?width=620&quality=85&auto=format&fit=max&s=45fd162100b331bf1618e364c5c69452'
}
credit={'Illustration: Guardian Design / Rich Cousins'}
/>
</Container>
</div>
);
};
50 changes: 50 additions & 0 deletions dotcom-rendering/src/frontend/schemas/feArticle.json
Original file line number Diff line number Diff line change
Expand Up @@ -611,6 +611,9 @@
{
"$ref": "#/definitions/CalloutBlockElementV2"
},
{
"$ref": "#/definitions/ReporterCalloutBlockElement"
},
{
"$ref": "#/definitions/CartoonBlockElement"
},
Expand Down Expand Up @@ -1547,6 +1550,53 @@
"value"
]
},
"ReporterCalloutBlockElement": {
"type": "object",
"properties": {
"_type": {
"type": "string",
"const": "model.dotcomrendering.pageElements.ReporterCalloutBlockElement"
},
"elementId": {
"type": "string"
},
"id": {
"type": "string"
},
"activeFrom": {
"type": "number"
},
"activeUntil": {
"type": "number"
},
"displayOnSensitive": {
"type": "boolean"
},
"title": {
"type": "string"
},
"description": {
"type": "string"
},
"role": {
"$ref": "#/definitions/RoleType"
},
"contacts": {
"type": "array",
"items": {
"$ref": "#/definitions/CalloutContactType"
}
}
},
"required": [
"_type",
"description",
"displayOnSensitive",
"elementId",
"id",
"title"
]
},
"CartoonBlockElement": {
"type": "object",
"properties": {
Expand Down
10 changes: 10 additions & 0 deletions dotcom-rendering/src/lib/renderElement.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ import { ProfileAtomWrapper } from '../components/ProfileAtomWrapper.importable'
import { PullQuoteBlockComponent } from '../components/PullQuoteBlockComponent';
import { QandaAtom } from '../components/QandaAtom.importable';
import { QAndAExplainers } from '../components/QAndAExplainers';
import { ReporterCalloutBlockComponent } from '../components/ReporterCalloutBlockComponent.importable';
import { RichLinkComponent } from '../components/RichLinkComponent.importable';
import { SoundcloudBlockComponent } from '../components/SoundcloudBlockComponent';
import { SpotifyBlockComponent } from '../components/SpotifyBlockComponent.importable';
Expand Down Expand Up @@ -220,6 +221,15 @@ export const renderElement = ({
);
}
return null;
case 'model.dotcomrendering.pageElements.ReporterCalloutBlockElement':
if (switches.callouts) {
return (
<Island priority="feature" defer={{ until: 'visible' }}>
<ReporterCalloutBlockComponent callout={element} />
</Island>
);
}
return null;

case 'model.dotcomrendering.pageElements.CaptionBlockElement':
return (
Expand Down
50 changes: 50 additions & 0 deletions dotcom-rendering/src/model/block-schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,9 @@
{
"$ref": "#/definitions/CalloutBlockElementV2"
},
{
"$ref": "#/definitions/ReporterCalloutBlockElement"
},
{
"$ref": "#/definitions/CartoonBlockElement"
},
Expand Down Expand Up @@ -1035,6 +1038,53 @@
"value"
]
},
"ReporterCalloutBlockElement": {
"type": "object",
"properties": {
"_type": {
"type": "string",
"const": "model.dotcomrendering.pageElements.ReporterCalloutBlockElement"
},
"elementId": {
"type": "string"
},
"id": {
"type": "string"
},
"activeFrom": {
"type": "number"
},
"activeUntil": {
"type": "number"
},
"displayOnSensitive": {
"type": "boolean"
},
"title": {
"type": "string"
},
"description": {
"type": "string"
},
"role": {
"$ref": "#/definitions/RoleType"
},
"contacts": {
"type": "array",
"items": {
"$ref": "#/definitions/CalloutContactType"
}
}
},
"required": [
"_type",
"description",
"displayOnSensitive",
"elementId",
"id",
"title"
]
},
"CartoonBlockElement": {
"type": "object",
"properties": {
Expand Down
14 changes: 14 additions & 0 deletions dotcom-rendering/src/types/content.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,19 @@ export interface CalloutBlockElementV2 {
contacts?: CalloutContactType[];
}

export interface ReporterCalloutBlockElement {
_type: 'model.dotcomrendering.pageElements.ReporterCalloutBlockElement';
elementId: string;
id: string;
activeFrom?: number;
activeUntil?: number;
displayOnSensitive: boolean;
title: string;
description: string;
role?: RoleType;
contacts?: CalloutContactType[];
}

export interface CartoonBlockElement {
_type: 'model.dotcomrendering.pageElements.CartoonBlockElement';
elementId: string;
Expand Down Expand Up @@ -796,6 +809,7 @@ export type FEElement =
| CaptionBlockElement
| CalloutBlockElement
| CalloutBlockElementV2
| ReporterCalloutBlockElement
| CartoonBlockElement
| ChartAtomBlockElement
| CodeBlockElement
Expand Down
Loading