Skip to content

Commit 0860aa0

Browse files
committed
fix(theme): scope single post layout styles
Avoid targeting WordPress' body.single class so single post pages keep the newspaper layout without turning the full document into a grid.
1 parent 652b5fd commit 0860aa0

2 files changed

Lines changed: 24 additions & 5 deletions

File tree

assets/css/custom.css

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2180,7 +2180,7 @@ body {
21802180
.stamp { border: 2px solid var(--bleed); color: var(--bleed); padding: 12px 14px; font-family: "JetBrains Mono", monospace; font-size: 11px; letter-spacing: 0.06em; text-transform: uppercase; transform: rotate(-2deg); text-align: center; font-weight: 600; line-height: 1.3; }
21812181
.stamp .big { display: block; font-size: 22px; font-family: "Fraunces", serif; font-weight: 900; letter-spacing: -0.02em; margin: 4px 0; }
21822182

2183-
.single { display: grid; grid-template-columns: 220px 1fr 240px; gap: 36px; padding: 36px 32px 100px; }
2183+
.single.wrap { display: grid; grid-template-columns: 220px 1fr 240px; gap: 36px; padding: 36px 32px 100px; }
21842184
.post-meta-rail, .toc-rail { font-family: "JetBrains Mono", monospace; font-size: 11px; position: sticky; top: 24px; align-self: start; }
21852185
.post-back { font-family: "JetBrains Mono", monospace; font-size: 11px; color: var(--ink-mute); text-decoration: none; text-transform: uppercase; letter-spacing: 0.08em; display: inline-block; margin-bottom: 24px; }
21862186
.post-back:hover { color: var(--bleed); }
@@ -2242,8 +2242,8 @@ body {
22422242
[data-theme="dark"] .aj-banner { background: var(--paper-dark); color: var(--ink); border: 1px solid var(--rule); border-left: 6px solid var(--hot); }
22432243

22442244
@media (max-width: 1100px) {
2245-
.layout, .single { grid-template-columns: 180px 1fr; gap: 24px; }
2246-
.layout > aside:last-of-type, .single > aside.toc-rail { display: none; }
2245+
.layout, .single.wrap { grid-template-columns: 180px 1fr; gap: 24px; }
2246+
.layout > aside:last-of-type, .single.wrap > aside.toc-rail { display: none; }
22472247
.mast-row { grid-template-columns: auto 1fr; gap: 20px; row-gap: 16px; }
22482248
.mast-tag { display: none; }
22492249
.mast-utility { grid-column: 1 / -1; justify-content: flex-end; }
@@ -2253,7 +2253,7 @@ body {
22532253
}
22542254

22552255
@media (max-width: 760px) {
2256-
.wrap, .masthead, .layout, .single { padding-left: 16px; padding-right: 16px; }
2256+
.wrap, .masthead, .layout, .single.wrap { padding-left: 16px; padding-right: 16px; }
22572257
.ticker { font-size: 10px; }
22582258
.masthead { padding-top: 18px; padding-bottom: 14px; }
22592259
.mast-row { display: block; }
@@ -2263,7 +2263,7 @@ body {
22632263
.nav { overflow-x: auto; padding: 0; }
22642264
.nav-item { padding: 12px 14px; font-size: 11px; flex-shrink: 0; }
22652265
.nav-spacer, .nav-status { display: none; }
2266-
.layout, .single { display: block; padding-top: 28px; }
2266+
.layout, .single.wrap { display: block; padding-top: 28px; }
22672267
.rail, .post-meta-rail { display: none; }
22682268
.lede { grid-template-columns: 1fr; gap: 10px; padding-bottom: 28px; }
22692269
.lede-marker { writing-mode: horizontal-tb; transform: none; border-left: 0; border-bottom: 2px solid var(--bleed); padding: 0 0 6px; }

tests/theme-design-static.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,14 @@
1515
'assets/css/custom.css' => array( '--paper', '--hot', '.ticker', '.masthead', '.entry-hash' ),
1616
);
1717

18+
$forbidden_css = array(
19+
'.single {' => 'WordPress adds body.single on posts; target .single.wrap instead.',
20+
'.layout, .single {' => 'WordPress body.single must not inherit layout grid rules.',
21+
'.layout, .single ' => 'Responsive selectors must target .single.wrap.',
22+
'.single > aside' => 'Child selectors must target .single.wrap.',
23+
'.single { display' => 'WordPress body.single must not become the layout grid.',
24+
);
25+
1826
$failures = array();
1927

2028
foreach ( $checks as $relative_path => $needles ) {
@@ -33,6 +41,17 @@
3341
}
3442
}
3543

44+
$css_path = $root . '/assets/css/custom.css';
45+
$css_contents = file_get_contents( $css_path );
46+
47+
if ( false !== $css_contents ) {
48+
foreach ( $forbidden_css as $needle => $message ) {
49+
if ( false !== strpos( $css_contents, $needle ) ) {
50+
$failures[] = 'assets/css/custom.css has unsafe selector ' . $needle . '' . $message;
51+
}
52+
}
53+
}
54+
3655
if ( $failures ) {
3756
fwrite( STDERR, implode( PHP_EOL, $failures ) . PHP_EOL );
3857
exit( 1 );

0 commit comments

Comments
 (0)