mirror of
https://github.com/jellyfin/jellyfin-web
synced 2025-03-30 19:56:21 +00:00
Add react-router
This commit is contained in:
parent
6534c0a596
commit
b2372a96e2
16 changed files with 176 additions and 59 deletions
50
src/components/Page.tsx
Normal file
50
src/components/Page.tsx
Normal file
|
@ -0,0 +1,50 @@
|
|||
import React, { FunctionComponent, useEffect, useRef } from 'react';
|
||||
|
||||
import viewManager from './viewManager/viewManager';
|
||||
|
||||
type PageProps = {
|
||||
title?: string
|
||||
};
|
||||
|
||||
/**
|
||||
* Page component that handles hiding active non-react views, triggering the required events for
|
||||
* navigation and appRouter state updates, and setting the correct classes and data attributes.
|
||||
*/
|
||||
const Page: FunctionComponent<PageProps> = ({ children, title }) => {
|
||||
const element = useRef<HTMLDivElement>(null);
|
||||
|
||||
useEffect(() => {
|
||||
// hide active non-react views
|
||||
viewManager.hideView();
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
const event = {
|
||||
bubbles: true,
|
||||
cancelable: false,
|
||||
detail: {
|
||||
isRestored: false
|
||||
}
|
||||
};
|
||||
// pagebeforeshow - hides tabs on tabless pages in libraryMenu
|
||||
element.current?.dispatchEvent(new CustomEvent('pagebeforeshow', event));
|
||||
// viewshow - updates state of appRouter
|
||||
element.current?.dispatchEvent(new CustomEvent('viewshow', event));
|
||||
// pageshow - updates header/navigation in libraryMenu
|
||||
element.current?.dispatchEvent(new CustomEvent('pageshow', event));
|
||||
}, [ element ]);
|
||||
|
||||
return (
|
||||
<div
|
||||
ref={element}
|
||||
data-role='page'
|
||||
className='mainAnimatedPage page libraryPage allLibraryPage noSecondaryNavPage'
|
||||
data-title={title}
|
||||
data-backbutton='true'
|
||||
>
|
||||
{children}
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default Page;
|
Loading…
Add table
Add a link
Reference in a new issue