/
index.tsx
123 lines (115 loc) · 4.52 KB
/
index.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
import "@babel/polyfill";
import React from "react";
import ReactDOM from "react-dom";
import { ComponentStyles, JSSManager } from "@microsoft/fast-jss-manager-react";
import { Canvas } from "../src/canvas";
import { Container } from "../src/container";
import { Row, RowResizeDirection } from "../src/row";
import { Pane, PaneResizeDirection } from "../src/pane";
import { Page } from "../src/page";
import { Grid } from "../src/grid";
import { Column, ColumnClassNamesContract } from "../src/column";
import { create } from "jss";
import jssNested from "jss-plugin-nested";
const jssInstance: ReturnType<create> = create();
jssInstance.use(jssNested());
JSSManager.jss = jssInstance;
const columnTestStyles: ComponentStyles<ColumnClassNamesContract, undefined> = {
column: {
"background-color": "rgba(0, 120, 212, 0.2)",
border: "2px solid rgba(0, 120, 212, 0.2)",
"min-height": "30px",
margin: "4px 0",
},
};
/**
* Create the root node
*/
const root: HTMLElement = document.createElement("div");
root.setAttribute("id", "root");
document.body.appendChild(root);
function renderIfEnabled(
isEnabled: boolean,
renderFunction: () => JSX.Element
): JSX.Element {
return isEnabled ? renderFunction() : null;
}
function render(): void {
const renderColumnA: boolean = true;
const renderColumnB: boolean = false;
ReactDOM.render(
<React.Fragment>
<Container>
<Row
resizable={true}
resizeFrom={RowResizeDirection.south}
minHeight={50}
style={{ background: "#CCC" }}
/>
<Row fill={true}>
<Pane
resizable={true}
resizeFrom={PaneResizeDirection.east}
style={{ background: "#E6E6E6" }}
/>
<Canvas>
<Page>
<Grid
key={"breakpoint-specific-spans"}
row={1}
gridColumn={2}
>
<Column jssStyleSheet={columnTestStyles} span={12} />
<Column
jssStyleSheet={columnTestStyles}
span={[12, 6, 6, 4]}
row={2}
/>
<Column
jssStyleSheet={columnTestStyles}
span={[12, 6, 6, 4]}
row={[3, 2]}
position={[1, 7, 7, 5]}
/>
<Column
jssStyleSheet={columnTestStyles}
span={[12, 12, 12, 4]}
row={[4, 3, 3, 2]}
position={[1, 1, 1, 9]}
/>
{renderColumnA && (
<Column
jssStyleSheet={columnTestStyles}
span={[12, 6, 6, 4]}
row={3}
>
A
</Column>
)}
{renderIfEnabled(renderColumnB, () => (
<Column
jssStyleSheet={columnTestStyles}
span={[12, 12, 12, 4]}
row={[4, 3, 3, 2]}
position={[1, 1, 1, 9]}
>
B
</Column>
))}
</Grid>
</Page>
</Canvas>
<Pane collapsed={true} style={{ background: "#E1E1E1" }} />
</Row>
<Row
resizable={true}
resizeFrom={RowResizeDirection.north}
minHeight={50}
style={{ background: "#CCC" }}
/>
</Container>
</React.Fragment>,
root
);
}
render();