@azerion/bunosaurus-theme-common 0.0.0-stage → 4.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/lib/components/Collapsible/index.d.ts +59 -0
- package/lib/components/Collapsible/index.d.ts.map +1 -0
- package/lib/components/Collapsible/index.js +145 -0
- package/lib/components/Collapsible/index.js.map +1 -0
- package/lib/components/Details/index.d.ts +20 -0
- package/lib/components/Details/index.d.ts.map +1 -0
- package/lib/components/Details/index.js +86 -0
- package/lib/components/Details/index.js.map +1 -0
- package/lib/components/Details/styles.module.css +66 -0
- package/lib/components/ThemedComponent/index.d.ts +31 -0
- package/lib/components/ThemedComponent/index.d.ts.map +1 -0
- package/lib/components/ThemedComponent/index.js +47 -0
- package/lib/components/ThemedComponent/index.js.map +1 -0
- package/lib/components/ThemedComponent/styles.module.css +26 -0
- package/lib/contexts/announcementBar.d.ts +21 -0
- package/lib/contexts/announcementBar.d.ts.map +1 -0
- package/lib/contexts/announcementBar.js +72 -0
- package/lib/contexts/announcementBar.js.map +1 -0
- package/lib/contexts/colorMode.d.ts +23 -0
- package/lib/contexts/colorMode.d.ts.map +1 -0
- package/lib/contexts/colorMode.js +163 -0
- package/lib/contexts/colorMode.js.map +1 -0
- package/lib/contexts/navbarMobileSidebar.d.ts +31 -0
- package/lib/contexts/navbarMobileSidebar.d.ts.map +1 -0
- package/lib/contexts/navbarMobileSidebar.js +65 -0
- package/lib/contexts/navbarMobileSidebar.js.map +1 -0
- package/lib/contexts/navbarSecondaryMenu/content.d.ts +37 -0
- package/lib/contexts/navbarSecondaryMenu/content.d.ts.map +1 -0
- package/lib/contexts/navbarSecondaryMenu/content.js +50 -0
- package/lib/contexts/navbarSecondaryMenu/content.js.map +1 -0
- package/lib/contexts/navbarSecondaryMenu/display.d.ts +24 -0
- package/lib/contexts/navbarSecondaryMenu/display.d.ts.map +1 -0
- package/lib/contexts/navbarSecondaryMenu/display.js +62 -0
- package/lib/contexts/navbarSecondaryMenu/display.js.map +1 -0
- package/lib/hooks/useBackToTopButton.d.ts +27 -0
- package/lib/hooks/useBackToTopButton.d.ts.map +1 -0
- package/lib/hooks/useBackToTopButton.js +50 -0
- package/lib/hooks/useBackToTopButton.js.map +1 -0
- package/lib/hooks/useCodeWordWrap.d.ts +15 -0
- package/lib/hooks/useCodeWordWrap.d.ts.map +1 -0
- package/lib/hooks/useCodeWordWrap.js +67 -0
- package/lib/hooks/useCodeWordWrap.js.map +1 -0
- package/lib/hooks/useHideableNavbar.d.ts +17 -0
- package/lib/hooks/useHideableNavbar.d.ts.map +1 -0
- package/lib/hooks/useHideableNavbar.js +65 -0
- package/lib/hooks/useHideableNavbar.js.map +1 -0
- package/lib/hooks/useLockBodyScroll.d.ts +12 -0
- package/lib/hooks/useLockBodyScroll.d.ts.map +1 -0
- package/lib/hooks/useLockBodyScroll.js +20 -0
- package/lib/hooks/useLockBodyScroll.js.map +1 -0
- package/lib/hooks/useMutationObserver.d.ts +4 -0
- package/lib/hooks/useMutationObserver.d.ts.map +1 -0
- package/lib/hooks/useMutationObserver.js +29 -0
- package/lib/hooks/useMutationObserver.js.map +1 -0
- package/lib/hooks/usePrismTheme.d.ts +13 -0
- package/lib/hooks/usePrismTheme.d.ts.map +1 -0
- package/lib/hooks/usePrismTheme.js +21 -0
- package/lib/hooks/usePrismTheme.js.map +1 -0
- package/lib/hooks/useTOCHighlight.d.ts +25 -0
- package/lib/hooks/useTOCHighlight.d.ts.map +1 -0
- package/lib/hooks/useTOCHighlight.js +130 -0
- package/lib/hooks/useTOCHighlight.js.map +1 -0
- package/lib/hooks/useWindowSize.d.ts +27 -0
- package/lib/hooks/useWindowSize.d.ts.map +1 -0
- package/lib/hooks/useWindowSize.js +49 -0
- package/lib/hooks/useWindowSize.js.map +1 -0
- package/lib/index.d.ts +30 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +37 -0
- package/lib/index.js.map +1 -0
- package/lib/internal.d.ts +35 -0
- package/lib/internal.d.ts.map +1 -0
- package/lib/internal.js +45 -0
- package/lib/internal.js.map +1 -0
- package/lib/translations/blogTranslations.d.ts +20 -0
- package/lib/translations/blogTranslations.d.ts.map +1 -0
- package/lib/translations/blogTranslations.js +52 -0
- package/lib/translations/blogTranslations.js.map +1 -0
- package/lib/translations/contentVisibilityTranslations.d.ts +12 -0
- package/lib/translations/contentVisibilityTranslations.d.ts.map +1 -0
- package/lib/translations/contentVisibilityTranslations.js +30 -0
- package/lib/translations/contentVisibilityTranslations.js.map +1 -0
- package/lib/translations/docsTranslations.d.ts +8 -0
- package/lib/translations/docsTranslations.d.ts.map +1 -0
- package/lib/translations/docsTranslations.js +17 -0
- package/lib/translations/docsTranslations.js.map +1 -0
- package/lib/utils/IntlUtils.d.ts +2 -0
- package/lib/utils/IntlUtils.d.ts.map +1 -0
- package/lib/utils/IntlUtils.js +20 -0
- package/lib/utils/IntlUtils.js.map +1 -0
- package/lib/utils/ThemeClassNames.d.ts +99 -0
- package/lib/utils/ThemeClassNames.d.ts.map +1 -0
- package/lib/utils/ThemeClassNames.js +107 -0
- package/lib/utils/ThemeClassNames.js.map +1 -0
- package/lib/utils/accessibilityUtils.d.ts +8 -0
- package/lib/utils/accessibilityUtils.d.ts.map +1 -0
- package/lib/utils/accessibilityUtils.js +10 -0
- package/lib/utils/accessibilityUtils.js.map +1 -0
- package/lib/utils/admonitionUtils.d.ts +12 -0
- package/lib/utils/admonitionUtils.d.ts.map +1 -0
- package/lib/utils/admonitionUtils.js +32 -0
- package/lib/utils/admonitionUtils.js.map +1 -0
- package/lib/utils/anchorUtils.d.ts +16 -0
- package/lib/utils/anchorUtils.d.ts.map +1 -0
- package/lib/utils/anchorUtils.js +26 -0
- package/lib/utils/anchorUtils.js.map +1 -0
- package/lib/utils/anchorUtils.module.css +14 -0
- package/lib/utils/codeBlockUtils.d.ts +101 -0
- package/lib/utils/codeBlockUtils.d.ts.map +1 -0
- package/lib/utils/codeBlockUtils.js +310 -0
- package/lib/utils/codeBlockUtils.js.map +1 -0
- package/lib/utils/emojiUtils.d.ts +20 -0
- package/lib/utils/emojiUtils.d.ts.map +1 -0
- package/lib/utils/emojiUtils.js +32 -0
- package/lib/utils/emojiUtils.js.map +1 -0
- package/lib/utils/errorBoundaryUtils.d.ts +31 -0
- package/lib/utils/errorBoundaryUtils.d.ts.map +1 -0
- package/lib/utils/errorBoundaryUtils.js +48 -0
- package/lib/utils/errorBoundaryUtils.js.map +1 -0
- package/lib/utils/errorBoundaryUtils.module.css +16 -0
- package/lib/utils/footerUtils.d.ts +13 -0
- package/lib/utils/footerUtils.d.ts.map +1 -0
- package/lib/utils/footerUtils.js +14 -0
- package/lib/utils/footerUtils.js.map +1 -0
- package/lib/utils/historyUtils.d.ts +39 -0
- package/lib/utils/historyUtils.d.ts.map +1 -0
- package/lib/utils/historyUtils.js +148 -0
- package/lib/utils/historyUtils.js.map +1 -0
- package/lib/utils/jsUtils.d.ts +24 -0
- package/lib/utils/jsUtils.d.ts.map +1 -0
- package/lib/utils/jsUtils.js +43 -0
- package/lib/utils/jsUtils.js.map +1 -0
- package/lib/utils/metadataUtils.d.ts +38 -0
- package/lib/utils/metadataUtils.d.ts.map +1 -0
- package/lib/utils/metadataUtils.js +87 -0
- package/lib/utils/metadataUtils.js.map +1 -0
- package/lib/utils/navbarUtils.d.ts +21 -0
- package/lib/utils/navbarUtils.d.ts.map +1 -0
- package/lib/utils/navbarUtils.js +35 -0
- package/lib/utils/navbarUtils.js.map +1 -0
- package/lib/utils/reactUtils.d.ts +60 -0
- package/lib/utils/reactUtils.d.ts.map +1 -0
- package/lib/utils/reactUtils.js +91 -0
- package/lib/utils/reactUtils.js.map +1 -0
- package/lib/utils/regexpUtils.d.ts +12 -0
- package/lib/utils/regexpUtils.d.ts.map +1 -0
- package/lib/utils/regexpUtils.js +18 -0
- package/lib/utils/regexpUtils.js.map +1 -0
- package/lib/utils/routesUtils.d.ts +26 -0
- package/lib/utils/routesUtils.d.ts.map +1 -0
- package/lib/utils/routesUtils.js +54 -0
- package/lib/utils/routesUtils.js.map +1 -0
- package/lib/utils/scrollUtils.d.ts +83 -0
- package/lib/utils/scrollUtils.d.ts.map +1 -0
- package/lib/utils/scrollUtils.js +201 -0
- package/lib/utils/scrollUtils.js.map +1 -0
- package/lib/utils/searchUtils.d.ts +8 -0
- package/lib/utils/searchUtils.d.ts.map +1 -0
- package/lib/utils/searchUtils.js +8 -0
- package/lib/utils/searchUtils.js.map +1 -0
- package/lib/utils/skipToContentUtils.d.ts +20 -0
- package/lib/utils/skipToContentUtils.d.ts.map +1 -0
- package/lib/utils/skipToContentUtils.js +75 -0
- package/lib/utils/skipToContentUtils.js.map +1 -0
- package/lib/utils/storageUtils.d.ts +36 -0
- package/lib/utils/storageUtils.d.ts.map +1 -0
- package/lib/utils/storageUtils.js +193 -0
- package/lib/utils/storageUtils.js.map +1 -0
- package/lib/utils/tabsUtils.d.ts +55 -0
- package/lib/utils/tabsUtils.d.ts.map +1 -0
- package/lib/utils/tabsUtils.js +179 -0
- package/lib/utils/tabsUtils.js.map +1 -0
- package/lib/utils/tagsUtils.d.ts +20 -0
- package/lib/utils/tagsUtils.d.ts.map +1 -0
- package/lib/utils/tagsUtils.js +41 -0
- package/lib/utils/tagsUtils.js.map +1 -0
- package/lib/utils/titleFormatterUtils.d.ts +59 -0
- package/lib/utils/titleFormatterUtils.d.ts.map +1 -0
- package/lib/utils/titleFormatterUtils.js +49 -0
- package/lib/utils/titleFormatterUtils.js.map +1 -0
- package/lib/utils/tocUtils.d.ts +36 -0
- package/lib/utils/tocUtils.d.ts.map +1 -0
- package/lib/utils/tocUtils.js +84 -0
- package/lib/utils/tocUtils.js.map +1 -0
- package/lib/utils/useAlternatePageUtils.d.ts +32 -0
- package/lib/utils/useAlternatePageUtils.d.ts.map +1 -0
- package/lib/utils/useAlternatePageUtils.js +42 -0
- package/lib/utils/useAlternatePageUtils.js.map +1 -0
- package/lib/utils/useLocalPathname.d.ts +13 -0
- package/lib/utils/useLocalPathname.d.ts.map +1 -0
- package/lib/utils/useLocalPathname.js +19 -0
- package/lib/utils/useLocalPathname.js.map +1 -0
- package/lib/utils/useLocationChange.d.ts +17 -0
- package/lib/utils/useLocationChange.d.ts.map +1 -0
- package/lib/utils/useLocationChange.js +31 -0
- package/lib/utils/useLocationChange.js.map +1 -0
- package/lib/utils/usePluralForm.d.ts +21 -0
- package/lib/utils/usePluralForm.d.ts.map +1 -0
- package/lib/utils/usePluralForm.js +93 -0
- package/lib/utils/usePluralForm.js.map +1 -0
- package/lib/utils/useThemeConfig.d.ts +120 -0
- package/lib/utils/useThemeConfig.d.ts.map +1 -0
- package/lib/utils/useThemeConfig.js +14 -0
- package/lib/utils/useThemeConfig.js.map +1 -0
- package/package.json +58 -4
- package/src/components/Collapsible/index.tsx +250 -0
- package/src/components/Details/index.tsx +130 -0
- package/src/components/Details/styles.module.css +66 -0
- package/src/components/ThemedComponent/index.tsx +75 -0
- package/src/components/ThemedComponent/styles.module.css +26 -0
- package/src/contexts/announcementBar.tsx +117 -0
- package/src/contexts/colorMode.tsx +257 -0
- package/src/contexts/navbarMobileSidebar.tsx +119 -0
- package/src/contexts/navbarSecondaryMenu/content.tsx +100 -0
- package/src/contexts/navbarSecondaryMenu/display.tsx +102 -0
- package/src/hooks/useBackToTopButton.ts +73 -0
- package/src/hooks/useCodeWordWrap.ts +107 -0
- package/src/hooks/useHideableNavbar.ts +81 -0
- package/src/hooks/useLockBodyScroll.ts +21 -0
- package/src/hooks/useMutationObserver.ts +38 -0
- package/src/hooks/usePrismTheme.ts +24 -0
- package/src/hooks/useTOCHighlight.ts +189 -0
- package/src/hooks/useWindowSize.ts +67 -0
- package/src/index.ts +112 -0
- package/src/internal.ts +107 -0
- package/src/translations/blogTranslations.tsx +89 -0
- package/src/translations/contentVisibilityTranslations.tsx +51 -0
- package/src/translations/docsTranslations.tsx +28 -0
- package/src/types.d.ts +8 -0
- package/src/utils/IntlUtils.ts +27 -0
- package/src/utils/ThemeClassNames.ts +119 -0
- package/src/utils/accessibilityUtils.ts +10 -0
- package/src/utils/admonitionUtils.tsx +44 -0
- package/src/utils/anchorUtils.module.css +14 -0
- package/src/utils/anchorUtils.ts +31 -0
- package/src/utils/codeBlockUtils.tsx +494 -0
- package/src/utils/emojiUtils.ts +40 -0
- package/src/utils/errorBoundaryUtils.module.css +16 -0
- package/src/utils/errorBoundaryUtils.tsx +71 -0
- package/src/utils/footerUtils.ts +18 -0
- package/src/utils/historyUtils.ts +199 -0
- package/src/utils/jsUtils.ts +54 -0
- package/src/utils/metadataUtils.tsx +145 -0
- package/src/utils/navbarUtils.tsx +45 -0
- package/src/utils/reactUtils.tsx +120 -0
- package/src/utils/regexpUtils.ts +24 -0
- package/src/utils/routesUtils.ts +75 -0
- package/src/utils/scrollUtils.tsx +303 -0
- package/src/utils/searchUtils.ts +8 -0
- package/src/utils/skipToContentUtils.tsx +108 -0
- package/src/utils/storageUtils.ts +260 -0
- package/src/utils/tabsUtils.tsx +307 -0
- package/src/utils/tagsUtils.tsx +61 -0
- package/src/utils/titleFormatterUtils.tsx +120 -0
- package/src/utils/tocUtils.ts +119 -0
- package/src/utils/useAlternatePageUtils.ts +80 -0
- package/src/utils/useLocalPathname.ts +22 -0
- package/src/utils/useLocationChange.ts +41 -0
- package/src/utils/usePluralForm.ts +131 -0
- package/src/utils/useThemeConfig.ts +147 -0
package/README.md
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
#
|
|
1
|
+
# `@docusaurus/theme-common`
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Common code for Docusaurus themes.
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
import type React from 'react';
|
|
8
|
+
import { type Dispatch, type SetStateAction, type ReactNode } from 'react';
|
|
9
|
+
/**
|
|
10
|
+
* This hook is a very thin wrapper around a `useState`.
|
|
11
|
+
*/
|
|
12
|
+
export declare function useCollapsible({ initialState, }: {
|
|
13
|
+
/** The initial state. Will be non-collapsed by default. */
|
|
14
|
+
initialState?: boolean | (() => boolean);
|
|
15
|
+
}): {
|
|
16
|
+
collapsed: boolean;
|
|
17
|
+
setCollapsed: Dispatch<SetStateAction<boolean>>;
|
|
18
|
+
toggleCollapsed: () => void;
|
|
19
|
+
};
|
|
20
|
+
type CollapsibleAnimationConfig = {
|
|
21
|
+
duration?: number;
|
|
22
|
+
easing?: string;
|
|
23
|
+
};
|
|
24
|
+
type CollapsibleElementType = React.ElementType<Pick<React.HTMLAttributes<unknown>, 'className' | 'onTransitionEnd' | 'style'>>;
|
|
25
|
+
type CollapsibleBaseProps = {
|
|
26
|
+
/** The actual DOM element to be used in the markup. */
|
|
27
|
+
as?: CollapsibleElementType;
|
|
28
|
+
/** Initial collapsed state. */
|
|
29
|
+
collapsed: boolean;
|
|
30
|
+
children: ReactNode;
|
|
31
|
+
/** Configuration of animation, like `duration` and `easing` */
|
|
32
|
+
animation?: CollapsibleAnimationConfig;
|
|
33
|
+
/**
|
|
34
|
+
* A callback fired when the collapse transition animation ends. Receives
|
|
35
|
+
* the **new** collapsed state: e.g. when
|
|
36
|
+
* expanding, `collapsed` will be `false`. You can use this for some "cleanup"
|
|
37
|
+
* like applying new styles when the container is fully expanded.
|
|
38
|
+
*/
|
|
39
|
+
onCollapseTransitionEnd?: (collapsed: boolean) => void;
|
|
40
|
+
/** Class name for the underlying DOM element. */
|
|
41
|
+
className?: string;
|
|
42
|
+
};
|
|
43
|
+
type CollapsibleProps = CollapsibleBaseProps & {
|
|
44
|
+
/**
|
|
45
|
+
* Delay rendering of the content till first expansion. Marked as required to
|
|
46
|
+
* force us to think if content should be server-rendered or not. This has
|
|
47
|
+
* perf impact since it reduces html file sizes, but could undermine SEO.
|
|
48
|
+
* @see https://github.com/facebook/docusaurus/issues/4753
|
|
49
|
+
*/
|
|
50
|
+
lazy: boolean;
|
|
51
|
+
};
|
|
52
|
+
/**
|
|
53
|
+
* A headless component providing smooth and uniform collapsing behavior. The
|
|
54
|
+
* component will be invisible (zero height) when collapsed. Doesn't provide
|
|
55
|
+
* interactivity by itself: collapse state is toggled through props.
|
|
56
|
+
*/
|
|
57
|
+
export declare function Collapsible({ lazy, ...props }: CollapsibleProps): ReactNode;
|
|
58
|
+
export {};
|
|
59
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/Collapsible/index.tsx"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAOL,KAAK,QAAQ,EACb,KAAK,cAAc,EACnB,KAAK,SAAS,EACf,MAAM,OAAO,CAAC;AAKf;;GAEG;AACH,wBAAgB,cAAc,CAAC,EAC7B,YAAY,GACb,EAAE;IACD,2DAA2D;IAC3D,YAAY,CAAC,EAAE,OAAO,GAAG,CAAC,MAAM,OAAO,CAAC,CAAC;CAC1C,GAAG;IACF,SAAS,EAAE,OAAO,CAAC;IACnB,YAAY,EAAE,QAAQ,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC,CAAC;IAChD,eAAe,EAAE,MAAM,IAAI,CAAC;CAC7B,CAYA;AAqCD,KAAK,0BAA0B,GAAG;IAChC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAoEF,KAAK,sBAAsB,GAAG,KAAK,CAAC,WAAW,CAC7C,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,OAAO,CAAC,EAAE,WAAW,GAAG,iBAAiB,GAAG,OAAO,CAAC,CAC/E,CAAC;AAEF,KAAK,oBAAoB,GAAG;IAC1B,uDAAuD;IACvD,EAAE,CAAC,EAAE,sBAAsB,CAAC;IAC5B,+BAA+B;IAC/B,SAAS,EAAE,OAAO,CAAC;IACnB,QAAQ,EAAE,SAAS,CAAC;IACpB,+DAA+D;IAC/D,SAAS,CAAC,EAAE,0BAA0B,CAAC;IACvC;;;;;OAKG;IACH,uBAAuB,CAAC,EAAE,CAAC,SAAS,EAAE,OAAO,KAAK,IAAI,CAAC;IACvD,iDAAiD;IACjD,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AAuDF,KAAK,gBAAgB,GAAG,oBAAoB,GAAG;IAC7C;;;;;OAKG;IACH,IAAI,EAAE,OAAO,CAAC;CACf,CAAC;AAEF;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,EAAC,IAAI,EAAE,GAAG,KAAK,EAAC,EAAE,gBAAgB,GAAG,SAAS,CAGzE"}
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
import { useState, useEffect, useLayoutEffect, useRef, useCallback, } from 'react';
|
|
8
|
+
import { prefersReducedMotion } from '../../utils/accessibilityUtils';
|
|
9
|
+
const DefaultAnimationEasing = 'ease-in-out';
|
|
10
|
+
/**
|
|
11
|
+
* This hook is a very thin wrapper around a `useState`.
|
|
12
|
+
*/
|
|
13
|
+
export function useCollapsible({ initialState, }) {
|
|
14
|
+
const [collapsed, setCollapsed] = useState(initialState ?? false);
|
|
15
|
+
const toggleCollapsed = useCallback(() => {
|
|
16
|
+
setCollapsed((expanded) => !expanded);
|
|
17
|
+
}, []);
|
|
18
|
+
return {
|
|
19
|
+
collapsed,
|
|
20
|
+
setCollapsed,
|
|
21
|
+
toggleCollapsed,
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
const CollapsedStyles = {
|
|
25
|
+
display: 'none',
|
|
26
|
+
overflow: 'hidden',
|
|
27
|
+
height: '0px',
|
|
28
|
+
};
|
|
29
|
+
const ExpandedStyles = {
|
|
30
|
+
display: 'block',
|
|
31
|
+
overflow: 'visible',
|
|
32
|
+
height: 'auto',
|
|
33
|
+
};
|
|
34
|
+
function applyCollapsedStyle(el, collapsed) {
|
|
35
|
+
const collapsedStyles = collapsed ? CollapsedStyles : ExpandedStyles;
|
|
36
|
+
el.style.display = collapsedStyles.display;
|
|
37
|
+
el.style.overflow = collapsedStyles.overflow;
|
|
38
|
+
el.style.height = collapsedStyles.height;
|
|
39
|
+
}
|
|
40
|
+
/*
|
|
41
|
+
Lex111: Dynamic transition duration is used in Material design, this technique
|
|
42
|
+
is good for a large number of items.
|
|
43
|
+
https://material.io/archive/guidelines/motion/duration-easing.html#duration-easing-dynamic-durations
|
|
44
|
+
https://github.com/mui-org/material-ui/blob/e724d98eba018e55e1a684236a2037e24bcf050c/packages/material-ui/src/styles/createTransitions.js#L40-L43
|
|
45
|
+
*/
|
|
46
|
+
function getAutoHeightDuration(height) {
|
|
47
|
+
if (prefersReducedMotion()) {
|
|
48
|
+
// Not using 0 because it prevents onTransitionEnd to fire and bubble up :/
|
|
49
|
+
// See https://github.com/facebook/docusaurus/pull/8906
|
|
50
|
+
return 1;
|
|
51
|
+
}
|
|
52
|
+
const constant = height / 36;
|
|
53
|
+
return Math.round((4 + 15 * constant ** 0.25 + constant / 5) * 10);
|
|
54
|
+
}
|
|
55
|
+
function useCollapseAnimation({ collapsibleRef, collapsed, animation, }) {
|
|
56
|
+
const mounted = useRef(false);
|
|
57
|
+
useEffect(() => {
|
|
58
|
+
const el = collapsibleRef.current;
|
|
59
|
+
function getTransitionStyles() {
|
|
60
|
+
const height = el.scrollHeight;
|
|
61
|
+
const duration = animation?.duration ?? getAutoHeightDuration(height);
|
|
62
|
+
const easing = animation?.easing ?? DefaultAnimationEasing;
|
|
63
|
+
return {
|
|
64
|
+
transition: `height ${duration}ms ${easing}`,
|
|
65
|
+
height: `${height}px`,
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
function applyTransitionStyles() {
|
|
69
|
+
const transitionStyles = getTransitionStyles();
|
|
70
|
+
el.style.transition = transitionStyles.transition;
|
|
71
|
+
el.style.height = transitionStyles.height;
|
|
72
|
+
}
|
|
73
|
+
// On mount, we just apply styles, no animated transition
|
|
74
|
+
if (!mounted.current) {
|
|
75
|
+
applyCollapsedStyle(el, collapsed);
|
|
76
|
+
mounted.current = true;
|
|
77
|
+
return undefined;
|
|
78
|
+
}
|
|
79
|
+
el.style.willChange = 'height';
|
|
80
|
+
function startAnimation() {
|
|
81
|
+
const animationFrame = requestAnimationFrame(() => {
|
|
82
|
+
// When collapsing
|
|
83
|
+
if (collapsed) {
|
|
84
|
+
applyTransitionStyles();
|
|
85
|
+
requestAnimationFrame(() => {
|
|
86
|
+
el.style.height = CollapsedStyles.height;
|
|
87
|
+
el.style.overflow = CollapsedStyles.overflow;
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
// When expanding
|
|
91
|
+
else {
|
|
92
|
+
el.style.display = 'block';
|
|
93
|
+
requestAnimationFrame(() => {
|
|
94
|
+
applyTransitionStyles();
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
return () => cancelAnimationFrame(animationFrame);
|
|
99
|
+
}
|
|
100
|
+
return startAnimation();
|
|
101
|
+
}, [collapsibleRef, collapsed, animation]);
|
|
102
|
+
}
|
|
103
|
+
function CollapsibleBase({ as: As = 'div', collapsed, children, animation, onCollapseTransitionEnd, className, }) {
|
|
104
|
+
const collapsibleRef = useRef(null);
|
|
105
|
+
useCollapseAnimation({ collapsibleRef, collapsed, animation });
|
|
106
|
+
return (<As
|
|
107
|
+
// @ts-expect-error: the "too complicated type" is produced from
|
|
108
|
+
// "CollapsibleElementType" being a huge union
|
|
109
|
+
ref={collapsibleRef} // Refs are contravariant, which is not expressible in TS
|
|
110
|
+
onTransitionEnd={(e) => {
|
|
111
|
+
if (e.propertyName !== 'height') {
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
applyCollapsedStyle(collapsibleRef.current, collapsed);
|
|
115
|
+
onCollapseTransitionEnd?.(collapsed);
|
|
116
|
+
}} className={className}>
|
|
117
|
+
{children}
|
|
118
|
+
</As>);
|
|
119
|
+
}
|
|
120
|
+
function CollapsibleLazy({ collapsed, ...props }) {
|
|
121
|
+
const [mounted, setMounted] = useState(!collapsed);
|
|
122
|
+
// Updated in effect so that first expansion transition can work
|
|
123
|
+
const [lazyCollapsed, setLazyCollapsed] = useState(collapsed);
|
|
124
|
+
useLayoutEffect(() => {
|
|
125
|
+
if (!collapsed) {
|
|
126
|
+
setMounted(true);
|
|
127
|
+
}
|
|
128
|
+
}, [collapsed]);
|
|
129
|
+
useLayoutEffect(() => {
|
|
130
|
+
if (mounted) {
|
|
131
|
+
setLazyCollapsed(collapsed);
|
|
132
|
+
}
|
|
133
|
+
}, [mounted, collapsed]);
|
|
134
|
+
return mounted ? (<CollapsibleBase {...props} collapsed={lazyCollapsed}/>) : null;
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* A headless component providing smooth and uniform collapsing behavior. The
|
|
138
|
+
* component will be invisible (zero height) when collapsed. Doesn't provide
|
|
139
|
+
* interactivity by itself: collapse state is toggled through props.
|
|
140
|
+
*/
|
|
141
|
+
export function Collapsible({ lazy, ...props }) {
|
|
142
|
+
const Comp = lazy ? CollapsibleLazy : CollapsibleBase;
|
|
143
|
+
return <Comp {...props}/>;
|
|
144
|
+
}
|
|
145
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/Collapsible/index.tsx"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EACL,QAAQ,EACR,SAAS,EACT,eAAe,EACf,MAAM,EACN,WAAW,GAKZ,MAAM,OAAO,CAAC;AACf,OAAO,EAAC,oBAAoB,EAAC,MAAM,gCAAgC,CAAC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source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
import { type ComponentProps, type ReactElement, type ReactNode } from 'react';
|
|
8
|
+
export type DetailsProps = {
|
|
9
|
+
/**
|
|
10
|
+
* Summary is provided as props, optionally including the wrapping
|
|
11
|
+
* `<summary>` tag
|
|
12
|
+
*/
|
|
13
|
+
summary?: ReactElement | string;
|
|
14
|
+
} & ComponentProps<'details'>;
|
|
15
|
+
/**
|
|
16
|
+
* A mostly un-styled `<details>` element with smooth collapsing. Provides some
|
|
17
|
+
* very lightweight styles, but you should bring your UI.
|
|
18
|
+
*/
|
|
19
|
+
export declare function Details({ summary, children, ...props }: DetailsProps): ReactNode;
|
|
20
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/Details/index.tsx"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAc,EAGZ,KAAK,cAAc,EACnB,KAAK,YAAY,EACjB,KAAK,SAAS,EACf,MAAM,OAAO,CAAC;AAqBf,MAAM,MAAM,YAAY,GAAG;IACzB;;;OAGG;IACH,OAAO,CAAC,EAAE,YAAY,GAAG,MAAM,CAAC;CACjC,GAAG,cAAc,CAAC,SAAS,CAAC,CAAC;AAE9B;;;GAGG;AACH,wBAAgB,OAAO,CAAC,EACtB,OAAO,EACP,QAAQ,EACR,GAAG,KAAK,EACT,EAAE,YAAY,GAAG,SAAS,CA+E1B"}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
import React, { useRef, useState, } from 'react';
|
|
8
|
+
import clsx from 'clsx';
|
|
9
|
+
import useBrokenLinks from '@docusaurus/useBrokenLinks';
|
|
10
|
+
import useIsBrowser from '@docusaurus/useIsBrowser';
|
|
11
|
+
import { useCollapsible, Collapsible } from '../Collapsible';
|
|
12
|
+
import styles from './styles.module.css';
|
|
13
|
+
function isInSummary(node) {
|
|
14
|
+
if (!node) {
|
|
15
|
+
return false;
|
|
16
|
+
}
|
|
17
|
+
return node.tagName === 'SUMMARY' || isInSummary(node.parentElement);
|
|
18
|
+
}
|
|
19
|
+
function hasParent(node, parent) {
|
|
20
|
+
if (!node) {
|
|
21
|
+
return false;
|
|
22
|
+
}
|
|
23
|
+
return node === parent || hasParent(node.parentElement, parent);
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* A mostly un-styled `<details>` element with smooth collapsing. Provides some
|
|
27
|
+
* very lightweight styles, but you should bring your UI.
|
|
28
|
+
*/
|
|
29
|
+
export function Details({ summary, children, ...props }) {
|
|
30
|
+
useBrokenLinks().collectAnchor(props.id);
|
|
31
|
+
const isBrowser = useIsBrowser();
|
|
32
|
+
const detailsRef = useRef(null);
|
|
33
|
+
const { collapsed, setCollapsed } = useCollapsible({
|
|
34
|
+
initialState: !props.open,
|
|
35
|
+
});
|
|
36
|
+
// Use a separate state for the actual details prop, because it must be set
|
|
37
|
+
// only after animation completes, otherwise close animations won't work
|
|
38
|
+
const [open, setOpen] = useState(props.open);
|
|
39
|
+
const summaryElement = React.isValidElement(summary) ? (summary) : (<summary>{summary ?? 'Details'}</summary>);
|
|
40
|
+
return (
|
|
41
|
+
// eslint-disable-next-line jsx-a11y/click-events-have-key-events, jsx-a11y/no-noninteractive-element-interactions
|
|
42
|
+
<details {...props} ref={detailsRef} open={open} data-collapsed={collapsed} className={clsx(styles.details, isBrowser && styles.isBrowser, props.className)} onMouseDown={(e) => {
|
|
43
|
+
const target = e.target;
|
|
44
|
+
// Prevent a double-click to highlight summary text
|
|
45
|
+
if (isInSummary(target) && e.detail > 1) {
|
|
46
|
+
e.preventDefault();
|
|
47
|
+
}
|
|
48
|
+
}} onClick={(e) => {
|
|
49
|
+
e.stopPropagation(); // For isolation of multiple nested details/summary
|
|
50
|
+
const target = e.target;
|
|
51
|
+
const shouldToggle = isInSummary(target) && hasParent(target, detailsRef.current);
|
|
52
|
+
if (!shouldToggle) {
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
e.preventDefault();
|
|
56
|
+
if (collapsed) {
|
|
57
|
+
setCollapsed(false);
|
|
58
|
+
setOpen(true);
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
setCollapsed(true);
|
|
62
|
+
// Don't do this, it breaks close animation!
|
|
63
|
+
// setOpen(false);
|
|
64
|
+
}
|
|
65
|
+
}} onToggle={(e) => {
|
|
66
|
+
// The toggle event also fires when React syncs the open attribute
|
|
67
|
+
// See https://github.com/facebook/docusaurus/pull/12277
|
|
68
|
+
const isOpen = e.currentTarget.open;
|
|
69
|
+
if (isOpen === !collapsed) {
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
setCollapsed(!isOpen);
|
|
73
|
+
setOpen(isOpen);
|
|
74
|
+
}}>
|
|
75
|
+
{summaryElement}
|
|
76
|
+
|
|
77
|
+
<Collapsible lazy={false} // Content might matter for SEO in this case
|
|
78
|
+
collapsed={collapsed} onCollapseTransitionEnd={(newCollapsed) => {
|
|
79
|
+
setCollapsed(newCollapsed);
|
|
80
|
+
setOpen(!newCollapsed);
|
|
81
|
+
}}>
|
|
82
|
+
<div className={styles.collapsibleContent}>{children}</div>
|
|
83
|
+
</Collapsible>
|
|
84
|
+
</details>);
|
|
85
|
+
}
|
|
86
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/Details/index.tsx"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,EACZ,MAAM,EACN,QAAQ,GAIT,MAAM,OAAO,CAAC;AACf,OAAO,IAAI,MAAM,MAAM,CAAC;A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,EAAE,EAAE;YACd,kEAAkE;YAClE,wDAAwD;YACxD,MAAM,MAAM,GAAG,CAAC,CAAC,aAAa,CAAC,IAAI,CAAC;YACpC,IAAI,MAAM,KAAK,CAAC,SAAS,EAAE,CAAC;gBAC1B,OAAO;YACT,CAAC;YACD,YAAY,CAAC,CAAC,MAAM,CAAC,CAAC;YACtB,OAAO,CAAC,MAAM,CAAC,CAAC;QAClB,CAAC,CAAC,CACF;MAAA,CAAC,cAAc,CAEf;;MAAA,CAAC,WAAW,CACV,IAAI,CAAC,CAAC,KAAK,CAAC,CAAC,4CAA4C;KACzD,SAAS,CAAC,CAAC,SAAS,CAAC,CACrB,uBAAuB,CAAC,CAAC,CAAC,YAAY,EAAE,EAAE;YACxC,YAAY,CAAC,YAAY,CAAC,CAAC;YAC3B,OAAO,CAAC,CAAC,YAAY,CAAC,CAAC;QACzB,CAAC,CAAC,CACF;QAAA,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC,MAAM,CAAC,kBAAkB,CAAC,CAAC,CAAC,QAAQ,CAAC,EAAE,GAAG,CAC5D;MAAA,EAAE,WAAW,CACf;IAAA,EAAE,OAAO,CAAC,CACX,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
/*
|
|
9
|
+
CSS variables, meant to be overridden by final theme
|
|
10
|
+
*/
|
|
11
|
+
.details {
|
|
12
|
+
--docusaurus-details-summary-arrow-size: 0.38rem;
|
|
13
|
+
--docusaurus-details-transition: transform 200ms ease;
|
|
14
|
+
--docusaurus-details-decoration-color: grey;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
.details > summary {
|
|
18
|
+
position: relative;
|
|
19
|
+
cursor: pointer;
|
|
20
|
+
list-style: none;
|
|
21
|
+
padding-left: 1rem;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/* TODO: deprecation, need to remove this after Safari will support `::marker` */
|
|
25
|
+
.details > summary::-webkit-details-marker {
|
|
26
|
+
display: none;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
.details > summary::before {
|
|
30
|
+
position: absolute;
|
|
31
|
+
top: 0.45rem;
|
|
32
|
+
left: 0;
|
|
33
|
+
|
|
34
|
+
/* CSS-only Arrow */
|
|
35
|
+
content: '';
|
|
36
|
+
border-width: var(--docusaurus-details-summary-arrow-size);
|
|
37
|
+
border-style: solid;
|
|
38
|
+
border-color: transparent transparent transparent
|
|
39
|
+
var(--docusaurus-details-decoration-color);
|
|
40
|
+
|
|
41
|
+
/* Arrow rotation anim */
|
|
42
|
+
transform: rotate(0deg);
|
|
43
|
+
transition: var(--docusaurus-details-transition);
|
|
44
|
+
transform-origin: calc(var(--docusaurus-details-summary-arrow-size) / 2) 50%;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/* When JS disabled/failed to load: we use the open property for arrow animation: */
|
|
48
|
+
.details[open]:not(.isBrowser) > summary::before,
|
|
49
|
+
/* When JS works: we use the data-attribute for arrow animation */
|
|
50
|
+
.details[data-collapsed='false'].isBrowser > summary::before {
|
|
51
|
+
transform: rotate(90deg);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
.collapsibleContent {
|
|
55
|
+
margin-top: 1rem;
|
|
56
|
+
border-top: 1px solid var(--docusaurus-details-decoration-color);
|
|
57
|
+
padding-top: 1rem;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
.collapsibleContent p:last-child {
|
|
61
|
+
margin-bottom: 0;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
.details > summary > p:last-child {
|
|
65
|
+
margin-bottom: 0;
|
|
66
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
import React, { type ReactNode } from 'react';
|
|
8
|
+
type Theme = 'light' | 'dark';
|
|
9
|
+
type RenderFn = ({ theme, className, }: {
|
|
10
|
+
theme: Theme;
|
|
11
|
+
className: string;
|
|
12
|
+
}) => React.ReactNode;
|
|
13
|
+
type Props = {
|
|
14
|
+
children: RenderFn;
|
|
15
|
+
className?: string;
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* Generic component to render anything themed in light/dark
|
|
19
|
+
* Note: it's preferable to use CSS for theming because this component
|
|
20
|
+
* will need to render all the variants during SSR to avoid a theme flash.
|
|
21
|
+
*
|
|
22
|
+
* Use this only when CSS customizations are not convenient or impossible.
|
|
23
|
+
* For example, rendering themed images or SVGs...
|
|
24
|
+
*
|
|
25
|
+
* @param className applied to all the variants
|
|
26
|
+
* @param children function to render a theme variant
|
|
27
|
+
* @constructor
|
|
28
|
+
*/
|
|
29
|
+
export default function ThemedComponent({ className, children, }: Props): ReactNode;
|
|
30
|
+
export {};
|
|
31
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/ThemedComponent/index.tsx"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,EAAC,KAAK,SAAS,EAAC,MAAM,OAAO,CAAC;AAO5C,KAAK,KAAK,GAAG,OAAO,GAAG,MAAM,CAAC;AAE9B,KAAK,QAAQ,GAAG,CAAC,EACf,KAAK,EACL,SAAS,GACV,EAAE;IACD,KAAK,EAAE,KAAK,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;CACnB,KAAK,KAAK,CAAC,SAAS,CAAC;AAEtB,KAAK,KAAK,GAAG;IACX,QAAQ,EAAE,QAAQ,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,OAAO,UAAU,eAAe,CAAC,EACtC,SAAS,EACT,QAAQ,GACT,EAAE,KAAK,GAAG,SAAS,CA8BnB"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
import React from 'react';
|
|
8
|
+
import clsx from 'clsx';
|
|
9
|
+
import useIsBrowser from '@docusaurus/useIsBrowser';
|
|
10
|
+
import { useColorMode } from '../../contexts/colorMode';
|
|
11
|
+
import styles from './styles.module.css';
|
|
12
|
+
/**
|
|
13
|
+
* Generic component to render anything themed in light/dark
|
|
14
|
+
* Note: it's preferable to use CSS for theming because this component
|
|
15
|
+
* will need to render all the variants during SSR to avoid a theme flash.
|
|
16
|
+
*
|
|
17
|
+
* Use this only when CSS customizations are not convenient or impossible.
|
|
18
|
+
* For example, rendering themed images or SVGs...
|
|
19
|
+
*
|
|
20
|
+
* @param className applied to all the variants
|
|
21
|
+
* @param children function to render a theme variant
|
|
22
|
+
* @constructor
|
|
23
|
+
*/
|
|
24
|
+
export default function ThemedComponent({ className, children, }) {
|
|
25
|
+
const isBrowser = useIsBrowser();
|
|
26
|
+
const { colorMode } = useColorMode();
|
|
27
|
+
function getThemesToRender() {
|
|
28
|
+
if (isBrowser) {
|
|
29
|
+
return colorMode === 'dark' ? ['dark'] : ['light'];
|
|
30
|
+
}
|
|
31
|
+
// We need to render both components on the server / hydration to avoid:
|
|
32
|
+
// - a flash of wrong theme before hydration
|
|
33
|
+
// - React hydration mismatches
|
|
34
|
+
// See https://github.com/facebook/docusaurus/pull/3730
|
|
35
|
+
return ['light', 'dark'];
|
|
36
|
+
}
|
|
37
|
+
return (<>
|
|
38
|
+
{getThemesToRender().map((theme) => {
|
|
39
|
+
const themedElement = children({
|
|
40
|
+
theme,
|
|
41
|
+
className: clsx(className, styles.themedComponent, styles[`themedComponent--${theme}`]),
|
|
42
|
+
});
|
|
43
|
+
return <React.Fragment key={theme}>{themedElement}</React.Fragment>;
|
|
44
|
+
})}
|
|
45
|
+
</>);
|
|
46
|
+
}
|
|
47
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/ThemedComponent/index.tsx"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAuB,MAAM,OAAO,CAAC;AAC5C,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,YAAY,MAAM,0BAA0B,CAAC;AACpD,OAAO,EAAC,YAAY,EAAC,MAAM,0BAA0B,CAAC;AAEtD,OAAO,MAAM,MAAM,qBAAqB,CAAC;AAiBzC;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,OAAO,UAAU,eAAe,CAAC,EACtC,SAAS,EACT,QAAQ,GACF;IACN,MAAM,SAAS,GAAG,YAAY,EAAE,CAAC;IACjC,MAAM,EAAC,SAAS,EAAC,GAAG,YAAY,EAAE,CAAC;IAEnC,SAAS,iBAAiB;QACxB,IAAI,SAAS,EAAE,CAAC;YACd,OAAO,SAAS,KAAK,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC;QACrD,CAAC;QACD,wEAAwE;QACxE,4CAA4C;QAC5C,+BAA+B;QAC/B,uDAAuD;QACvD,OAAO,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;IAC3B,CAAC;IAED,OAAO,CACL,EACE;MAAA,CAAC,iBAAiB,EAAE,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE;YACjC,MAAM,aAAa,GAAG,QAAQ,CAAC;gBAC7B,KAAK;gBACL,SAAS,EAAE,IAAI,CACb,SAAS,EACT,MAAM,CAAC,eAAe,EACtB,MAAM,CAAC,oBAAoB,KAAK,EAAE,CAAC,CACpC;aACF,CAAC,CAAC;YACH,OAAO,CAAC,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,aAAa,CAAC,EAAE,KAAK,CAAC,QAAQ,CAAC,CAAC;QACtE,CAAC,CAAC,CACJ;IAAA,GAAG,CACJ,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
.themedComponent {
|
|
9
|
+
display: none;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
[data-theme='light'] .themedComponent--light {
|
|
13
|
+
display: initial;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
[data-theme='dark'] .themedComponent--dark {
|
|
17
|
+
display: initial;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/*
|
|
21
|
+
JS disabled??? Show light version by default => better than showing nothing
|
|
22
|
+
TODO bad, but we currently always show light mode when there's no data-theme
|
|
23
|
+
*/
|
|
24
|
+
html:not([data-theme]) .themedComponent--light {
|
|
25
|
+
display: initial;
|
|
26
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
import { type ReactNode } from 'react';
|
|
8
|
+
type ContextValue = {
|
|
9
|
+
/** Whether the announcement bar should be displayed. */
|
|
10
|
+
readonly isActive: boolean;
|
|
11
|
+
/**
|
|
12
|
+
* Callback fired when the user closes the announcement. Will be saved.
|
|
13
|
+
*/
|
|
14
|
+
readonly close: () => void;
|
|
15
|
+
};
|
|
16
|
+
export declare function AnnouncementBarProvider({ children, }: {
|
|
17
|
+
children: ReactNode;
|
|
18
|
+
}): ReactNode;
|
|
19
|
+
export declare function useAnnouncementBar(): ContextValue;
|
|
20
|
+
export {};
|
|
21
|
+
//# sourceMappingURL=announcementBar.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"announcementBar.d.ts","sourceRoot":"","sources":["../../src/contexts/announcementBar.tsx"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAc,EAMZ,KAAK,SAAS,EACf,MAAM,OAAO,CAAC;AAkBf,KAAK,YAAY,GAAG;IAClB,wDAAwD;IACxD,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;IAC3B;;OAEG;IACH,QAAQ,CAAC,KAAK,EAAE,MAAM,IAAI,CAAC;CAC5B,CAAC;AA8DF,wBAAgB,uBAAuB,CAAC,EACtC,QAAQ,GACT,EAAE;IACD,QAAQ,EAAE,SAAS,CAAC;CACrB,GAAG,SAAS,CAGZ;AAED,wBAAgB,kBAAkB,IAAI,YAAY,CAMjD"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
import React, { useState, useEffect, useCallback, useMemo, useContext, } from 'react';
|
|
8
|
+
import useIsBrowser from '@docusaurus/useIsBrowser';
|
|
9
|
+
import { createStorageSlot } from '../utils/storageUtils';
|
|
10
|
+
import { ReactContextError } from '../utils/reactUtils';
|
|
11
|
+
import { useThemeConfig } from '../utils/useThemeConfig';
|
|
12
|
+
// Keep these keys in sync with the inlined script
|
|
13
|
+
// See packages/docusaurus-theme-classic/src/inlineScripts.ts
|
|
14
|
+
const AnnouncementBarDismissStorage = createStorageSlot('docusaurus.announcement.dismiss');
|
|
15
|
+
const IdStorage = createStorageSlot('docusaurus.announcement.id');
|
|
16
|
+
const isDismissedInStorage = () => AnnouncementBarDismissStorage.get() === 'true';
|
|
17
|
+
const setDismissedInStorage = (bool) => AnnouncementBarDismissStorage.set(String(bool));
|
|
18
|
+
const Context = React.createContext(null);
|
|
19
|
+
function useContextValue() {
|
|
20
|
+
const { announcementBar } = useThemeConfig();
|
|
21
|
+
const isBrowser = useIsBrowser();
|
|
22
|
+
const [isClosed, setClosed] = useState(() => isBrowser
|
|
23
|
+
? // On client navigation: init with local storage value
|
|
24
|
+
isDismissedInStorage()
|
|
25
|
+
: // On server/hydration: always visible to prevent layout shifts (will be hidden with css if needed)
|
|
26
|
+
false);
|
|
27
|
+
// Update state after hydration
|
|
28
|
+
useEffect(() => {
|
|
29
|
+
setClosed(isDismissedInStorage());
|
|
30
|
+
}, []);
|
|
31
|
+
const handleClose = useCallback(() => {
|
|
32
|
+
setDismissedInStorage(true);
|
|
33
|
+
setClosed(true);
|
|
34
|
+
}, []);
|
|
35
|
+
useEffect(() => {
|
|
36
|
+
if (!announcementBar) {
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
const { id } = announcementBar;
|
|
40
|
+
let viewedId = IdStorage.get();
|
|
41
|
+
// Retrocompatibility due to spelling mistake of default id
|
|
42
|
+
// see https://github.com/facebook/docusaurus/issues/3338
|
|
43
|
+
// cSpell:ignore annoucement
|
|
44
|
+
if (viewedId === 'annoucement-bar') {
|
|
45
|
+
viewedId = 'announcement-bar';
|
|
46
|
+
}
|
|
47
|
+
const isNewAnnouncement = id !== viewedId;
|
|
48
|
+
IdStorage.set(id);
|
|
49
|
+
if (isNewAnnouncement) {
|
|
50
|
+
setDismissedInStorage(false);
|
|
51
|
+
}
|
|
52
|
+
if (isNewAnnouncement || !isDismissedInStorage()) {
|
|
53
|
+
setClosed(false);
|
|
54
|
+
}
|
|
55
|
+
}, [announcementBar]);
|
|
56
|
+
return useMemo(() => ({
|
|
57
|
+
isActive: !!announcementBar && !isClosed,
|
|
58
|
+
close: handleClose,
|
|
59
|
+
}), [announcementBar, isClosed, handleClose]);
|
|
60
|
+
}
|
|
61
|
+
export function AnnouncementBarProvider({ children, }) {
|
|
62
|
+
const value = useContextValue();
|
|
63
|
+
return <Context value={value}>{children}</Context>;
|
|
64
|
+
}
|
|
65
|
+
export function useAnnouncementBar() {
|
|
66
|
+
const api = useContext(Context);
|
|
67
|
+
if (!api) {
|
|
68
|
+
throw new ReactContextError('AnnouncementBarProvider');
|
|
69
|
+
}
|
|
70
|
+
return api;
|
|
71
|
+
}
|
|
72
|
+
//# sourceMappingURL=announcementBar.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"announcementBar.js","sourceRoot":"","sources":["../../src/contexts/announcementBar.tsx"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,EACZ,QAAQ,EACR,SAAS,EACT,WAAW,EACX,OAAO,EACP,UAAU,GAEX,MAAM,OAAO,CAAC;AACf,OAAO,YAAY,MAAM,0BAA0B,CAAC;AACpD,OAAO,EAAC,iBAAiB,EAAC,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAC,iBAAiB,EAAC,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAC,cAAc,EAAC,MAAM,yBAAyB,CAAC;AAEvD,kDAAkD;AAClD,6DAA6D;AAC7D,MAAM,6BAA6B,GAAG,iBAAiB,CACrD,iCAAiC,CAClC,CAAC;AACF,MAAM,SAAS,GAAG,iBAAiB,CAAC,4BAA4B,CAAC,CAAC;AAElE,MAAM,oBAAoB,GAAG,GAAG,EAAE,CAChC,6BAA6B,CAAC,GAAG,EAAE,KAAK,MAAM,CAAC;AACjD,MAAM,qBAAqB,GAAG,CAAC,IAAa,EAAE,EAAE,CAC9C,6BAA6B,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,CAA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,CAAC;YACjD,SAAS,CAAC,KAAK,CAAC,CAAC;QACnB,CAAC;IACH,CAAC,EAAE,CAAC,eAAe,CAAC,CAAC,CAAC;IAEtB,OAAO,OAAO,CACZ,GAAG,EAAE,CAAC,CAAC;QACL,QAAQ,EAAE,CAAC,CAAC,eAAe,IAAI,CAAC,QAAQ;QACxC,KAAK,EAAE,WAAW;KACnB,CAAC,EACF,CAAC,eAAe,EAAE,QAAQ,EAAE,WAAW,CAAC,CACzC,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,uBAAuB,CAAC,EACtC,QAAQ,GAGT;IACC,MAAM,KAAK,GAAG,eAAe,EAAE,CAAC;IAChC,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAC,CAAC;AACrD,CAAC;AAED,MAAM,UAAU,kBAAkB;IAChC,MAAM,GAAG,GAAG,UAAU,CAAC,OAAO,CAAC,CAAC;IAChC,IAAI,CAAC,GAAG,EAAE,CAAC;QACT,MAAM,IAAI,iBAAiB,CAAC,yBAAyB,CAAC,CAAC;IACzD,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
import { type ReactNode } from 'react';
|
|
8
|
+
export type ColorMode = 'light' | 'dark';
|
|
9
|
+
type ColorModeChoice = ColorMode | null;
|
|
10
|
+
type ContextValue = {
|
|
11
|
+
/** The effective color mode. */
|
|
12
|
+
readonly colorMode: ColorMode;
|
|
13
|
+
/** The explicitly chosen color mode */
|
|
14
|
+
readonly colorModeChoice: ColorModeChoice;
|
|
15
|
+
/** Set new color mode. */
|
|
16
|
+
readonly setColorMode: (colorMode: ColorModeChoice) => void;
|
|
17
|
+
};
|
|
18
|
+
export declare function ColorModeProvider({ children, }: {
|
|
19
|
+
children: ReactNode;
|
|
20
|
+
}): ReactNode;
|
|
21
|
+
export declare function useColorMode(): ContextValue;
|
|
22
|
+
export {};
|
|
23
|
+
//# sourceMappingURL=colorMode.d.ts.map
|