-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[v3] fix normalize pages issues, back to top issues (#2654)
* aa * fix * fix lint * fix build error * fix back to top * prettier * back to top true by default * remove some stuff * a * prettier * optimize imports * aa * try * comment for now
- Loading branch information
Dimitri POSTOLOV
authored
Jan 27, 2024
1 parent
e0d18e0
commit 45471df
Showing
19 changed files
with
145 additions
and
278 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
--- | ||
'nextra-theme-docs': patch | ||
--- | ||
|
||
fix “Scroll to top” is not supposed to be interactable when it is hidden. | ||
|
||
`display:children` doesn't collapse breadcrumbs | ||
|
||
hide external links from pagination | ||
|
||
remove xmlns attribute from icons |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -127,9 +127,6 @@ const config: DocsThemeConfig = { | |
</p> | ||
</div> | ||
) | ||
}, | ||
toc: { | ||
backToTop: true | ||
} | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 10 additions & 18 deletions
28
packages/nextra-theme-docs/src/components/back-to-top.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,30 @@ | ||
import cn from 'clsx' | ||
import { ArrowRightIcon } from 'nextra/icons' | ||
import type { ReactElement } from 'react' | ||
import { useEffect, useRef } from 'react' | ||
|
||
function scrollToTop() { | ||
window.scrollTo({ top: 0, behavior: 'smooth' }) | ||
} | ||
|
||
export function BackToTop({ className }: { className?: string }): ReactElement { | ||
const ref = useRef<HTMLButtonElement>(null) | ||
useEffect(() => { | ||
function toggleVisible() { | ||
const { scrollTop } = document.documentElement | ||
ref.current?.classList.toggle('_opacity-0', scrollTop < 300) | ||
} | ||
|
||
window.addEventListener('scroll', toggleVisible) | ||
return () => { | ||
window.removeEventListener('scroll', toggleVisible) | ||
} | ||
}, []) | ||
|
||
export function BackToTop({ | ||
className, | ||
hidden | ||
}: { | ||
className?: string | ||
hidden: boolean | ||
}): ReactElement { | ||
return ( | ||
<button | ||
ref={ref} | ||
aria-hidden="true" | ||
onClick={scrollToTop} | ||
disabled={hidden} | ||
className={cn( | ||
'_flex _items-center _gap-1.5 _transition _opacity-0', | ||
'_flex _items-center _gap-1.5 _transition _opacity-100 disabled:_opacity-0', | ||
className | ||
)} | ||
> | ||
Scroll to top | ||
<ArrowRightIcon className="_-rotate-90 _w-3.5 _h-3.5 _border _rounded-full _border-current" /> | ||
<ArrowRightIcon className="_-rotate-90 _size-4 _border _rounded-full _border-current" /> | ||
</button> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 0 additions & 5 deletions
5
packages/nextra/__test__/fixture/page-maps/display-hidden-for-mobile/_meta.ts
This file was deleted.
Oops, something went wrong.
Empty file removed
0
...nextra/__test__/fixture/page-maps/display-hidden-for-mobile/bar/baz/quz/qwe.mdx
Empty file.
28 changes: 0 additions & 28 deletions
28
.../nextra/__test__/fixture/page-maps/display-hidden-for-mobile/chunks/generated-page-map.js
This file was deleted.
Oops, something went wrong.
Empty file.
Oops, something went wrong.