Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
e8e7d89
Rough implementation for mobile view
frederickobrien Feb 25, 2026
fe42bcf
Desktop layout
frederickobrien Feb 27, 2026
b2c0902
Add vertical rules to grid module
frederickobrien Feb 27, 2026
184703d
Fix not appearing
frederickobrien Mar 3, 2026
bf45089
Roll back RightColumn changes
frederickobrien Mar 4, 2026
1401d19
Abstract area placement depending on layout
frederickobrien Mar 4, 2026
49dac14
Human readable furniture row configuration
frederickobrien Mar 5, 2026
0cc57ca
Review polishes and refactors
frederickobrien Mar 6, 2026
a195e3c
Adjust media furniture layout
frederickobrien Mar 10, 2026
8ca2a3d
More consistent row and column grid styling abstraction
frederickobrien Mar 10, 2026
0d1ec8b
Dom review polishes
frederickobrien Mar 11, 2026
2592a0c
Incorporate grid rows into furniture layout config
frederickobrien Mar 11, 2026
e3c23c6
Type tidying
frederickobrien Mar 11, 2026
1fe94e0
Move all column settings into layout config
frederickobrien Mar 11, 2026
d1e17a0
Remove maxWidth wrapper divs
frederickobrien Mar 11, 2026
690a46e
Deduplicate config
frederickobrien Mar 12, 2026
bc79caa
Adjust standard layout to sit properly when there's no featured image
frederickobrien Mar 12, 2026
d406d3f
Tidying
frederickobrien Mar 17, 2026
bf46bf0
Reflect existing conditional padding on right-column area
frederickobrien Mar 18, 2026
3d01f58
Rebase tidy
frederickobrien Mar 18, 2026
72a0419
Rename furnitureLayouts to furnitureArrangements
frederickobrien Apr 15, 2026
1c02fd6
Review suggestions
frederickobrien Apr 21, 2026
c9f0e95
Readability improvements
frederickobrien Apr 22, 2026
418cf95
Documentation
frederickobrien Apr 22, 2026
cb0e17c
Replace abstraction with vanilla CSS approach
frederickobrien Apr 28, 2026
44c4898
Update grid.ts
frederickobrien Apr 30, 2026
a29cb9f
Rebase tidying
frederickobrien Apr 30, 2026
04c9e47
Rough first pass
frederickobrien May 19, 2026
26ae7b0
Refactor grid centre rule, more breakpoints
frederickobrien May 21, 2026
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
53 changes: 39 additions & 14 deletions dotcom-rendering/src/grid.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,35 +88,55 @@ const paddedContainer = `
// ----- Vertical Rules ----- //

type VerticalRuleOptions = {
centre?: boolean;
plusChild?: number;
};

/**
* Render Guardian grid vertical rules.
*
* Left and right rules are always present.
* A centre rule can optionally be enabled.
* A centre rule can optionally be enabled, anchored to the top of the first
* child by default, or to the nth child if a number is passed.
*
* Usage:
* css([grid.container, grid.verticalRules()])
* css([grid.container, grid.verticalRules({ centre: true })])
* css([grid.container, grid.verticalRules({ centre: 3 })])
*/
const optionalCentreRule = `/* CENTRE RULE */
& > *:first-child::before {
grid-column: centre-column-start;
transform: translateX(-${columnGap});
${fromBreakpoint.leftCol} {
transform: translateX(calc(-${columnGap} / 2));
}

// The centre rule is self-contained on the nth child element rather than on
// the grid container, so that `top: 0` aligns to that element's top edge.
// `bottom` uses a large negative value to extend the rule down to the
// container's bottom; ensure `overflow: hidden` is set on the container
const optionalCentreRule = (nth: number): string => `/* CENTRE RULE */
& > *:nth-child(${nth}) {
position: relative;

&::before {
position: absolute;
top: 0;
bottom: -9999px;
width: 1px;
background-color: ${palette('--article-border')};
content: '';
grid-column: centre-column-start;
transform: translateX(-${columnGap});

${fromBreakpoint.leftCol} {
transform: translateX(calc(-${columnGap} / 2));
}
}
}`;

const verticalRules = (options: VerticalRuleOptions = {}): string => `
const verticalRules = (options: VerticalRuleOptions = {}): string => {
const { plusChild: centreChild } = options;

return `
${fromBreakpoint.tablet} {
position: relative;

&::before,
&::after
${options.centre ? ', & > *:first-child::before' : ''} {
&::after {
position: absolute;
top: 0;
bottom: 0;
Expand Down Expand Up @@ -145,8 +165,9 @@ const verticalRules = (options: VerticalRuleOptions = {}): string => `
}
}

${options.centre ? optionalCentreRule : ''}
`;
${centreChild !== undefined ? optionalCentreRule(centreChild) : ''}
}`;
};

// ----- API ----- //

Expand Down Expand Up @@ -251,6 +272,10 @@ const grid = {
verticalRules,
} as const;

// ----- Types ----- //
type ColumnPreset = keyof typeof grid.column;

// ----- Exports ----- //

export type { Line, ColumnPreset };
export { grid };
Loading
Loading