Skip to content

Commit

Permalink
Test
Browse files Browse the repository at this point in the history
  • Loading branch information
fgalz committed Aug 27, 2024
1 parent 7ab4b60 commit 82314d2
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 8 deletions.
6 changes: 6 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"@mdx-js/react": "^3.0.1",
"clsx": "^2.1.1",
"docusaurus-lunr-search": "^3.3.2",
"medium-zoom": "^1.1.0",
"prism-react-renderer": "^2.3.0",
"react": "^18.3.1",
"react-copy-to-clipboard": "^5.1.0",
Expand Down
40 changes: 32 additions & 8 deletions src/theme/Root.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,34 @@
import React from 'react';
import React, { useEffect } from 'react';
import mediumZoom from 'medium-zoom';
import { useLocation } from '@docusaurus/router';
import { VoucherProvider } from '../utilities/contexts/VoucherContext';

export default function Root({children}) {
return (
<VoucherProvider>
{ children }
</VoucherProvider>
);
}
export default function Root({ children }) {
const location = useLocation();

useEffect(() => {
const applyMediumZoom = () => {
mediumZoom('img');
};

const intervalId = setInterval(() => {
if (document.readyState === 'complete') {
applyMediumZoom();
clearInterval(intervalId);
}
}, 100);

window.addEventListener('docusaurus.onRouteDidUpdate', applyMediumZoom);

return () => {
clearInterval(intervalId);
window.removeEventListener('docusaurus.onRouteDidUpdate', applyMediumZoom);
};
}, [location.pathname]);

return (
<VoucherProvider>
{children}
</VoucherProvider>
);
}

0 comments on commit 82314d2

Please sign in to comment.