mirror of
https://github.com/facebook/docusaurus.git
synced 2025-07-08 04:17:55 +02:00
feat(v2): Provide typing to most of the theme-classic components (#3348)
* feat(v2): Provide typing to most of the theme-classic components * Expose type to the end users and dogfood it in v2 website
This commit is contained in:
parent
658dac7d42
commit
bd9b6618c1
31 changed files with 440 additions and 125 deletions
|
@ -7,8 +7,7 @@
|
|||
|
||||
import {useState, useEffect} from 'react';
|
||||
import ExecutionEnvironment from '@docusaurus/ExecutionEnvironment';
|
||||
|
||||
type ScrollPosition = {scrollX: number; scrollY: number};
|
||||
import type {ScrollPosition} from '@theme/hooks/useScrollPosition';
|
||||
|
||||
const getScrollPosition = (): ScrollPosition => ({
|
||||
scrollX: ExecutionEnvironment.canUseDOM ? window.pageXOffset : 0,
|
||||
|
@ -16,7 +15,7 @@ const getScrollPosition = (): ScrollPosition => ({
|
|||
});
|
||||
|
||||
const useScrollPosition = (
|
||||
effect: (position: ScrollPosition) => void,
|
||||
effect?: (position: ScrollPosition) => void,
|
||||
deps = [],
|
||||
): ScrollPosition => {
|
||||
const [scrollPosition, setScrollPosition] = useState(getScrollPosition());
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue