Skip to content

Commit ba1e65a

Browse files
committed
feat(layout): center content at standard widths and anchor sidenav/TOC at large screens\n\n- Center content column by default and cap width via CSS var\n- At >=2057px, anchor left sidenav and right TOC to content edges\n- Add 5rem side padding on large screens; keep top padding unchanged\n- No changes to step or separator components in this commit
1 parent 2a9e006 commit ba1e65a

File tree

2 files changed

+46
-11
lines changed

2 files changed

+46
-11
lines changed

src/components/docPage/index.tsx

Lines changed: 45 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -70,14 +70,15 @@ export function DocPage({
7070
<main className="main-content flex w-full mt-[var(--header-height)] flex-1 mx-auto">
7171
<div
7272
className={[
73-
'mx-auto lg:mx-0 pt-6 px-6 prose dark:prose-invert max-w-full text-[var(--gray-12)] prose-a:no-underline hover:prose-a:underline',
73+
'mx-auto pt-6 px-6 prose dark:prose-invert max-w-full text-[var(--gray-12)] prose-a:no-underline hover:prose-a:underline',
7474
'prose-code:font-normal prose-code:font-mono marker:text-[var(--accent)] prose-li:my-1',
7575
'prose-headings:mt-0 prose-headings:font-medium prose-headings:relative prose-headings:text-[var(--gray-12)]',
7676
'prose-blockquote:font-normal prose-blockquote:border-l-[3px] prose-em:font-normal prose-blockquote:text-[var(--gray-12)]',
7777
'prose-img:my-2',
7878
'prose-strong:text-[var(--gray-12)]',
79-
fullWidth ? 'max-w-none w-full' : 'w-[75ch] xl:max-w-[calc(100%-250px)]',
79+
fullWidth ? 'max-w-none w-full' : 'w-full',
8080
].join(' ')}
81+
id="doc-content"
8182
>
8283
<div className="mb-4">
8384
<Banner />
@@ -113,16 +114,50 @@ export function DocPage({
113114
</div>
114115
</div>
115116

116-
{hasToc && (
117-
<aside className="sticky h-[calc(100vh-var(--header-height))] top-[var(--header-height)] overflow-y-auto hidden xl:block w-[250px]">
118-
<div className="sidebar">
119-
<SidebarTableOfContents />
120-
<PlatformSdkDetail />
121-
</div>
122-
</aside>
123-
)}
124117
</main>
118+
{hasToc && (
119+
<aside
120+
data-layout-anchor="right"
121+
className="sticky h-[calc(100vh-var(--header-height))] top-[var(--header-height)] overflow-y-auto hidden xl:block w-[250px]"
122+
>
123+
<div className="sidebar">
124+
<SidebarTableOfContents />
125+
<PlatformSdkDetail />
126+
</div>
127+
</aside>
128+
)}
125129
</section>
130+
<style>{`:root { --doc-content-w: 100ch; } #doc-content { max-width: var(--doc-content-w); }`}</style>
131+
<style>{`
132+
@media (min-width: 2057px) {
133+
:root {
134+
--doc-content-w: 100ch;
135+
--toc-w: 250px;
136+
--gap: 24px;
137+
}
138+
/* Cap content width and center (reinforced at this breakpoint) */
139+
#doc-content {
140+
max-width: var(--doc-content-w);
141+
padding-left: 5rem; /* increase from px-6 (24px) to 5rem (80px) */
142+
padding-right: 5rem;
143+
}
144+
/* Cancel default push so content can center */
145+
[data-layout-anchor="left"] + .main-content {
146+
margin-left: 0 !important;
147+
width: 100% !important;
148+
}
149+
/* Anchor sidebars to content edges */
150+
[data-layout-anchor="left"] {
151+
left: calc(50% - (var(--doc-content-w) / 2) - var(--gap) - var(--sidebar-width));
152+
}
153+
[data-layout-anchor="right"] {
154+
position: fixed !important;
155+
left: calc(50% + (var(--doc-content-w) / 2) + var(--gap));
156+
width: var(--toc-w);
157+
}
158+
}
159+
`}</style>
160+
126161
<Mermaid />
127162
<ReaderDepthTracker />
128163
</div>

src/components/sidebar/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ export async function Sidebar({path, versions}: SidebarProps) {
8181
});
8282

8383
return (
84-
<aside className={`${styles.sidebar} py-3`}>
84+
<aside className={`${styles.sidebar} py-3`} data-layout-anchor="left">
8585
<input type="checkbox" id={sidebarToggleId} className="hidden" />
8686
<style>{':root { --sidebar-width: 300px; }'}</style>
8787
<div className="md:flex flex-col items-stretch overflow-auto">

0 commit comments

Comments
 (0)