You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Here `T` is a `ViewId` that can be used to look elements up in `ELEMENT_MAP`.
96
-
This allows for easier view state specification and serialization.
97
-
The resulting view looks and functions identically to the previous example.
65
+
`renderTile` is a stateless lookup function to convert `T` into a displayable `JSX.Element`.
66
+
By default `T` is `string`.
67
+
`initialValue` is a [`MosaicNode<T>`](./src/types.ts#L27).
68
+
69
+
The user can resize these panes but there is no other advanced functionality.
70
+
This example renders a simple tiled interface with one element on the left half, and two stacked elements on the right half.
71
+
The user can resize these panes but there is no other advanced functionality.
98
72
99
73
#### Drag, Drop, and other advanced functionality with `MosaicWindow`
100
74
`MosaicWindow` is a component that renders a toolbar and controls around its children for a tile as well as providing full featured drag and drop functionality.
101
75
102
76
```tsx
103
-
exporttypeViewId=string;
77
+
exporttypeViewId='a'|'b'|'c'|'new';
104
78
105
79
// Make a simple extension class to preserve generic type checking in TSX
Here `T` is a `ViewId` that can be used to look elements up in `TITLE_MAP`.
114
+
This allows for easy view state specification and serialization.
138
115
This will render a view that looks very similar to the previous examples, but now each of the windows will have a toolbar with buttons.
139
116
These toolbars can be dragged around by a user to rearrange their workspace.
140
-
`MosaicWindow` API docs [here](#MosaicWindow).
117
+
118
+
`MosaicWindow` API docs [here](#mosaicwindow).
141
119
142
120
#### Controlled vs. Uncontrolled
143
121
Mosaic views have two modes, similar to `React.DOM` input elements:
@@ -151,7 +129,8 @@ All of the previous examples show use of Mosaic in an Uncontrolled fashion.
151
129
152
130
#### TS/JS vs. TSX/JSX
153
131
Components export both factories and component classes.
154
-
If you are using TS/JS then use the factories; if you are using TSX/JSX then use the exported class but know that you will lose the generics if you aren't careful.
132
+
If you are using TS/JS then use the factories;
133
+
if you are using TSX/JSX then use the exported class but know that you will lose the generics if you aren't careful.
155
134
The exported classes are named as the base name of the component (e.g. `MosaicWindow`) while the exported factories
156
135
have 'Factory' appended (e.g. `MosaicWindowFactory`).
157
136
@@ -163,9 +142,9 @@ for a more interesting example that shows the usage of Mosaic as a controlled co
The default controls rendered by `MosaicWindow` can be accessed from [`defaultToolbarControls`](src/buttons/MosaicButton.tsx)
227
+
The default controls rendered by `MosaicWindow` can be accessed from [`defaultToolbarControls`](./src/buttons/defaultToolbarControls.tsx)
242
228
243
229
### Advanced API
244
230
The above API is good for most consumers, however Mosaic provides functionality on the [Context](https://facebook.github.io/react/docs/context.html) of its children that make it easier to alter the view state.
245
231
All leaves rendered by Mosaic will have the following available on React context.
246
232
These are used extensively by `MosaicWindow`.
247
233
248
234
```typescript
235
+
/**
236
+
* Valid node types
237
+
* @seeReact.Key
238
+
*/
239
+
exporttypeMosaicKey=string|number;
249
240
exporttypeMosaicBranch='first'|'second';
250
241
exporttypeMosaicPath=MosaicBranch[];
251
242
252
-
exportinterfaceMosaicTileContext<T> {
253
-
/**
254
-
* These actions are used to alter the state of the view tree
0 commit comments