Browse Source

Pages base.

master
Mattia Belletti 3 months ago
parent
commit
ec2a014ead
3 changed files with 25 additions and 2 deletions
  1. +3
    -1
      src/plugins/board/index.tsx
  2. +12
    -0
      src/plugins/board/pages.ts
  3. +10
    -1
      src/plugins/board/public-interface.ts

+ 3
- 1
src/plugins/board/index.tsx View File

@@ -3,9 +3,10 @@ const { Tabs, Tab } = MaterialUI;
import { addTab } from "./handle-tabs";
import BoardPublicInterface from "./public-interface";
import useTabs from "./use-tabs";
import SplitPane from "./split-pane";
import { registerPage } from "./pages";

import styles from "./board.module.css";
import SplitPane from "./split-pane";

const Board = () => {
const {
@@ -47,6 +48,7 @@ getCaps("mountComponent")
mountComponent(Board);
registerPublicInterface({
addTab,
registerPage,
} as BoardPublicInterface);
})
.catch((err) => debug("Error!", err));

+ 12
- 0
src/plugins/board/pages.ts View File

@@ -0,0 +1,12 @@
import { JSXElementConstructor } from "react";

const factories: {
[name: string]: () => JSXElementConstructor<Record<string, never>>;
} = {};

export const registerPage = (
name: string,
componentFactory: () => JSXElementConstructor<Record<string, never>>
) => {
factories[name] = componentFactory;
};

+ 10
- 1
src/plugins/board/public-interface.ts View File

@@ -1,3 +1,12 @@
import { JSXElementConstructor } from "react";

export default interface BoardPublicInterface {
addTab: (name: string, Component: React.JSXElementConstructor<{}>) => void;
addTab(
name: string,
Component: React.JSXElementConstructor<Record<string, never>>
): void;
registerPage(
name: string,
componentFactory: () => JSXElementConstructor<Record<string, never>>
): void;
}

Loading…
Cancel
Save