mirror of
https://github.com/bendtherules/UiQuestions.git
synced 2026-08-18 13:52:50 +00:00
Remove DocWrapper usage
This commit is contained in:
@@ -1,24 +0,0 @@
|
|||||||
import React from "react"
|
|
||||||
import { useEffect } from "react"
|
|
||||||
|
|
||||||
const DocWrapper = ({children})=>{
|
|
||||||
|
|
||||||
useEffect(()=>{
|
|
||||||
let hash = location.hash.substring(1);
|
|
||||||
// Remove scroll restoration when there is a hash of length > 0.
|
|
||||||
if (hash.length!==0 && "scrollRestoration" in history) {
|
|
||||||
history.scrollRestoration = "manual"
|
|
||||||
}
|
|
||||||
// Check if the hash type is a Docusauraus link or a reference link within document.
|
|
||||||
let isDocusaurusLink = (hash.substring(0,4) !== "link")
|
|
||||||
let targetElement;
|
|
||||||
targetElement = document.getElementById(hash)
|
|
||||||
if(!targetElement)return
|
|
||||||
if(isDocusaurusLink)
|
|
||||||
targetElement.scrollIntoView(true)
|
|
||||||
},[])
|
|
||||||
|
|
||||||
return <>{children}</>
|
|
||||||
}
|
|
||||||
|
|
||||||
export default DocWrapper
|
|
||||||
@@ -8,6 +8,7 @@ const Link = ({hash,title}) =>{
|
|||||||
window.location.hash = hash;
|
window.location.hash = hash;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return <a onClick={handleLink} className="navlink">{title}</a>
|
return <a onClick={handleLink} className="navlink">{title}</a>
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -9,9 +9,6 @@ import Admonition from "../components/Admonition"
|
|||||||
import Accordion from "../components/Accordion"
|
import Accordion from "../components/Accordion"
|
||||||
import Link from "../components/Link"
|
import Link from "../components/Link"
|
||||||
import MDN from "../components/MDNBadge"
|
import MDN from "../components/MDNBadge"
|
||||||
import DocWrapper from "../components/DocWrapper"
|
|
||||||
|
|
||||||
<DocWrapper>
|
|
||||||
|
|
||||||
:::note DOM interfaces
|
:::note DOM interfaces
|
||||||
Every kind of **DOM** node is represented by an interface based on **Node** interface.
|
Every kind of **DOM** node is represented by an interface based on **Node** interface.
|
||||||
@@ -248,5 +245,3 @@ outerEle.appendChild(fragment)
|
|||||||
--------
|
--------
|
||||||
|
|
||||||
In the next section, we'll see how to read information from a DOM element.
|
In the next section, we'll see how to read information from a DOM element.
|
||||||
|
|
||||||
</DocWrapper>
|
|
||||||
Reference in New Issue
Block a user