@potch/html-bin 2.0.1 → 2.1.1

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/index.html CHANGED
@@ -25,7 +25,7 @@ setInterval(() => {
25
25
  }`,
26
26
  html: "<h1>HI</h1>\n",
27
27
  },
28
- split: 0.6,
28
+ initialTab: "preview",
29
29
  height: "512px",
30
30
  });
31
31
  </script>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@potch/html-bin",
3
- "version": "2.0.1",
3
+ "version": "2.1.1",
4
4
  "description": "",
5
5
  "main": "src/index.js",
6
6
  "type": "module",
package/src/index.js CHANGED
@@ -135,6 +135,8 @@ export const createBin = ({
135
135
  container,
136
136
  sources: rawSources,
137
137
  split,
138
+ initialTab = "js",
139
+ splitMode = true,
138
140
  width,
139
141
  height,
140
142
  }) => {
@@ -162,11 +164,16 @@ export const createBin = ({
162
164
  }
163
165
  });
164
166
 
165
- const isMiniMode = computed(() => actualWidth.value <= 700);
167
+ const isMiniMode = computed(() => {
168
+ const w = actualWidth.value;
169
+ return !splitMode || w <= 700;
170
+ });
166
171
  const resizing = signal(false);
167
- const splitOverride = signal(null);
172
+ const splitOverride = signal(
173
+ splitMode && initialTab === "preview" ? 0 : null
174
+ );
168
175
 
169
- const activeTab = signal("js");
176
+ const activeTab = signal(initialTab);
170
177
 
171
178
  const sources = {
172
179
  js: signal(rawSources.js ?? "// js goes here"),
@@ -370,8 +377,16 @@ export const createBin = ({
370
377
  ),
371
378
  _("button", {
372
379
  className: "bin__preview__expand bin__iconbutton",
373
- title: "toggle showing only the preview",
374
- "aria-label": "toggle showing only the preview",
380
+ title: computed(() =>
381
+ splitOverride.value === 0
382
+ ? "show the code tabs"
383
+ : "show only the preview"
384
+ ),
385
+ "aria-label": computed(() =>
386
+ splitOverride.value === 0
387
+ ? "show the code tabs"
388
+ : "show only the preview"
389
+ ),
375
390
  innerText: computed(() => (splitOverride.value === 0 ? "⏭️" : "↔️")),
376
391
  style: computed(() => ({
377
392
  order: splitOverride.value === 0 ? -1 : "unset",
@@ -488,6 +503,7 @@ export const createBin = ({
488
503
  el: binEl,
489
504
  editors,
490
505
  activeTab,
506
+ splitMode,
491
507
  start,
492
508
  teardown,
493
509
  };