@abcnews/components-builder 0.0.15 → 0.0.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,9 +1,82 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
let { Viz, Sidebar } = $props();
|
|
3
|
+
|
|
4
|
+
let vizAreaWidth = $state();
|
|
5
|
+
let vizAreaHeight = $state();
|
|
6
|
+
|
|
7
|
+
let vizDimensions: [number, number] = $state([Infinity, Infinity]);
|
|
8
|
+
let presetValue: [number, number] | "custom" | "auto" = $state("auto");
|
|
9
|
+
|
|
10
|
+
$effect(() => {
|
|
11
|
+
if (Array.isArray(presetValue)) {
|
|
12
|
+
vizDimensions = [presetValue[0], presetValue[1]];
|
|
13
|
+
}
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
$effect(() => {
|
|
17
|
+
const match = commonViewports
|
|
18
|
+
.values()
|
|
19
|
+
.find((d) => d[0] === vizDimensions[0] && d[1] === vizDimensions[1]);
|
|
20
|
+
|
|
21
|
+
if (!match) {
|
|
22
|
+
presetValue =
|
|
23
|
+
vizAreaWidth === vizDimensions[0] && vizAreaHeight === vizDimensions[1]
|
|
24
|
+
? "auto"
|
|
25
|
+
: "custom";
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
const commonViewports = new Map<string, [number, number]>([
|
|
30
|
+
["Desktop (large)", [1920, 1080]],
|
|
31
|
+
["Desktop (small)", [1280, 720]],
|
|
32
|
+
["iPad Pro", [1024, 1366]],
|
|
33
|
+
["Surface Pro 7", [912, 1368]],
|
|
34
|
+
["Gallaxy Note 20", [412, 915]],
|
|
35
|
+
["iPhone 14 Pro Max", [430, 932]],
|
|
36
|
+
["iPhone SE", [375, 667]],
|
|
37
|
+
]);
|
|
3
38
|
</script>
|
|
4
39
|
|
|
5
40
|
<div class="builder-frame">
|
|
6
|
-
<div class="builder-frame__viz">
|
|
41
|
+
<div class="builder-frame__viz">
|
|
42
|
+
<div class="tools">
|
|
43
|
+
<select name="resize-options" bind:value={presetValue}>
|
|
44
|
+
<option value={"auto"} selected>Auto</option>
|
|
45
|
+
<option value={"custom"}>Custom</option>
|
|
46
|
+
{#each commonViewports.entries() as [name, dimensions]}
|
|
47
|
+
<option value={dimensions}>{name}</option>
|
|
48
|
+
{/each}
|
|
49
|
+
</select>
|
|
50
|
+
<input
|
|
51
|
+
disabled={presetValue === "auto"}
|
|
52
|
+
id="viz-width"
|
|
53
|
+
type="number"
|
|
54
|
+
bind:value={vizDimensions[0]}
|
|
55
|
+
/>
|
|
56
|
+
x
|
|
57
|
+
<input
|
|
58
|
+
disabled={presetValue === "auto"}
|
|
59
|
+
id="viz-height"
|
|
60
|
+
type="number"
|
|
61
|
+
bind:value={vizDimensions[1]}
|
|
62
|
+
/>
|
|
63
|
+
</div>
|
|
64
|
+
<div
|
|
65
|
+
class="content-area"
|
|
66
|
+
bind:offsetWidth={vizAreaWidth}
|
|
67
|
+
bind:offsetHeight={vizAreaHeight}
|
|
68
|
+
>
|
|
69
|
+
<div
|
|
70
|
+
class="resize-frame"
|
|
71
|
+
bind:offsetWidth={vizDimensions[0]}
|
|
72
|
+
bind:offsetHeight={vizDimensions[1]}
|
|
73
|
+
style:width={presetValue === "auto" ? "100%" : `${vizDimensions[0]}px`}
|
|
74
|
+
style:height={presetValue === "auto" ? "100%" : `${vizDimensions[1]}px`}
|
|
75
|
+
>
|
|
76
|
+
{@render Viz?.()}
|
|
77
|
+
</div>
|
|
78
|
+
</div>
|
|
79
|
+
</div>
|
|
7
80
|
|
|
8
81
|
<div class="builder-frame__sidebar">{@render Sidebar?.()}</div>
|
|
9
82
|
</div>
|
|
@@ -20,16 +93,51 @@
|
|
|
20
93
|
color: var(--text);
|
|
21
94
|
}
|
|
22
95
|
.builder-frame__viz {
|
|
96
|
+
display: grid;
|
|
97
|
+
grid-template-columns: 100%;
|
|
98
|
+
grid-template-rows: min-content 1fr;
|
|
23
99
|
flex: 1;
|
|
24
100
|
min-width: 50%;
|
|
25
|
-
justify-content: center;
|
|
26
|
-
align-items: center;
|
|
27
101
|
position: relative;
|
|
28
102
|
overflow: hidden;
|
|
29
|
-
|
|
30
|
-
background: white;
|
|
103
|
+
background: var(--background-alt);
|
|
31
104
|
color: black;
|
|
105
|
+
|
|
106
|
+
> * {
|
|
107
|
+
margin: 5px;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
.tools {
|
|
111
|
+
width: 100%;
|
|
112
|
+
text-align: left;
|
|
113
|
+
font-size: 0.8em;
|
|
114
|
+
margin-bottom: 0;
|
|
115
|
+
select {
|
|
116
|
+
width: 8em;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
input[type="number"] {
|
|
120
|
+
width: 5em;
|
|
121
|
+
&[disabled] {
|
|
122
|
+
opacity: 0.3;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
.content-area {
|
|
128
|
+
overflow: auto;
|
|
129
|
+
display: block;
|
|
130
|
+
|
|
131
|
+
.resize-frame {
|
|
132
|
+
resize: both;
|
|
133
|
+
overflow: auto;
|
|
134
|
+
background-color: var(--background);
|
|
135
|
+
border: 1px solid hsl(from var(--border) h s l / 0.2);
|
|
136
|
+
box-shadow: hsl(from var(--border) h s l / 0.1) 0 0 5px;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
32
139
|
}
|
|
140
|
+
|
|
33
141
|
.builder-frame__sidebar {
|
|
34
142
|
width: 22rem;
|
|
35
143
|
padding: 2rem 1rem;
|