@potch/html-bin 2.1.1 → 2.2.0
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.
- package/build/index.min.js +1 -1
- package/build/index.min.js.map +1 -1
- package/package.json +1 -1
- package/src/index.js +46 -28
- package/src/style.css +17 -0
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -134,7 +134,7 @@ Returns object with the following fields:
|
|
|
134
134
|
export const createBin = ({
|
|
135
135
|
container,
|
|
136
136
|
sources: rawSources,
|
|
137
|
-
split,
|
|
137
|
+
split = 0.5,
|
|
138
138
|
initialTab = "js",
|
|
139
139
|
splitMode = true,
|
|
140
140
|
width,
|
|
@@ -145,7 +145,7 @@ export const createBin = ({
|
|
|
145
145
|
document.head.append(injectedStyles);
|
|
146
146
|
}
|
|
147
147
|
|
|
148
|
-
const editorSplit = signal(parseFloat(split)
|
|
148
|
+
const editorSplit = signal(parseFloat(split));
|
|
149
149
|
|
|
150
150
|
const teardownFns = [];
|
|
151
151
|
const stopCapturingEffects = onEffect((fn) => teardownFns.push(fn));
|
|
@@ -164,6 +164,8 @@ export const createBin = ({
|
|
|
164
164
|
}
|
|
165
165
|
});
|
|
166
166
|
|
|
167
|
+
const isFullScreen = signal(false);
|
|
168
|
+
|
|
167
169
|
const isMiniMode = computed(() => {
|
|
168
170
|
const w = actualWidth.value;
|
|
169
171
|
return !splitMode || w <= 700;
|
|
@@ -337,7 +339,8 @@ export const createBin = ({
|
|
|
337
339
|
() =>
|
|
338
340
|
"bin" +
|
|
339
341
|
maybe(isMiniMode.value, " bin--mini-mode") +
|
|
340
|
-
maybe(resizing.value, " bin--resizing")
|
|
342
|
+
maybe(resizing.value, " bin--resizing") +
|
|
343
|
+
maybe(isFullScreen.value, " bin--fullscreen")
|
|
341
344
|
),
|
|
342
345
|
},
|
|
343
346
|
_(
|
|
@@ -360,6 +363,21 @@ export const createBin = ({
|
|
|
360
363
|
_(
|
|
361
364
|
"div",
|
|
362
365
|
{ className: "bin__menu" },
|
|
366
|
+
_(
|
|
367
|
+
"button",
|
|
368
|
+
{
|
|
369
|
+
className: "bin__preview__expand bin__iconbutton",
|
|
370
|
+
title: "show the code tabs",
|
|
371
|
+
"aria-label": "show the code tabs",
|
|
372
|
+
style: computed(() => ({
|
|
373
|
+
display: splitOverride.value === 0 ? "block" : "none",
|
|
374
|
+
})),
|
|
375
|
+
onclick: () => {
|
|
376
|
+
splitOverride.value = null;
|
|
377
|
+
},
|
|
378
|
+
},
|
|
379
|
+
"⏭️"
|
|
380
|
+
),
|
|
363
381
|
_(
|
|
364
382
|
"div",
|
|
365
383
|
{ className: "bin__tab bin__preview_tab bin__tab--active" },
|
|
@@ -375,26 +393,21 @@ export const createBin = ({
|
|
|
375
393
|
"🔁"
|
|
376
394
|
)
|
|
377
395
|
),
|
|
378
|
-
_(
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
innerText: computed(() => (splitOverride.value === 0 ? "⏭️" : "↔️")),
|
|
391
|
-
style: computed(() => ({
|
|
392
|
-
order: splitOverride.value === 0 ? -1 : "unset",
|
|
393
|
-
})),
|
|
394
|
-
onclick: () => {
|
|
395
|
-
splitOverride.value = splitOverride.value === 0 ? null : 0;
|
|
396
|
+
_(
|
|
397
|
+
"button",
|
|
398
|
+
{
|
|
399
|
+
className: "bin__preview__expand bin__iconbutton",
|
|
400
|
+
title: "show only the preview",
|
|
401
|
+
"aria-label": "show only the preview",
|
|
402
|
+
style: computed(() => ({
|
|
403
|
+
display: splitOverride.value === 0 ? "none" : "block",
|
|
404
|
+
})),
|
|
405
|
+
onclick: () => {
|
|
406
|
+
splitOverride.value = 0;
|
|
407
|
+
},
|
|
396
408
|
},
|
|
397
|
-
|
|
409
|
+
"↔️"
|
|
410
|
+
)
|
|
398
411
|
),
|
|
399
412
|
editorPanes.js,
|
|
400
413
|
editorPanes.css,
|
|
@@ -410,7 +423,14 @@ export const createBin = ({
|
|
|
410
423
|
src: previewURL,
|
|
411
424
|
}),
|
|
412
425
|
_("div", { className: "bin__controls" })
|
|
413
|
-
)
|
|
426
|
+
),
|
|
427
|
+
_("button", {
|
|
428
|
+
className: "bin__fullscreen bin__iconbutton",
|
|
429
|
+
title: "toggle fullscreen mode",
|
|
430
|
+
"aria-label": "toggle fullscreen mode",
|
|
431
|
+
innerText: computed(() => (isFullScreen.value ? "↖️" : "↘️")),
|
|
432
|
+
onclick: () => (isFullScreen.value = !isFullScreen.value),
|
|
433
|
+
})
|
|
414
434
|
);
|
|
415
435
|
|
|
416
436
|
if (width) binEl.style.setProperty("--bin-width", width);
|
|
@@ -453,10 +473,9 @@ export const createBin = ({
|
|
|
453
473
|
|
|
454
474
|
// set the split in CSS, factoring in expanded panes
|
|
455
475
|
effect(() => {
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
);
|
|
476
|
+
const o = splitOverride.value;
|
|
477
|
+
const s = editorSplit.value;
|
|
478
|
+
binEl.style.setProperty("--resizer-split", o !== null ? o : s);
|
|
460
479
|
});
|
|
461
480
|
|
|
462
481
|
// editor tabs
|
|
@@ -490,7 +509,6 @@ export const createBin = ({
|
|
|
490
509
|
|
|
491
510
|
// destroy / teardown
|
|
492
511
|
stopCapturingEffects();
|
|
493
|
-
console.log(teardownFns);
|
|
494
512
|
|
|
495
513
|
const teardown = () => {
|
|
496
514
|
while (teardownFns.length) {
|
package/src/style.css
CHANGED
|
@@ -33,6 +33,15 @@
|
|
|
33
33
|
--code-comment: #a3b0d9;
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
+
.bin--fullscreen {
|
|
37
|
+
--bin-width: 100svw !important;
|
|
38
|
+
--bin-height: 100svh !important;
|
|
39
|
+
position: fixed;
|
|
40
|
+
inset: 0;
|
|
41
|
+
height: 100svh;
|
|
42
|
+
max-height: 100svh;
|
|
43
|
+
}
|
|
44
|
+
|
|
36
45
|
.bin__widget {
|
|
37
46
|
position: absolute;
|
|
38
47
|
width: 100%;
|
|
@@ -102,7 +111,15 @@
|
|
|
102
111
|
margin-inline: 0.5rem;
|
|
103
112
|
}
|
|
104
113
|
|
|
114
|
+
.bin__fullscreen {
|
|
115
|
+
position: absolute;
|
|
116
|
+
bottom: 0.5rem;
|
|
117
|
+
right: 0.5rem;
|
|
118
|
+
padding: 0.25rem;
|
|
119
|
+
}
|
|
120
|
+
|
|
105
121
|
.bin__resizer {
|
|
122
|
+
user-select: none;
|
|
106
123
|
grid-area: resizer;
|
|
107
124
|
cursor: ew-resize;
|
|
108
125
|
position: relative;
|