treesap 0.1.4 → 0.1.6
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/dist/components/SimpleLivePreview.d.ts.map +1 -1
- package/dist/components/SimpleLivePreview.js +1 -1
- package/dist/components/SimpleLivePreview.js.map +1 -1
- package/dist/pages/Code.js +1 -1
- package/dist/pages/Code.js.map +1 -1
- package/dist/static/components/SimpleLivePreview.js +41 -26
- package/dist/static/styles/main.css +31 -8
- package/package.json +1 -1
- package/src/components/SimpleLivePreview.tsx +12 -2
- package/src/pages/Code.tsx +3 -3
- package/src/static/components/SimpleLivePreview.js +41 -26
- package/src/static/styles/main.css +31 -8
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SimpleLivePreview.d.ts","sourceRoot":"","sources":["../../src/components/SimpleLivePreview.tsx"],"names":[],"mappings":"AAAA,UAAU,sBAAsB;IAC9B,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,wBAAgB,iBAAiB,CAAC,EAAE,EAAqB,EAAE,WAAkB,EAAE,EAAE,sBAAsB,
|
|
1
|
+
{"version":3,"file":"SimpleLivePreview.d.ts","sourceRoot":"","sources":["../../src/components/SimpleLivePreview.tsx"],"names":[],"mappings":"AAAA,UAAU,sBAAsB;IAC9B,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,wBAAgB,iBAAiB,CAAC,EAAE,EAAqB,EAAE,WAAkB,EAAE,EAAE,sBAAsB,kDAkCtG"}
|
|
@@ -2,6 +2,6 @@ import { jsx as _jsx, jsxs as _jsxs } from "hono/jsx/jsx-runtime";
|
|
|
2
2
|
export function SimpleLivePreview({ id = "simple-preview", previewPort = 5173 }) {
|
|
3
3
|
const defaultSrc = `http://localhost:${previewPort}`;
|
|
4
4
|
const baseUrl = `localhost:${previewPort}/`;
|
|
5
|
-
return (_jsxs("sapling-island", { loading: "visible", children: [_jsxs("template", { children: [_jsx("script", { type: "module", src: "https://code.iconify.design/iconify-icon/2.0.0/iconify-icon.min.js" }), _jsx("script", { type: "module", src: "/components/SimpleLivePreview.js" })] }),
|
|
5
|
+
return (_jsxs("sapling-island", { loading: "visible", children: [_jsxs("template", { children: [_jsx("script", { type: "module", src: "https://code.iconify.design/iconify-icon/2.0.0/iconify-icon.min.js" }), _jsx("script", { type: "module", src: "/components/SimpleLivePreview.js" })] }), _jsxs("div", { id: id, class: "flex-1 h-full bg-white transition-all duration-300 p-2 relative overflow-hidden", children: [_jsx("iframe", { id: `${id}-iframe`, src: defaultSrc, class: "w-full h-full border border-gray-300 bg-white block rounded-md", title: "Live Preview", sandbox: "allow-same-origin allow-scripts allow-forms allow-popups allow-top-navigation allow-downloads allow-modals allow-orientation-lock allow-pointer-lock allow-presentation allow-storage-access-by-user-activation", "data-preview-port": previewPort }), _jsx("button", { id: `${id}-floating-hide-sidebar-btn`, class: "absolute p-3 bg-white border-2 border-gray-400 rounded-lg shadow-xl hover:bg-gray-50 hover:shadow-2xl transition-all flex items-center justify-center z-50", title: "Toggle Sidebar", style: "position: absolute !important; z-index: 9999 !important; bottom: 16px; left: 16px;", children: _jsx("iconify-icon", { id: `${id}-floating-hide-sidebar-icon`, icon: "ph:sidebar-simple", width: "20", height: "20", class: "text-gray-800" }) })] })] }));
|
|
6
6
|
}
|
|
7
7
|
//# sourceMappingURL=SimpleLivePreview.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SimpleLivePreview.js","sourceRoot":"","sources":["../../src/components/SimpleLivePreview.tsx"],"names":[],"mappings":";AAKA,MAAM,UAAU,iBAAiB,CAAC,EAAE,EAAE,GAAG,gBAAgB,EAAE,WAAW,GAAG,IAAI,EAA0B;IACrG,MAAM,UAAU,GAAG,oBAAoB,WAAW,EAAE,CAAC;IACrD,MAAM,OAAO,GAAG,aAAa,WAAW,GAAG,CAAC;IAE5C,OAAO,CACL,0BAAgB,OAAO,EAAC,SAAS,aAC/B,+BACE,iBAAQ,IAAI,EAAC,QAAQ,EAAC,GAAG,EAAC,oEAAoE,GAAU,EACxG,iBAAQ,IAAI,EAAC,QAAQ,EAAC,GAAG,EAAC,kCAAkC,GAAU,IAC7D,EAEX,
|
|
1
|
+
{"version":3,"file":"SimpleLivePreview.js","sourceRoot":"","sources":["../../src/components/SimpleLivePreview.tsx"],"names":[],"mappings":";AAKA,MAAM,UAAU,iBAAiB,CAAC,EAAE,EAAE,GAAG,gBAAgB,EAAE,WAAW,GAAG,IAAI,EAA0B;IACrG,MAAM,UAAU,GAAG,oBAAoB,WAAW,EAAE,CAAC;IACrD,MAAM,OAAO,GAAG,aAAa,WAAW,GAAG,CAAC;IAE5C,OAAO,CACL,0BAAgB,OAAO,EAAC,SAAS,aAC/B,+BACE,iBAAQ,IAAI,EAAC,QAAQ,EAAC,GAAG,EAAC,oEAAoE,GAAU,EACxG,iBAAQ,IAAI,EAAC,QAAQ,EAAC,GAAG,EAAC,kCAAkC,GAAU,IAC7D,EAEX,eAAK,EAAE,EAAE,EAAE,EAAE,KAAK,EAAC,iFAAiF,aAElG,iBACE,EAAE,EAAE,GAAG,EAAE,SAAS,EAClB,GAAG,EAAE,UAAU,EACf,KAAK,EAAC,gEAAgE,EACtE,KAAK,EAAC,cAAc,EACpB,OAAO,EAAC,iNAAiN,uBACtM,WAAW,GACtB,EAGV,iBACE,EAAE,EAAE,GAAG,EAAE,4BAA4B,EACrC,KAAK,EAAC,4JAA4J,EAClK,KAAK,EAAC,gBAAgB,EACtB,KAAK,EAAC,oFAAoF,YAE1F,uBAAc,EAAE,EAAE,GAAG,EAAE,6BAA6B,EAAE,IAAI,EAAC,mBAAmB,EAAC,KAAK,EAAC,IAAI,EAAC,MAAM,EAAC,IAAI,EAAC,KAAK,EAAC,eAAe,GAAgB,GACpI,IACL,IACS,CAClB,CAAC;AACJ,CAAC"}
|
package/dist/pages/Code.js
CHANGED
|
@@ -3,6 +3,6 @@ import Layout from "../layouts/Layout.js";
|
|
|
3
3
|
import { Terminal as TerminalComponent } from "../components/Terminal.js";
|
|
4
4
|
import { SimpleLivePreview } from "../components/SimpleLivePreview.js";
|
|
5
5
|
export function Code({ previewPort = 1234, workingDirectory }) {
|
|
6
|
-
return (_jsx(Layout, { title: "Code Editor", children: _jsxs("div", { id: "code-container", class: "h-screen flex bg-[#1e1e1e]", children: [_jsxs("div", { id: "sidebar-pane", class: "w-2/5 border-r border-[#3c3c3c] transition-all duration-300 flex flex-col bg-[#252526]", children: [_jsx("div", { class: "p-3 border-b border-[#3c3c3c]", children: _jsx("a", { href: "/", class: "text-[#cccccc] hover:text-white text-sm", children: "\u2190 Back to Home" }) }), _jsx("div", { class: "p-3 border-b border-[#3c3c3c] bg-[#2d2d30]", children: _jsxs("div", { class: "flex items-center gap-2", children: [_jsx("button", { id: "live-preview-hide-
|
|
6
|
+
return (_jsx(Layout, { title: "Code Editor", children: _jsxs("div", { id: "code-container", class: "h-screen flex bg-[#1e1e1e]", children: [_jsxs("div", { id: "sidebar-pane", class: "w-2/5-plus border-r border-[#3c3c3c] transition-all duration-300 flex flex-col bg-[#252526]", children: [_jsx("div", { class: "p-3 border-b border-[#3c3c3c]", children: _jsx("a", { href: "/", class: "text-[#cccccc] hover:text-white text-sm", children: "\u2190 Back to Home" }) }), _jsx("div", { class: "p-3 border-b border-[#3c3c3c] bg-[#2d2d30]", children: _jsxs("div", { class: "flex items-center gap-2", children: [_jsx("button", { id: "live-preview-hide-sidebar-btn", class: "p-2 hover:bg-[#3c3c3c] rounded-md transition-colors flex items-center text-[#cccccc] hover:text-white", title: "Hide Sidebar", children: _jsx("iconify-icon", { id: "live-preview-hide-sidebar-icon", icon: "ph:sidebar-simple", width: "16", height: "16" }) }), _jsx("button", { type: "button", id: "live-preview-refresh-btn", class: "p-2 hover:bg-[#3c3c3c] rounded-md transition-colors flex-shrink-0 text-[#cccccc] hover:text-white", title: "Reload", children: _jsx("iconify-icon", { icon: "tabler:refresh", width: "16", height: "16" }) }), _jsxs("div", { class: "flex-1 flex items-center bg-[#1e1e1e] border border-[#3c3c3c] rounded px-3 py-2 hover:border-[#0e639c] focus-within:border-[#0e639c] transition-all", children: [_jsx("iconify-icon", { icon: "tabler:world", width: "16", height: "16", class: "text-[#cccccc] mr-2" }), _jsxs("span", { class: "text-[#cccccc] text-sm", children: ["localhost:", previewPort, "/"] }), _jsx("input", { id: "live-preview-url-input", type: "text", placeholder: "path", defaultValue: "", class: "flex-1 bg-transparent text-sm focus:outline-none text-[#cccccc] ml-1" }), _jsx("button", { type: "button", id: "live-preview-load-btn", class: "ml-2 p-1 hover:bg-[#3c3c3c] rounded transition-colors flex-shrink-0 text-[#cccccc] hover:text-white", title: "Go", children: _jsx("iconify-icon", { icon: "tabler:chevron-right", width: "16", height: "16" }) })] })] }) }), _jsxs("div", { class: "flex py-2", children: [_jsx("button", { class: "px-3 py-2 text-[#cccccc] disabled:opacity-50 cursor-not-allowed flex items-center justify-center", children: _jsx("iconify-icon", { icon: "tabler:folder", width: "20", height: "20" }) }), _jsx("button", { class: "px-3 py-2 text-[#cccccc] disabled:opacity-50 cursor-not-allowed flex items-center justify-center", children: _jsx("iconify-icon", { icon: "tabler:search", width: "20", height: "20" }) }), _jsx("button", { class: "px-3 py-2 text-white flex items-center justify-center", children: _jsx("iconify-icon", { icon: "tabler:terminal", width: "20", height: "20" }) }), _jsx("button", { class: "px-3 py-2 text-[#cccccc] disabled:opacity-50 cursor-not-allowed flex items-center justify-center", children: _jsx("iconify-icon", { icon: "tabler:git-merge", width: "20", height: "20" }) })] }), _jsx("div", { class: "flex-1 overflow-hidden bg-[#1e1e1e]", children: _jsx("div", { class: "h-full p-4", children: _jsx(TerminalComponent, { id: "terminal", sessionId: "shared-terminal-session" }) }) })] }), _jsx(SimpleLivePreview, { id: "live-preview", previewPort: previewPort })] }) }));
|
|
7
7
|
}
|
|
8
8
|
//# sourceMappingURL=Code.js.map
|
package/dist/pages/Code.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Code.js","sourceRoot":"","sources":["../../src/pages/Code.tsx"],"names":[],"mappings":";AAAA,OAAO,MAAM,MAAM,sBAAsB,CAAC;AAC1C,OAAO,EAAE,QAAQ,IAAI,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAC1E,OAAO,EAAE,iBAAiB,EAAE,MAAM,oCAAoC,CAAC;AAOvE,MAAM,UAAU,IAAI,CAAC,EAAE,WAAW,GAAG,IAAI,EAAE,gBAAgB,EAAiB;IAC1E,OAAO,CACL,KAAC,MAAM,IAAC,KAAK,EAAC,aAAa,YACzB,eAAK,EAAE,EAAC,gBAAgB,EAAC,KAAK,EAAC,4BAA4B,aAEzD,eAAK,EAAE,EAAC,cAAc,EAAC,KAAK,EAAC,
|
|
1
|
+
{"version":3,"file":"Code.js","sourceRoot":"","sources":["../../src/pages/Code.tsx"],"names":[],"mappings":";AAAA,OAAO,MAAM,MAAM,sBAAsB,CAAC;AAC1C,OAAO,EAAE,QAAQ,IAAI,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAC1E,OAAO,EAAE,iBAAiB,EAAE,MAAM,oCAAoC,CAAC;AAOvE,MAAM,UAAU,IAAI,CAAC,EAAE,WAAW,GAAG,IAAI,EAAE,gBAAgB,EAAiB;IAC1E,OAAO,CACL,KAAC,MAAM,IAAC,KAAK,EAAC,aAAa,YACzB,eAAK,EAAE,EAAC,gBAAgB,EAAC,KAAK,EAAC,4BAA4B,aAEzD,eAAK,EAAE,EAAC,cAAc,EAAC,KAAK,EAAC,6FAA6F,aAExH,cAAK,KAAK,EAAC,+BAA+B,YACxC,YAAG,IAAI,EAAC,GAAG,EAAC,KAAK,EAAC,yCAAyC,oCAAmB,GAC1E,EAGN,cAAK,KAAK,EAAC,4CAA4C,YACrD,eAAK,KAAK,EAAC,yBAAyB,aAClC,iBACE,EAAE,EAAC,+BAA+B,EAClC,KAAK,EAAC,uGAAuG,EAC7G,KAAK,EAAC,cAAc,YAEpB,uBAAc,EAAE,EAAC,gCAAgC,EAAC,IAAI,EAAC,mBAAmB,EAAC,KAAK,EAAC,IAAI,EAAC,MAAM,EAAC,IAAI,GAAgB,GAC1G,EACT,iBACE,IAAI,EAAC,QAAQ,EACb,EAAE,EAAC,0BAA0B,EAC7B,KAAK,EAAC,mGAAmG,EACzG,KAAK,EAAC,QAAQ,YAEd,uBAAc,IAAI,EAAC,gBAAgB,EAAC,KAAK,EAAC,IAAI,EAAC,MAAM,EAAC,IAAI,GAAgB,GACnE,EACT,eAAK,KAAK,EAAC,qJAAqJ,aAC9J,uBAAc,IAAI,EAAC,cAAc,EAAC,KAAK,EAAC,IAAI,EAAC,MAAM,EAAC,IAAI,EAAC,KAAK,EAAC,qBAAqB,GAAgB,EACpG,gBAAM,KAAK,EAAC,wBAAwB,2BAAY,WAAW,SAAS,EACpE,gBACE,EAAE,EAAC,wBAAwB,EAC3B,IAAI,EAAC,MAAM,EACX,WAAW,EAAC,MAAM,EAClB,YAAY,EAAC,EAAE,EACf,KAAK,EAAC,sEAAsE,GAC5E,EACF,iBACE,IAAI,EAAC,QAAQ,EACb,EAAE,EAAC,uBAAuB,EAC1B,KAAK,EAAC,qGAAqG,EAC3G,KAAK,EAAC,IAAI,YAEV,uBAAc,IAAI,EAAC,sBAAsB,EAAC,KAAK,EAAC,IAAI,EAAC,MAAM,EAAC,IAAI,GAAgB,GACzE,IACL,IACF,GACF,EAGN,eAAK,KAAK,EAAC,WAAW,aACpB,iBAAQ,KAAK,EAAC,kGAAkG,YAC9G,uBAAc,IAAI,EAAC,eAAe,EAAC,KAAK,EAAC,IAAI,EAAC,MAAM,EAAC,IAAI,GAAgB,GAClE,EACT,iBAAQ,KAAK,EAAC,kGAAkG,YAC9G,uBAAc,IAAI,EAAC,eAAe,EAAC,KAAK,EAAC,IAAI,EAAC,MAAM,EAAC,IAAI,GAAgB,GAClE,EACT,iBAAQ,KAAK,EAAC,uDAAuD,YACnE,uBAAc,IAAI,EAAC,iBAAiB,EAAC,KAAK,EAAC,IAAI,EAAC,MAAM,EAAC,IAAI,GAAgB,GACpE,EACT,iBAAQ,KAAK,EAAC,kGAAkG,YAC9G,uBAAc,IAAI,EAAC,kBAAkB,EAAC,KAAK,EAAC,IAAI,EAAC,MAAM,EAAC,IAAI,GAAgB,GACrE,IACL,EAGN,cAAK,KAAK,EAAC,qCAAqC,YAE9C,cAAK,KAAK,EAAC,YAAY,YACrB,KAAC,iBAAiB,IAChB,EAAE,EAAC,UAAU,EACb,SAAS,EAAC,yBAAyB,GACnC,GACE,GACF,IACF,EAGN,KAAC,iBAAiB,IAAC,EAAE,EAAC,cAAc,EAAC,WAAW,EAAE,WAAW,GAAI,IAC7D,GACC,CACV,CAAC;AACJ,CAAC"}
|
|
@@ -5,8 +5,10 @@ class SimpleLivePreviewManager {
|
|
|
5
5
|
|
|
6
6
|
// DOM elements
|
|
7
7
|
this.container = document.getElementById(id);
|
|
8
|
-
this.
|
|
9
|
-
this.
|
|
8
|
+
this.hideSidebarBtn = document.getElementById(`${id}-hide-sidebar-btn`);
|
|
9
|
+
this.hideSidebarIcon = document.getElementById(`${id}-hide-sidebar-icon`);
|
|
10
|
+
this.floatingHideSidebarBtn = document.getElementById(`${id}-floating-hide-sidebar-btn`);
|
|
11
|
+
this.floatingHideSidebarIcon = document.getElementById(`${id}-floating-hide-sidebar-icon`);
|
|
10
12
|
this.refreshBtn = document.getElementById(`${id}-refresh-btn`);
|
|
11
13
|
this.urlInput = document.getElementById(`${id}-url-input`);
|
|
12
14
|
this.loadBtn = document.getElementById(`${id}-load-btn`);
|
|
@@ -16,7 +18,7 @@ class SimpleLivePreviewManager {
|
|
|
16
18
|
this.previewPort = this.iframe?.getAttribute('data-preview-port') || 5173;
|
|
17
19
|
|
|
18
20
|
// State
|
|
19
|
-
this.
|
|
21
|
+
this.isSidebarHidden = false;
|
|
20
22
|
|
|
21
23
|
this.init();
|
|
22
24
|
}
|
|
@@ -35,8 +37,9 @@ class SimpleLivePreviewManager {
|
|
|
35
37
|
}
|
|
36
38
|
|
|
37
39
|
setupEventListeners() {
|
|
38
|
-
// Hide
|
|
39
|
-
this.
|
|
40
|
+
// Hide sidebar toggle (both sidebar and floating button)
|
|
41
|
+
this.hideSidebarBtn?.addEventListener('click', () => this.toggleSidebarVisibility());
|
|
42
|
+
this.floatingHideSidebarBtn?.addEventListener('click', () => this.toggleSidebarVisibility());
|
|
40
43
|
|
|
41
44
|
// Refresh button
|
|
42
45
|
this.refreshBtn?.addEventListener('click', () => this.refreshIframe());
|
|
@@ -66,10 +69,10 @@ class SimpleLivePreviewManager {
|
|
|
66
69
|
e.preventDefault();
|
|
67
70
|
this.refreshIframe();
|
|
68
71
|
}
|
|
69
|
-
// Cmd/Ctrl + B to toggle
|
|
72
|
+
// Cmd/Ctrl + B to toggle sidebar panel
|
|
70
73
|
if ((e.metaKey || e.ctrlKey) && e.key === 'b') {
|
|
71
74
|
e.preventDefault();
|
|
72
|
-
this.
|
|
75
|
+
this.toggleSidebarVisibility();
|
|
73
76
|
}
|
|
74
77
|
});
|
|
75
78
|
|
|
@@ -126,38 +129,50 @@ class SimpleLivePreviewManager {
|
|
|
126
129
|
}
|
|
127
130
|
}
|
|
128
131
|
|
|
129
|
-
|
|
130
|
-
this.
|
|
132
|
+
toggleSidebarVisibility() {
|
|
133
|
+
this.isSidebarHidden = !this.isSidebarHidden;
|
|
131
134
|
|
|
132
|
-
const
|
|
135
|
+
const sidebarPane = document.getElementById('sidebar-pane');
|
|
133
136
|
const previewPane = document.getElementById(this.id);
|
|
134
137
|
|
|
135
|
-
if (
|
|
136
|
-
if (this.
|
|
137
|
-
// Hide
|
|
138
|
-
|
|
138
|
+
if (sidebarPane && previewPane) {
|
|
139
|
+
if (this.isSidebarHidden) {
|
|
140
|
+
// Hide sidebar pane and make preview full width
|
|
141
|
+
sidebarPane.style.display = 'none';
|
|
139
142
|
previewPane.classList.remove('flex-1');
|
|
140
143
|
previewPane.classList.add('w-full');
|
|
141
144
|
|
|
142
|
-
// Update button
|
|
143
|
-
if (this.
|
|
144
|
-
this.
|
|
145
|
+
// Update button icons and titles
|
|
146
|
+
if (this.hideSidebarIcon) {
|
|
147
|
+
this.hideSidebarIcon.setAttribute('icon', 'ph:sidebar-simple-fill');
|
|
145
148
|
}
|
|
146
|
-
if (this.
|
|
147
|
-
this.
|
|
149
|
+
if (this.floatingHideSidebarIcon) {
|
|
150
|
+
this.floatingHideSidebarIcon.setAttribute('icon', 'ph:sidebar-simple-fill');
|
|
151
|
+
}
|
|
152
|
+
if (this.hideSidebarBtn) {
|
|
153
|
+
this.hideSidebarBtn.setAttribute('title', 'Show Sidebar');
|
|
154
|
+
}
|
|
155
|
+
if (this.floatingHideSidebarBtn) {
|
|
156
|
+
this.floatingHideSidebarBtn.setAttribute('title', 'Show Sidebar');
|
|
148
157
|
}
|
|
149
158
|
} else {
|
|
150
|
-
// Show
|
|
151
|
-
|
|
159
|
+
// Show sidebar pane and restore original widths
|
|
160
|
+
sidebarPane.style.display = '';
|
|
152
161
|
previewPane.classList.remove('w-full');
|
|
153
162
|
previewPane.classList.add('flex-1');
|
|
154
163
|
|
|
155
|
-
// Update button
|
|
156
|
-
if (this.
|
|
157
|
-
this.
|
|
164
|
+
// Update button icons and titles
|
|
165
|
+
if (this.hideSidebarIcon) {
|
|
166
|
+
this.hideSidebarIcon.setAttribute('icon', 'ph:sidebar-simple');
|
|
167
|
+
}
|
|
168
|
+
if (this.floatingHideSidebarIcon) {
|
|
169
|
+
this.floatingHideSidebarIcon.setAttribute('icon', 'ph:sidebar-simple');
|
|
170
|
+
}
|
|
171
|
+
if (this.hideSidebarBtn) {
|
|
172
|
+
this.hideSidebarBtn.setAttribute('title', 'Hide Sidebar');
|
|
158
173
|
}
|
|
159
|
-
if (this.
|
|
160
|
-
this.
|
|
174
|
+
if (this.floatingHideSidebarBtn) {
|
|
175
|
+
this.floatingHideSidebarBtn.setAttribute('title', 'Hide Sidebar');
|
|
161
176
|
}
|
|
162
177
|
}
|
|
163
178
|
}
|
|
@@ -1109,6 +1109,10 @@ video {
|
|
|
1109
1109
|
position: relative;
|
|
1110
1110
|
}
|
|
1111
1111
|
|
|
1112
|
+
.z-50 {
|
|
1113
|
+
z-index: 50;
|
|
1114
|
+
}
|
|
1115
|
+
|
|
1112
1116
|
.mb-4 {
|
|
1113
1117
|
margin-bottom: 1rem;
|
|
1114
1118
|
}
|
|
@@ -1169,10 +1173,6 @@ video {
|
|
|
1169
1173
|
width: 2.5rem;
|
|
1170
1174
|
}
|
|
1171
1175
|
|
|
1172
|
-
.w-2\/5 {
|
|
1173
|
-
width: 40%;
|
|
1174
|
-
}
|
|
1175
|
-
|
|
1176
1176
|
.w-full {
|
|
1177
1177
|
width: 100%;
|
|
1178
1178
|
}
|
|
@@ -1253,10 +1253,6 @@ video {
|
|
|
1253
1253
|
border-width: 1px;
|
|
1254
1254
|
}
|
|
1255
1255
|
|
|
1256
|
-
.border-0 {
|
|
1257
|
-
border-width: 0px;
|
|
1258
|
-
}
|
|
1259
|
-
|
|
1260
1256
|
.border-2 {
|
|
1261
1257
|
border-width: 2px;
|
|
1262
1258
|
}
|
|
@@ -1274,6 +1270,16 @@ video {
|
|
|
1274
1270
|
border-color: rgb(60 60 60 / var(--tw-border-opacity, 1));
|
|
1275
1271
|
}
|
|
1276
1272
|
|
|
1273
|
+
.border-gray-300 {
|
|
1274
|
+
--tw-border-opacity: 1;
|
|
1275
|
+
border-color: rgb(209 213 219 / var(--tw-border-opacity, 1));
|
|
1276
|
+
}
|
|
1277
|
+
|
|
1278
|
+
.border-gray-400 {
|
|
1279
|
+
--tw-border-opacity: 1;
|
|
1280
|
+
border-color: rgb(156 163 175 / var(--tw-border-opacity, 1));
|
|
1281
|
+
}
|
|
1282
|
+
|
|
1277
1283
|
.border-green-600 {
|
|
1278
1284
|
--tw-border-opacity: 1;
|
|
1279
1285
|
border-color: rgb(22 163 74 / var(--tw-border-opacity, 1));
|
|
@@ -1458,6 +1464,12 @@ video {
|
|
|
1458
1464
|
box-shadow: var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow);
|
|
1459
1465
|
}
|
|
1460
1466
|
|
|
1467
|
+
.shadow-xl {
|
|
1468
|
+
--tw-shadow: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
|
|
1469
|
+
--tw-shadow-colored: 0 20px 25px -5px var(--tw-shadow-color), 0 8px 10px -6px var(--tw-shadow-color);
|
|
1470
|
+
box-shadow: var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow);
|
|
1471
|
+
}
|
|
1472
|
+
|
|
1461
1473
|
.filter {
|
|
1462
1474
|
filter: var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow);
|
|
1463
1475
|
}
|
|
@@ -1493,6 +1505,11 @@ video {
|
|
|
1493
1505
|
background-color: rgb(60 60 60 / var(--tw-bg-opacity, 1));
|
|
1494
1506
|
}
|
|
1495
1507
|
|
|
1508
|
+
.hover\:bg-gray-50:hover {
|
|
1509
|
+
--tw-bg-opacity: 1;
|
|
1510
|
+
background-color: rgb(249 250 251 / var(--tw-bg-opacity, 1));
|
|
1511
|
+
}
|
|
1512
|
+
|
|
1496
1513
|
.hover\:bg-gray-800:hover {
|
|
1497
1514
|
--tw-bg-opacity: 1;
|
|
1498
1515
|
background-color: rgb(31 41 55 / var(--tw-bg-opacity, 1));
|
|
@@ -1508,6 +1525,12 @@ video {
|
|
|
1508
1525
|
color: rgb(255 255 255 / var(--tw-text-opacity, 1));
|
|
1509
1526
|
}
|
|
1510
1527
|
|
|
1528
|
+
.hover\:shadow-2xl:hover {
|
|
1529
|
+
--tw-shadow: 0 25px 50px -12px rgb(0 0 0 / 0.25);
|
|
1530
|
+
--tw-shadow-colored: 0 25px 50px -12px var(--tw-shadow-color);
|
|
1531
|
+
box-shadow: var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow);
|
|
1532
|
+
}
|
|
1533
|
+
|
|
1511
1534
|
.focus\:outline-none:focus {
|
|
1512
1535
|
outline: 2px solid transparent;
|
|
1513
1536
|
outline-offset: 2px;
|
package/package.json
CHANGED
|
@@ -14,16 +14,26 @@ export function SimpleLivePreview({ id = "simple-preview", previewPort = 5173 }:
|
|
|
14
14
|
<script type="module" src="/components/SimpleLivePreview.js"></script>
|
|
15
15
|
</template>
|
|
16
16
|
|
|
17
|
-
<div id={id} class="flex-1 h-full bg-white transition-all duration-300">
|
|
17
|
+
<div id={id} class="flex-1 h-full bg-white transition-all duration-300 p-2 relative overflow-hidden">
|
|
18
18
|
{/* Iframe - Full Height */}
|
|
19
19
|
<iframe
|
|
20
20
|
id={`${id}-iframe`}
|
|
21
21
|
src={defaultSrc}
|
|
22
|
-
class="w-full h-full border-
|
|
22
|
+
class="w-full h-full border border-gray-300 bg-white block rounded-md"
|
|
23
23
|
title="Live Preview"
|
|
24
24
|
sandbox="allow-same-origin allow-scripts allow-forms allow-popups allow-top-navigation allow-downloads allow-modals allow-orientation-lock allow-pointer-lock allow-presentation allow-storage-access-by-user-activation"
|
|
25
25
|
data-preview-port={previewPort}
|
|
26
26
|
></iframe>
|
|
27
|
+
|
|
28
|
+
{/* Floating Sidebar Toggle */}
|
|
29
|
+
<button
|
|
30
|
+
id={`${id}-floating-hide-sidebar-btn`}
|
|
31
|
+
class="absolute p-3 bg-white border-2 border-gray-400 rounded-lg shadow-xl hover:bg-gray-50 hover:shadow-2xl transition-all flex items-center justify-center z-50"
|
|
32
|
+
title="Toggle Sidebar"
|
|
33
|
+
style="position: absolute !important; z-index: 9999 !important; bottom: 16px; left: 16px;"
|
|
34
|
+
>
|
|
35
|
+
<iconify-icon id={`${id}-floating-hide-sidebar-icon`} icon="ph:sidebar-simple" width="20" height="20" class="text-gray-800"></iconify-icon>
|
|
36
|
+
</button>
|
|
27
37
|
</div>
|
|
28
38
|
</sapling-island>
|
|
29
39
|
);
|
package/src/pages/Code.tsx
CHANGED
|
@@ -12,7 +12,7 @@ export function Code({ previewPort = 1234, workingDirectory }: TerminalProps) {
|
|
|
12
12
|
<Layout title="Code Editor">
|
|
13
13
|
<div id="code-container" class="h-screen flex bg-[#1e1e1e]">
|
|
14
14
|
{/* Left Pane - Tabbed Sidebar */}
|
|
15
|
-
<div id="sidebar-pane" class="w-2/5 border-r border-[#3c3c3c] transition-all duration-300 flex flex-col bg-[#252526]">
|
|
15
|
+
<div id="sidebar-pane" class="w-2/5-plus border-r border-[#3c3c3c] transition-all duration-300 flex flex-col bg-[#252526]">
|
|
16
16
|
{/* Back to Home */}
|
|
17
17
|
<div class="p-3 border-b border-[#3c3c3c]">
|
|
18
18
|
<a href="/" class="text-[#cccccc] hover:text-white text-sm">← Back to Home</a>
|
|
@@ -22,11 +22,11 @@ export function Code({ previewPort = 1234, workingDirectory }: TerminalProps) {
|
|
|
22
22
|
<div class="p-3 border-b border-[#3c3c3c] bg-[#2d2d30]">
|
|
23
23
|
<div class="flex items-center gap-2">
|
|
24
24
|
<button
|
|
25
|
-
id="live-preview-hide-
|
|
25
|
+
id="live-preview-hide-sidebar-btn"
|
|
26
26
|
class="p-2 hover:bg-[#3c3c3c] rounded-md transition-colors flex items-center text-[#cccccc] hover:text-white"
|
|
27
27
|
title="Hide Sidebar"
|
|
28
28
|
>
|
|
29
|
-
<iconify-icon id="live-preview-hide-
|
|
29
|
+
<iconify-icon id="live-preview-hide-sidebar-icon" icon="ph:sidebar-simple" width="16" height="16"></iconify-icon>
|
|
30
30
|
</button>
|
|
31
31
|
<button
|
|
32
32
|
type="button"
|
|
@@ -5,8 +5,10 @@ class SimpleLivePreviewManager {
|
|
|
5
5
|
|
|
6
6
|
// DOM elements
|
|
7
7
|
this.container = document.getElementById(id);
|
|
8
|
-
this.
|
|
9
|
-
this.
|
|
8
|
+
this.hideSidebarBtn = document.getElementById(`${id}-hide-sidebar-btn`);
|
|
9
|
+
this.hideSidebarIcon = document.getElementById(`${id}-hide-sidebar-icon`);
|
|
10
|
+
this.floatingHideSidebarBtn = document.getElementById(`${id}-floating-hide-sidebar-btn`);
|
|
11
|
+
this.floatingHideSidebarIcon = document.getElementById(`${id}-floating-hide-sidebar-icon`);
|
|
10
12
|
this.refreshBtn = document.getElementById(`${id}-refresh-btn`);
|
|
11
13
|
this.urlInput = document.getElementById(`${id}-url-input`);
|
|
12
14
|
this.loadBtn = document.getElementById(`${id}-load-btn`);
|
|
@@ -16,7 +18,7 @@ class SimpleLivePreviewManager {
|
|
|
16
18
|
this.previewPort = this.iframe?.getAttribute('data-preview-port') || 5173;
|
|
17
19
|
|
|
18
20
|
// State
|
|
19
|
-
this.
|
|
21
|
+
this.isSidebarHidden = false;
|
|
20
22
|
|
|
21
23
|
this.init();
|
|
22
24
|
}
|
|
@@ -35,8 +37,9 @@ class SimpleLivePreviewManager {
|
|
|
35
37
|
}
|
|
36
38
|
|
|
37
39
|
setupEventListeners() {
|
|
38
|
-
// Hide
|
|
39
|
-
this.
|
|
40
|
+
// Hide sidebar toggle (both sidebar and floating button)
|
|
41
|
+
this.hideSidebarBtn?.addEventListener('click', () => this.toggleSidebarVisibility());
|
|
42
|
+
this.floatingHideSidebarBtn?.addEventListener('click', () => this.toggleSidebarVisibility());
|
|
40
43
|
|
|
41
44
|
// Refresh button
|
|
42
45
|
this.refreshBtn?.addEventListener('click', () => this.refreshIframe());
|
|
@@ -66,10 +69,10 @@ class SimpleLivePreviewManager {
|
|
|
66
69
|
e.preventDefault();
|
|
67
70
|
this.refreshIframe();
|
|
68
71
|
}
|
|
69
|
-
// Cmd/Ctrl + B to toggle
|
|
72
|
+
// Cmd/Ctrl + B to toggle sidebar panel
|
|
70
73
|
if ((e.metaKey || e.ctrlKey) && e.key === 'b') {
|
|
71
74
|
e.preventDefault();
|
|
72
|
-
this.
|
|
75
|
+
this.toggleSidebarVisibility();
|
|
73
76
|
}
|
|
74
77
|
});
|
|
75
78
|
|
|
@@ -126,38 +129,50 @@ class SimpleLivePreviewManager {
|
|
|
126
129
|
}
|
|
127
130
|
}
|
|
128
131
|
|
|
129
|
-
|
|
130
|
-
this.
|
|
132
|
+
toggleSidebarVisibility() {
|
|
133
|
+
this.isSidebarHidden = !this.isSidebarHidden;
|
|
131
134
|
|
|
132
|
-
const
|
|
135
|
+
const sidebarPane = document.getElementById('sidebar-pane');
|
|
133
136
|
const previewPane = document.getElementById(this.id);
|
|
134
137
|
|
|
135
|
-
if (
|
|
136
|
-
if (this.
|
|
137
|
-
// Hide
|
|
138
|
-
|
|
138
|
+
if (sidebarPane && previewPane) {
|
|
139
|
+
if (this.isSidebarHidden) {
|
|
140
|
+
// Hide sidebar pane and make preview full width
|
|
141
|
+
sidebarPane.style.display = 'none';
|
|
139
142
|
previewPane.classList.remove('flex-1');
|
|
140
143
|
previewPane.classList.add('w-full');
|
|
141
144
|
|
|
142
|
-
// Update button
|
|
143
|
-
if (this.
|
|
144
|
-
this.
|
|
145
|
+
// Update button icons and titles
|
|
146
|
+
if (this.hideSidebarIcon) {
|
|
147
|
+
this.hideSidebarIcon.setAttribute('icon', 'ph:sidebar-simple-fill');
|
|
145
148
|
}
|
|
146
|
-
if (this.
|
|
147
|
-
this.
|
|
149
|
+
if (this.floatingHideSidebarIcon) {
|
|
150
|
+
this.floatingHideSidebarIcon.setAttribute('icon', 'ph:sidebar-simple-fill');
|
|
151
|
+
}
|
|
152
|
+
if (this.hideSidebarBtn) {
|
|
153
|
+
this.hideSidebarBtn.setAttribute('title', 'Show Sidebar');
|
|
154
|
+
}
|
|
155
|
+
if (this.floatingHideSidebarBtn) {
|
|
156
|
+
this.floatingHideSidebarBtn.setAttribute('title', 'Show Sidebar');
|
|
148
157
|
}
|
|
149
158
|
} else {
|
|
150
|
-
// Show
|
|
151
|
-
|
|
159
|
+
// Show sidebar pane and restore original widths
|
|
160
|
+
sidebarPane.style.display = '';
|
|
152
161
|
previewPane.classList.remove('w-full');
|
|
153
162
|
previewPane.classList.add('flex-1');
|
|
154
163
|
|
|
155
|
-
// Update button
|
|
156
|
-
if (this.
|
|
157
|
-
this.
|
|
164
|
+
// Update button icons and titles
|
|
165
|
+
if (this.hideSidebarIcon) {
|
|
166
|
+
this.hideSidebarIcon.setAttribute('icon', 'ph:sidebar-simple');
|
|
167
|
+
}
|
|
168
|
+
if (this.floatingHideSidebarIcon) {
|
|
169
|
+
this.floatingHideSidebarIcon.setAttribute('icon', 'ph:sidebar-simple');
|
|
170
|
+
}
|
|
171
|
+
if (this.hideSidebarBtn) {
|
|
172
|
+
this.hideSidebarBtn.setAttribute('title', 'Hide Sidebar');
|
|
158
173
|
}
|
|
159
|
-
if (this.
|
|
160
|
-
this.
|
|
174
|
+
if (this.floatingHideSidebarBtn) {
|
|
175
|
+
this.floatingHideSidebarBtn.setAttribute('title', 'Hide Sidebar');
|
|
161
176
|
}
|
|
162
177
|
}
|
|
163
178
|
}
|
|
@@ -1109,6 +1109,10 @@ video {
|
|
|
1109
1109
|
position: relative;
|
|
1110
1110
|
}
|
|
1111
1111
|
|
|
1112
|
+
.z-50 {
|
|
1113
|
+
z-index: 50;
|
|
1114
|
+
}
|
|
1115
|
+
|
|
1112
1116
|
.mb-4 {
|
|
1113
1117
|
margin-bottom: 1rem;
|
|
1114
1118
|
}
|
|
@@ -1169,10 +1173,6 @@ video {
|
|
|
1169
1173
|
width: 2.5rem;
|
|
1170
1174
|
}
|
|
1171
1175
|
|
|
1172
|
-
.w-2\/5 {
|
|
1173
|
-
width: 40%;
|
|
1174
|
-
}
|
|
1175
|
-
|
|
1176
1176
|
.w-full {
|
|
1177
1177
|
width: 100%;
|
|
1178
1178
|
}
|
|
@@ -1253,10 +1253,6 @@ video {
|
|
|
1253
1253
|
border-width: 1px;
|
|
1254
1254
|
}
|
|
1255
1255
|
|
|
1256
|
-
.border-0 {
|
|
1257
|
-
border-width: 0px;
|
|
1258
|
-
}
|
|
1259
|
-
|
|
1260
1256
|
.border-2 {
|
|
1261
1257
|
border-width: 2px;
|
|
1262
1258
|
}
|
|
@@ -1274,6 +1270,16 @@ video {
|
|
|
1274
1270
|
border-color: rgb(60 60 60 / var(--tw-border-opacity, 1));
|
|
1275
1271
|
}
|
|
1276
1272
|
|
|
1273
|
+
.border-gray-300 {
|
|
1274
|
+
--tw-border-opacity: 1;
|
|
1275
|
+
border-color: rgb(209 213 219 / var(--tw-border-opacity, 1));
|
|
1276
|
+
}
|
|
1277
|
+
|
|
1278
|
+
.border-gray-400 {
|
|
1279
|
+
--tw-border-opacity: 1;
|
|
1280
|
+
border-color: rgb(156 163 175 / var(--tw-border-opacity, 1));
|
|
1281
|
+
}
|
|
1282
|
+
|
|
1277
1283
|
.border-green-600 {
|
|
1278
1284
|
--tw-border-opacity: 1;
|
|
1279
1285
|
border-color: rgb(22 163 74 / var(--tw-border-opacity, 1));
|
|
@@ -1458,6 +1464,12 @@ video {
|
|
|
1458
1464
|
box-shadow: var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow);
|
|
1459
1465
|
}
|
|
1460
1466
|
|
|
1467
|
+
.shadow-xl {
|
|
1468
|
+
--tw-shadow: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
|
|
1469
|
+
--tw-shadow-colored: 0 20px 25px -5px var(--tw-shadow-color), 0 8px 10px -6px var(--tw-shadow-color);
|
|
1470
|
+
box-shadow: var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow);
|
|
1471
|
+
}
|
|
1472
|
+
|
|
1461
1473
|
.filter {
|
|
1462
1474
|
filter: var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow);
|
|
1463
1475
|
}
|
|
@@ -1493,6 +1505,11 @@ video {
|
|
|
1493
1505
|
background-color: rgb(60 60 60 / var(--tw-bg-opacity, 1));
|
|
1494
1506
|
}
|
|
1495
1507
|
|
|
1508
|
+
.hover\:bg-gray-50:hover {
|
|
1509
|
+
--tw-bg-opacity: 1;
|
|
1510
|
+
background-color: rgb(249 250 251 / var(--tw-bg-opacity, 1));
|
|
1511
|
+
}
|
|
1512
|
+
|
|
1496
1513
|
.hover\:bg-gray-800:hover {
|
|
1497
1514
|
--tw-bg-opacity: 1;
|
|
1498
1515
|
background-color: rgb(31 41 55 / var(--tw-bg-opacity, 1));
|
|
@@ -1508,6 +1525,12 @@ video {
|
|
|
1508
1525
|
color: rgb(255 255 255 / var(--tw-text-opacity, 1));
|
|
1509
1526
|
}
|
|
1510
1527
|
|
|
1528
|
+
.hover\:shadow-2xl:hover {
|
|
1529
|
+
--tw-shadow: 0 25px 50px -12px rgb(0 0 0 / 0.25);
|
|
1530
|
+
--tw-shadow-colored: 0 25px 50px -12px var(--tw-shadow-color);
|
|
1531
|
+
box-shadow: var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow);
|
|
1532
|
+
}
|
|
1533
|
+
|
|
1511
1534
|
.focus\:outline-none:focus {
|
|
1512
1535
|
outline: 2px solid transparent;
|
|
1513
1536
|
outline-offset: 2px;
|