@potch/html-bin 2.0.1 → 2.1.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/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.0",
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,13 @@ export const createBin = ({
162
164
  }
163
165
  });
164
166
 
165
- const isMiniMode = computed(() => actualWidth.value <= 700);
167
+ const isMiniMode = computed(() => !splitMode || actualWidth.value <= 700);
166
168
  const resizing = signal(false);
167
- const splitOverride = signal(null);
169
+ const splitOverride = signal(
170
+ splitMode && initialTab === "preview" ? 0 : null
171
+ );
168
172
 
169
- const activeTab = signal("js");
173
+ const activeTab = signal(initialTab);
170
174
 
171
175
  const sources = {
172
176
  js: signal(rawSources.js ?? "// js goes here"),
@@ -370,8 +374,16 @@ export const createBin = ({
370
374
  ),
371
375
  _("button", {
372
376
  className: "bin__preview__expand bin__iconbutton",
373
- title: "toggle showing only the preview",
374
- "aria-label": "toggle showing only the preview",
377
+ title: computed(() =>
378
+ splitOverride.value === 0
379
+ ? "show the code tabs"
380
+ : "show only the preview"
381
+ ),
382
+ "aria-label": computed(() =>
383
+ splitOverride.value === 0
384
+ ? "show the code tabs"
385
+ : "show only the preview"
386
+ ),
375
387
  innerText: computed(() => (splitOverride.value === 0 ? "⏭️" : "↔️")),
376
388
  style: computed(() => ({
377
389
  order: splitOverride.value === 0 ? -1 : "unset",
@@ -488,6 +500,7 @@ export const createBin = ({
488
500
  el: binEl,
489
501
  editors,
490
502
  activeTab,
503
+ splitMode,
491
504
  start,
492
505
  teardown,
493
506
  };