-
Notifications
You must be signed in to change notification settings - Fork 199
/
Copy pathtemplate.js
65 lines (62 loc) · 1.64 KB
/
template.js
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
import { html } from "lit";
import { classMap } from "lit/directives/class-map.js";
import { when } from "lit/directives/when.js";
import "../index.css";
export const Template = ({
rootClass = "spectrum-SplitView",
customClasses = [],
orientation = "horizontal",
isResizable = false,
isFocused = false,
isCollapsible = false,
collapsePosition,
panelLabels = [],
panelStyles = [],
componentHeight = "200px",
}) => {
const collapsible = isCollapsible;
const collapsibleStart =
(typeof collapsePosition !== "undefined" && collapsePosition === "left") ||
collapsePosition === "top";
const collapsibleEnd =
(typeof collapsePosition !== "undefined" && collapsePosition === "right") ||
collapsePosition === "bottom";
const collapsibleClassName =
collapsible && collapsibleStart
? "start"
: collapsible && collapsibleEnd
? "end"
: "";
return html`
<div
style="height: ${componentHeight};"
class=${classMap({
[rootClass]: true,
[`${rootClass}--${orientation}`]: orientation,
...customClasses.reduce((a, c) => ({ ...a, [c]: true }), {}),
})}
>
<div class="spectrum-SplitView-pane" style="${panelStyles[0]}">
${panelLabels[0]}
</div>
<div
class=${classMap({
[`${rootClass}-splitter`]: true,
["is-focused"]: isFocused,
["is-draggable"]: isResizable,
[`is-collapsed-${collapsibleClassName}`]: isCollapsible,
})}
tabindex="0"
data-testid="splitter"
>
${when(
isResizable,
() => html`<div class="spectrum-SplitView-gripper"></div>`
)}
</div>
<div class="spectrum-SplitView-pane" style="${panelStyles[1]}">
${panelLabels[1]}
</div>
</div>
`;
};