nope/pages/test/test-dynamic-layout.tsx

112 lines
2.3 KiB
TypeScript
Raw Normal View History

2020-12-30 18:59:44 +00:00
import { faHatWizard } from "@fortawesome/free-solid-svg-icons";
import * as React from "react";
import DynLayout, {
IDynamicLayoutProps
} from "../../resources/ui/layout/dynamicLayout";
import TabEntry from "../../resources/ui/layout/tabs";
2020-10-30 18:30:59 +00:00
2020-12-30 18:59:44 +00:00
export interface DynLayoutProps {}
2020-10-30 18:30:59 +00:00
2020-12-30 18:59:44 +00:00
export interface DynLayoutState {}
2020-10-30 18:30:59 +00:00
2020-12-30 18:59:44 +00:00
class TestDynLayoutComponent extends React.Component<
DynLayoutProps,
DynLayoutState
> {
componentDidMount() {
this.setState({
layoutSettings: {
width: process.browser ? window.innerWidth : 1920,
autoSize: false
}
});
2020-10-30 18:30:59 +00:00
2020-12-30 18:59:44 +00:00
console.log("here", process.browser ? window.innerWidth : 1920);
}
2020-10-30 18:30:59 +00:00
2020-12-30 18:59:44 +00:00
constructor(props) {
super(props);
}
2020-10-30 18:30:59 +00:00
2020-12-30 18:59:44 +00:00
render() {
const settings: IDynamicLayoutProps<any> = {
components: [
{
visible: true,
component() {
return <># Test Widget 1 </>;
},
gridSettings: {
h: 5,
w: 5,
x: 0,
y: 0,
minW: 3,
maxH: 5,
minH: 5,
maxW: 5
},
id: "test",
label: "Test Widget 1",
props: {},
hideable: true
},
{
visible: true,
component() {
return (
<TabEntry
tabs={{
active: "-1",
allowNewTabs: true,
items: []
}}
></TabEntry>
);
},
gridSettings: {
h: 5,
w: 10,
x: 5,
y: 0,
minW: 5,
maxH: 5,
minH: 5
},
id: "test2",
label: "# Test Widget 2",
props: {},
hideable: false,
bg: "light"
2020-10-30 18:30:59 +00:00
}
2020-12-30 18:59:44 +00:00
],
layoutSettings: {
width: process.browser ? window.innerWidth : 1920,
autoSize: false,
preventCollision: false,
cols: 15,
compactType: "horizontal"
},
toolbar: {
items: [
{
type: "link",
label: "docs",
ref: "/docs",
icon: faHatWizard
}
]
},
generateData() {
return {
content: "hello"
};
}
};
2020-10-30 18:30:59 +00:00
2020-12-30 18:59:44 +00:00
return React.createElement(DynLayout, settings);
}
2020-10-30 18:30:59 +00:00
}
2020-12-30 18:59:44 +00:00
export default TestDynLayoutComponent;