From 40bb65e27919a87a9834d55b3e7b94e0990c7a42 Mon Sep 17 00:00:00 2001 From: nmd Date: Sun, 13 Jun 2021 12:48:24 +0100 Subject: [PATCH] - --- examples/demo/App.tsx | 5 +++-- src/view/Layout.tsx | 39 ++++++++++++++++++++++----------------- 2 files changed, 25 insertions(+), 19 deletions(-) diff --git a/examples/demo/App.tsx b/examples/demo/App.tsx index e53eaf6a..da80eed0 100755 --- a/examples/demo/App.tsx +++ b/examples/demo/App.tsx @@ -3,6 +3,7 @@ import * as ReactDOM from "react-dom"; import * as FlexLayout from "../../src/index"; import Utils from "./Utils"; import { Node, TabSetNode, TabNode, DropInfo, BorderNode, Action } from "../../src/index"; +import { ITabRenderValues, ITabSetRenderValues } from "../../src/view/Layout"; var fields = ["Name", "Field1", "Field2", "Field3", "Field4", "Field5"]; @@ -281,13 +282,13 @@ class App extends React.Component { + onRenderTab = (node: TabNode, renderValues: ITabRenderValues) => { // renderValues.content += " *"; // renderValues.name = "tab " + node.getId(); // name used in overflow menu // renderValues.buttons.push(); } - onRenderTabSet = (node: (TabSetNode | BorderNode), renderValues: any) => { + onRenderTabSet = (node: (TabSetNode | BorderNode), renderValues: ITabSetRenderValues) => { if (this.state.layoutFile === "default") { //renderValues.headerContent = "-- " + renderValues.headerContent + " --"; //renderValues.buttons.push(); diff --git a/src/view/Layout.tsx b/src/view/Layout.tsx index 1cf8965b..0ecdffd7 100755 --- a/src/view/Layout.tsx +++ b/src/view/Layout.tsx @@ -27,12 +27,7 @@ import { IJsonTabNode } from "../model/IJsonModel"; export interface ILayoutProps { model: Model; factory: (node: TabNode) => React.ReactNode; - font?: { - size?: string; - family?: string; - style?: string; - weight?: string; - }; + font?: IFontValues; fontFamily?: string; iconFactory?: (node: TabNode) => React.ReactNode | undefined; titleFactory?: (node: TabNode) => ITitleObject | React.ReactNode | undefined; @@ -41,20 +36,11 @@ export interface ILayoutProps { onAction?: (action: Action) => Action | undefined; onRenderTab?: ( node: TabNode, - renderValues: { - leading: React.ReactNode; - content: React.ReactNode; - name: string; - buttons: React.ReactNode[]; - } + renderValues: ITabRenderValues, ) => void; onRenderTabSet?: ( tabSetNode: TabSetNode | BorderNode, - renderValues: { - headerContent?: React.ReactNode; - stickyButtons: React.ReactNode[]; - buttons: React.ReactNode[]; - } + renderValues: ITabSetRenderValues, ) => void; onModelChange?: (model: Model) => void; onExternalDrag?: (event: React.DragEvent) => undefined | { @@ -67,6 +53,25 @@ export interface ILayoutProps { supportsPopout?: boolean | undefined; popoutURL?: string | undefined; } +export interface IFontValues { + size?: string; + family?: string; + style?: string; + weight?: string; +} + +export interface ITabSetRenderValues { + headerContent?: React.ReactNode; + stickyButtons: React.ReactNode[]; + buttons: React.ReactNode[]; +} + +export interface ITabRenderValues { + leading: React.ReactNode; + content: React.ReactNode; + name: string; + buttons: React.ReactNode[]; +} export interface ITitleObject { titleContent: React.ReactNode;