Skip to content

Commit 74d2616

Browse files
committed
fix layout flexbug
1 parent 095fcc3 commit 74d2616

File tree

2 files changed

+47
-54
lines changed

2 files changed

+47
-54
lines changed

src/layouts/ContentsLayout.js

+40-46
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import {
88
useContext,
99
} from 'react'
1010
import { ClassTable } from '@/components/ClassTable'
11-
import { useIsHome } from '@/hooks/useIsHome'
1211
import { usePrevNext } from '@/hooks/usePrevNext'
1312
import Link from 'next/link'
1413
import { SidebarLayout, SidebarContext } from '@/layouts/SidebarLayout'
@@ -165,56 +164,51 @@ export function ContentsLayout({ children, meta, classes, tableOfContents }) {
165164
]
166165

167166
const { currentSection, registerHeading, unregisterHeading } = useTableOfContents(toc)
168-
let isHome = useIsHome()
169167
let { prev, next } = usePrevNext()
170168

171169
return (
172-
<div id={meta.containerId} className="pt-10 pb-16 w-full">
173-
<div className="flex">
174-
<div className="flex-auto px-6 xl:px-8">
175-
<PageHeader
176-
title={meta.title}
177-
description={meta.description}
178-
badge={{ key: 'Tailwind CSS version', value: meta.featureVersion }}
179-
border={!classes && meta.headerSeparator !== false}
180-
/>
181-
<ContentsContext.Provider value={{ registerHeading, unregisterHeading }}>
182-
{classes && (
183-
<ClassTable {...(isValidElement(classes) ? { custom: classes } : classes)} />
184-
)}
185-
{children}
186-
</ContentsContext.Provider>
187-
{(prev || next) && (
188-
<>
189-
<hr />
190-
<div className="-mt-6 flex justify-between">
191-
{prev && (
192-
<Link href={prev.href}>
193-
<a className="font-medium text-blue-500 underline hover:text-blue-700">
194-
{prev.shortTitle || prev.title}
195-
</a>
196-
</Link>
197-
)}
198-
{next && (
199-
<Link href={next.href}>
200-
<a className="font-medium text-blue-500 underline hover:text-blue-700">
201-
{next.shortTitle || next.title}
202-
</a>
203-
</Link>
204-
)}
205-
</div>
206-
</>
170+
<div id={meta.containerId} className="pt-10 pb-16 w-full flex">
171+
<div className="min-w-0 flex-auto px-6 xl:px-8">
172+
<PageHeader
173+
title={meta.title}
174+
description={meta.description}
175+
badge={{ key: 'Tailwind CSS version', value: meta.featureVersion }}
176+
border={!classes && meta.headerSeparator !== false}
177+
/>
178+
<ContentsContext.Provider value={{ registerHeading, unregisterHeading }}>
179+
{classes && <ClassTable {...(isValidElement(classes) ? { custom: classes } : classes)} />}
180+
{children}
181+
</ContentsContext.Provider>
182+
{(prev || next) && (
183+
<>
184+
<hr />
185+
<div className="-mt-6 flex justify-between">
186+
{prev && (
187+
<Link href={prev.href}>
188+
<a className="font-medium text-blue-500 underline hover:text-blue-700">
189+
{prev.shortTitle || prev.title}
190+
</a>
191+
</Link>
192+
)}
193+
{next && (
194+
<Link href={next.href}>
195+
<a className="font-medium text-blue-500 underline hover:text-blue-700">
196+
{next.shortTitle || next.title}
197+
</a>
198+
</Link>
199+
)}
200+
</div>
201+
</>
202+
)}
203+
</div>
204+
<div className="hidden xl:text-sm xl:block flex-none w-64 pl-8 pr-12">
205+
<div className="flex flex-col justify-between overflow-y-auto sticky max-h-(screen-18) -mt-10 pt-10 pb-4 top-18">
206+
{toc.length > 0 && (
207+
<div className="mb-8">
208+
<TableOfContents tableOfContents={toc} currentSection={currentSection} />
209+
</div>
207210
)}
208211
</div>
209-
<div className="hidden xl:text-sm xl:block flex-none w-64 pl-8 pr-12">
210-
<div className="flex flex-col justify-between overflow-y-auto sticky max-h-(screen-18) -mt-10 pt-10 pb-4 top-18">
211-
{toc.length > 0 && (
212-
<div className="mb-8">
213-
<TableOfContents tableOfContents={toc} currentSection={currentSection} />
214-
</div>
215-
)}
216-
</div>
217-
</div>
218212
</div>
219213
</div>
220214
)

src/layouts/SidebarLayout.js

+7-8
Original file line numberDiff line numberDiff line change
@@ -291,15 +291,14 @@ export function SidebarLayout({ children, navIsOpen, setNavIsOpen, nav, sidebar,
291291
</div>
292292
<div
293293
id="content-wrapper"
294-
className={clsx('min-h-screen flex-auto lg:static lg:max-h-full lg:overflow-visible', {
295-
'overflow-hidden max-h-screen fixed': navIsOpen,
296-
})}
294+
className={clsx(
295+
'min-h-screen min-w-0 flex-auto lg:static lg:max-h-full lg:overflow-visible',
296+
{
297+
'overflow-hidden max-h-screen fixed': navIsOpen,
298+
}
299+
)}
297300
>
298-
<div id="content">
299-
<div id="app" className="flex">
300-
{children}
301-
</div>
302-
</div>
301+
{children}
303302
</div>
304303
</div>
305304
</div>

0 commit comments

Comments
 (0)