-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Expand file tree
/
Copy pathWidgetSection.svelte
More file actions
182 lines (158 loc) · 4.43 KB
/
WidgetSection.svelte
File metadata and controls
182 lines (158 loc) · 4.43 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
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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
<script lang="ts">
import { getContext } from "svelte";
import LayoutCol from "/src/components/layout/LayoutCol.svelte";
import IconButton from "/src/components/widgets/buttons/IconButton.svelte";
import TextLabel from "/src/components/widgets/labels/TextLabel.svelte";
import WidgetSpan from "/src/components/widgets/WidgetSpan.svelte";
import type { EditorWrapper, LayoutTarget, WidgetSection as WidgetSectionData } from "/wrapper/pkg/graphite_wasm_wrapper";
export let widgetData: WidgetSectionData;
export let layoutTarget: LayoutTarget;
let className = "";
export { className as class };
export let classes: Record<string, boolean> = {};
let expanded = true;
const editor = getContext<EditorWrapper>("editor");
</script>
<!-- TODO: Implement collapsable sections with properties system -->
<LayoutCol class={`widget-section ${className}`.trim()} {classes}>
<button class="header" class:expanded on:click|stopPropagation={() => (expanded = !expanded)} tabindex="0">
<div class="expand-arrow"></div>
<TextLabel tooltipLabel={widgetData.name} tooltipDescription={widgetData.description} bold={true}>{widgetData.name}</TextLabel>
<IconButton
icon={widgetData.pinned ? "PinActive" : "PinInactive"}
tooltipDescription={widgetData.pinned ? "Unpin this node so it's no longer shown here when nothing is selected." : "Pin this node so it's shown here when nothing is selected."}
size={24}
action={(e) => {
editor.setNodePinned(widgetData.id, !widgetData.pinned);
e?.stopPropagation();
}}
class="show-only-on-hover"
/>
<IconButton
icon="Trash"
tooltipDescription="Delete this node from the layer chain."
size={24}
action={(e) => {
editor.deleteNode(widgetData.id);
e?.stopPropagation();
}}
class="show-only-on-hover"
/>
<IconButton
icon={widgetData.visible ? "EyeVisible" : "EyeHidden"}
hoverIcon={widgetData.visible ? "EyeHide" : "EyeShow"}
tooltipDescription={widgetData.visible ? "Hide this node." : "Show this node."}
size={24}
action={(e) => {
editor.toggleNodeVisibilityLayerPanel(widgetData.id);
e?.stopPropagation();
}}
class={widgetData.visible ? "show-only-on-hover" : ""}
/>
</button>
{#if expanded}
<LayoutCol class="body" data-block-hover-transfer>
{#each widgetData.layout as layoutGroup}
{#if "Row" in layoutGroup}
<WidgetSpan direction="row" widgets={layoutGroup.Row.rowWidgets} {layoutTarget} />
{:else if "Section" in layoutGroup}
<svelte:self widgetData={layoutGroup.Section} {layoutTarget} />
{/if}
{/each}
</LayoutCol>
{/if}
</LayoutCol>
<style lang="scss" global>
.widget-section {
flex: 0 0 auto;
margin: 0 4px;
margin-top: 4px;
.header {
text-align: left;
align-items: center;
display: flex;
flex: 0 0 24px;
padding-left: 8px;
padding-right: 0;
margin-bottom: 4px;
border: 0;
border-radius: 4px;
background: var(--color-2-mildblack);
&.expanded {
border-radius: 4px 4px 0 0;
margin-bottom: 0;
.expand-arrow::after {
transform: rotate(90deg);
}
}
&:hover {
background: var(--color-4-dimgray);
.expand-arrow::after {
background: var(--icon-expand-collapse-arrow-hover);
}
+ .body {
border: 1px solid var(--color-4-dimgray);
}
}
.expand-arrow {
width: 8px;
height: 8px;
margin: 0;
padding: 0;
position: relative;
flex: 0 0 auto;
display: flex;
align-items: center;
justify-content: center;
&::after {
content: "";
position: absolute;
width: 8px;
height: 8px;
background: var(--icon-expand-collapse-arrow);
}
}
.text-label {
height: 18px;
margin-left: 8px;
flex: 1 1 100%;
}
}
&:not(:hover) .header .show-only-on-hover {
display: none;
}
.body {
padding: 0 7px;
padding-top: 1px;
margin-top: -1px;
background: var(--color-3-darkgray);
border: 1px solid var(--color-2-mildblack);
border-radius: 0 0 4px 4px;
overflow: hidden;
.widget-span.row {
&:first-child {
margin-top: calc(4px - 1px);
}
&:last-child {
margin-bottom: calc(4px - 1px);
}
> .text-button:first-child {
margin-left: 16px;
}
> .text-label:first-of-type {
flex: 0 0 25%;
margin-left: 16px;
}
> .parameter-expose-button + .text-label:first-of-type {
margin-left: 8px;
}
> .text-button {
flex-grow: 1;
}
> .radio-input button {
flex: 1 1 100%;
}
}
}
}
</style>