Skip to content
Open
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
1 change: 1 addition & 0 deletions dotcom-rendering/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ declare namespace JSX {
'data-spacefinder-role'?:
| 'nested'
| 'immersive'
| 'fullWidth'
| 'inline'
| 'richLink'
| 'thumbnail';
Expand Down
59 changes: 57 additions & 2 deletions dotcom-rendering/src/components/Figure.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ type Props = {
children: React.ReactNode;
format: ArticleFormat;
isMainMedia: boolean;
role?: RoleType | 'richLink';
role?: RoleType | 'richLink' | 'fullWidth';
id?: string;
className?: string;
type?: FEElement['_type'];
Expand Down Expand Up @@ -70,6 +70,59 @@ const roleCss = {
}
`,

fullWidth: css`
margin-top: ${space[3]}px;
margin-bottom: ${space[3]}px;

@property --scrollbar-width {
syntax: '<length>';
inherits: true;
initial-value: 15px;
}

--scrollbar-width: 15px;

${until.mobileLandscape} {
margin-left: -10px;
margin-right: -10px;
}
${until.tablet} {
margin-left: -20px;
margin-right: -20px;
}
${from.tablet} {
width: calc(100vw - var(--scrollbar-width, 15px));
max-width: calc(100vw - var(--scrollbar-width, 15px));

--grid-container-max-width: 740px;
--grid-container-left-margin: calc(
((-100vw + (var(--grid-container-max-width) - 42px)) / 2) +
(var(--scrollbar-width, 15px) / 2)
);
--grid-body-column-left: calc(
(var(--grid-container-left-margin, 0px) * -1) +
var(--grid-left-col-width, 0px)
);

margin-left: calc(var(--grid-container-left-margin));
}
${from.desktop} {
--grid-container-max-width: 980px;
}
${from.leftCol} {
--grid-container-max-width: 1140px;
--grid-left-col-width: 140px;
--grid-body-column-left: calc(
(var(--grid-container-left-margin, 0px) * -1) +
var(--grid-left-col-width, 0px) + 21px
);
}
${from.wide} {
--grid-container-max-width: 1300px;
--grid-left-col-width: 219px;
}
`,

showcase: css`
margin-top: ${space[3]}px;
margin-bottom: ${space[3]}px;
Expand Down Expand Up @@ -150,7 +203,7 @@ const roleCss = {

// Used for vast majority of layouts.
export const defaultRoleStyles = (
role: RoleType | 'richLink',
role: RoleType | 'richLink' | 'fullWidth',
format: ArticleFormat,
isTimeline = false,
) => {
Expand All @@ -161,6 +214,8 @@ export const defaultRoleStyles = (
return roleCss.supporting;
case 'immersive':
return roleCss.immersive;
case 'fullWidth':
return roleCss.fullWidth;
case 'showcase':
if (isTimeline) {
return css`
Expand Down
11 changes: 10 additions & 1 deletion dotcom-rendering/src/frontend/schemas/feArticle.json
Original file line number Diff line number Diff line change
Expand Up @@ -2378,7 +2378,16 @@
"type": "string"
},
"role": {
"$ref": "#/definitions/RoleType"
"enum": [
"fullWidth",
"halfWidth",
"immersive",
"inline",
"showcase",
"supporting",
"thumbnail"
],
"type": "string"
}
},
"required": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export const isInteractive = (design: ArticleDesign): boolean =>

export const interactiveLegacyFigureClasses = (
elementType: string,
role?: RoleType,
role?: RoleType | 'fullWidth',
): string => {
const elementClasses: { [key: string]: string } = {
'model.dotcomrendering.pageElements.InteractiveAtomBlockElement':
Expand Down
12 changes: 11 additions & 1 deletion dotcom-rendering/src/lib/renderElement.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1060,7 +1060,17 @@ export const RenderArticleElement = ({
});

const needsFigure = !bareElements.has(element._type);
const role = 'role' in element ? (element.role as RoleType) : undefined;

const isInteractiveFormat =
format.design === ArticleDesign.Interactive ||
format.design === ArticleDesign.FullPageInteractive;

const role: RoleType | 'fullWidth' | undefined =
'role' in element
? element.role === 'fullWidth' && !isInteractiveFormat
? 'immersive'
: (element.role as RoleType | undefined)
: undefined;

return needsFigure ? (
<Figure
Expand Down
11 changes: 10 additions & 1 deletion dotcom-rendering/src/model/block-schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -1866,7 +1866,16 @@
"type": "string"
},
"role": {
"$ref": "#/definitions/RoleType"
"enum": [
"fullWidth",
"halfWidth",
"immersive",
"inline",
"showcase",
"supporting",
"thumbnail"
],
"type": "string"
}
},
"required": [
Expand Down
2 changes: 1 addition & 1 deletion dotcom-rendering/src/types/content.ts
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ export interface InteractiveAtomBlockElement {
html?: string;
css?: string;
placeholderUrl?: string;
role?: RoleType;
role?: RoleType | 'fullWidth';
}

// Can't guarantee anything in interactiveBlockElement :shrug:
Expand Down
Loading