Skip to content

Commit be56c9a

Browse files
committed
chore(docs): Adjust spacing
We used to determine the gutter based on whether items were component docs - this brings that back so we can adjust where margins are used. Fixes #4257 Assisted-by: Cursor
1 parent ae66183 commit be56c9a

3 files changed

Lines changed: 51 additions & 6 deletions

File tree

‎packages/documentation-framework/components/example/example.css‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@
66
--pf-v6-c-code-editor__header--before--BorderBottomWidth: 0;
77
}
88

9+
/* Code editor: space before the next block (e.g. section heading). */
10+
[data-prose-content] .ws-code-editor:has(.pf-v6-c-code-editor__header-content:last-child) {
11+
margin-block-end: var(--pf-t--global--spacer--lg);
12+
}
13+
914
.ws-code-editor-control {
1015
--pf-v6-c-button--m-control--BackgroundColor: transparent;
1116
--pf-v6-c-button--m-control--active--BackgroundColor: transparent;

‎packages/documentation-framework/templates/mdx.css‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,27 @@
11
@import './content-sources/ai-guidelines.css';
22

3+
/* Org docs rely on Stack hasGutter for block spacing; suppress paragraph margins. */
34
p.pf-v6-c-content--p.ws-p {
45
margin: 0;
56
}
67

8+
/* Component/code docs and other prose-heavy sources need editorial paragraph spacing. */
9+
[data-prose-content] p.pf-v6-c-content--p.ws-p {
10+
margin-block-end: var(--pf-v6-c-content--MarginBlockEnd);
11+
}
12+
13+
/* Org docs: Stack gutter handles spacing before template sections; not content headings. */
14+
:not([data-prose-content]) .ws-example-page-wrapper.pf-m-gutter .ws-stack-section-heading {
15+
margin-block-start: 0;
16+
}
17+
18+
/* Prose docs: editorial heading spacing (Stack hasGutter is off; typography handles rhythm). */
19+
[data-prose-content] .ws-heading.ws-h2,
20+
[data-prose-content] .ws-heading.ws-h3,
21+
[data-prose-content] .ws-heading.ws-h4 {
22+
margin-block-end: var(--pf-t--global--spacer--lg);
23+
}
24+
725
.ws-code {
826
display: inline-block;
927
background-color: var(--pf-t--global--background--color--secondary--default);

‎packages/documentation-framework/templates/mdx.js‎

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,25 @@ const MDXChildTemplate = ({ Component, source, toc = [], index = 0, id }) => {
8787
ensureID(toc);
8888
}
8989

90-
const isComponentCodeDocs = ['react', 'react-demos', 'html', 'html-demos', 'react-templates'].includes(source);
90+
// Markdown sourced from component/code repos needs editorial paragraph spacing.
91+
const isProseContent = [
92+
'react',
93+
'react-next',
94+
'react-deprecated',
95+
'react-demos',
96+
'react-templates',
97+
'html',
98+
'html-demos',
99+
'html-deprecated',
100+
'ECharts-docs',
101+
'ECharts',
102+
'ECharts-next',
103+
'-Victory',
104+
'-Victory-next',
105+
'ai-guidelines',
106+
'extensions',
107+
'components'
108+
].includes(source);
91109

92110
const InlineAlerts = (optIn ||
93111
beta ||
@@ -134,22 +152,26 @@ const MDXChildTemplate = ({ Component, source, toc = [], index = 0, id }) => {
134152
);
135153
// Create dynamic component for @reach/router
136154
const ChildComponent = () => (
137-
<div className={source !== 'landing-pages' ? 'pf-v6-l-flex pf-v6-m-column pf-m-nowrap-on-2xl' : ''} data-content-source={source}>
155+
<div
156+
className={source !== 'landing-pages' ? 'pf-v6-l-flex pf-v6-m-column pf-m-nowrap-on-2xl' : ''}
157+
data-content-source={source}
158+
{...(isProseContent && { 'data-prose-content': true })}
159+
>
138160
{toc.length > 1 && <TableOfContents items={toc} />}
139-
<Stack hasGutter className={(source !== 'landing-pages' && 'ws-example-page-wrapper')}>
161+
<Stack hasGutter={!isProseContent} className={(source !== 'landing-pages' && 'ws-example-page-wrapper')}>
140162
{InlineAlerts}
141163
<Component />
142164
{functionDocumentation.length > 0 && (
143165
<StackItem>
144-
<AutoLinkHeader headingLevel="h2" className="pf-v6-c-content--h2" id="functions">
166+
<AutoLinkHeader headingLevel="h2" className="pf-v6-c-content--h2 ws-stack-section-heading" id="functions">
145167
Functions
146168
</AutoLinkHeader>
147169
<FunctionsTable functionDescriptions={functionDocumentation} />
148170
</StackItem>
149171
)}
150172
{propsTitle && (
151173
<StackItem>
152-
<AutoLinkHeader headingLevel="h2" className="pf-v6-c-content--h2" id="props">
174+
<AutoLinkHeader headingLevel="h2" className="pf-v6-c-content--h2 ws-stack-section-heading" id="props">
153175
{propsTitle}
154176
</AutoLinkHeader>
155177
{propComponents.map((component) => (
@@ -165,7 +187,7 @@ const MDXChildTemplate = ({ Component, source, toc = [], index = 0, id }) => {
165187
)}
166188
{cssPrefix.length > 0 && (
167189
<StackItem>
168-
<AutoLinkHeader headingLevel="h2" className="pf-v6-c-content--h2" id="css-variables">
190+
<AutoLinkHeader headingLevel="h2" className="pf-v6-c-content--h2 ws-stack-section-heading" id="css-variables">
169191
{cssVarsTitle}
170192
</AutoLinkHeader>
171193
{cssPrefix.map((prefix, index) => (

0 commit comments

Comments
 (0)