-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathwidget.jsx
More file actions
38 lines (35 loc) · 1.16 KB
/
Copy pathwidget.jsx
File metadata and controls
38 lines (35 loc) · 1.16 KB
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
// JSX equivalent of layout-widget. Renders a single area with grid CSS
// custom properties driven by the widget's options.
export default function (data, { Area }) {
const opts = data.options || {};
const managerOpts = (data.manager && data.manager.options) || {};
const columns = opts.columns || managerOpts.columns;
const gap = opts.gap || managerOpts.gap || '0';
const justify = opts.defaultCellHorizontalAlignment ||
managerOpts.defaultCellHorizontalAlignment || 'stretch';
const align = opts.defaultCellVerticalAlignment ||
managerOpts.defaultCellVerticalAlignment || 'stretch';
const aposStyle =
`--grid-columns: ${columns};` +
` --grid-gap: ${gap};` +
' --grid-rows: auto;' +
' --mobile-grid-rows: auto;' +
' --tablet-grid-rows: auto;' +
` --justify-items: ${justify};` +
` --align-items: ${align};`;
return (
<Area
doc={data.widget}
name="columns"
with={{
aposStyle,
aposClassName: 'layout-widget widget',
aposParentOptions: { ...opts, widgetId: data.widget._id },
aposAttrs: {
'tablet-auto': true,
'mobile-auto': true
}
}}
/>
);
}