Update lib, show example of router

This commit is contained in:
Jonas Dellinger 2022-05-30 22:23:13 +02:00
commit d8870f2062
3 changed files with 59 additions and 19 deletions

View file

@ -1,10 +1,12 @@
import {
ButtonItem,
definePlugin,
DialogButton,
Menu,
MenuItem,
PanelSection,
PanelSectionRow,
Router,
ServerAPI,
showModal,
staticClasses,
@ -60,14 +62,44 @@ const Content: VFC<{ serverAPI: ServerAPI }> = ({}) => {
<img src={logo} />
</div>
</PanelSectionRow>
<PanelSectionRow>
<ButtonItem
layout="below"
onClick={() => {
Router.CloseSideMenus();
Router.Navigate("/decky-plugin-test");
}}
>
Router
</ButtonItem>
</PanelSectionRow>
</PanelSection>
);
};
const DeckyPluginRouterTest: VFC = () => {
return (
<div style={{ marginTop: "50px", color: "white" }}>
Hello World!
<DialogButton onClick={() => Router.NavigateToStore()}>
Go to Store
</DialogButton>
</div>
);
};
export default definePlugin((serverApi: ServerAPI) => {
serverApi.routerHook.addRoute("/decky-plugin-test", DeckyPluginRouterTest, {
exact: true,
});
return {
title: <div className={staticClasses.Title}>Example Plugin</div>,
content: <Content serverAPI={serverApi} />,
icon: <FaShip />,
onDismount() {
serverApi.routerHook.removeRoute("/decky-plugin-test");
},
};
});