@toriistudio/v0-playground 0.2.8 → 0.2.10
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/index.js +18 -0
- package/dist/index.mjs +18 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -39,6 +39,7 @@ module.exports = __toCommonJS(src_exports);
|
|
|
39
39
|
|
|
40
40
|
// src/components/Playground/Playground.tsx
|
|
41
41
|
var import_react6 = require("react");
|
|
42
|
+
var import_lucide_react4 = require("lucide-react");
|
|
42
43
|
|
|
43
44
|
// src/context/ResizableLayout.tsx
|
|
44
45
|
var import_react = require("react");
|
|
@@ -769,6 +770,7 @@ var import_jsx_runtime11 = require("react/jsx-runtime");
|
|
|
769
770
|
var NO_CONTROLS_PARAM = "nocontrols";
|
|
770
771
|
function Playground({ children }) {
|
|
771
772
|
const [isHydrated, setIsHydrated] = (0, import_react6.useState)(false);
|
|
773
|
+
const [copied, setCopied] = (0, import_react6.useState)(false);
|
|
772
774
|
(0, import_react6.useEffect)(() => {
|
|
773
775
|
setIsHydrated(true);
|
|
774
776
|
}, []);
|
|
@@ -776,8 +778,24 @@ function Playground({ children }) {
|
|
|
776
778
|
if (typeof window === "undefined") return false;
|
|
777
779
|
return new URLSearchParams(window.location.search).get(NO_CONTROLS_PARAM) === "true";
|
|
778
780
|
}, []);
|
|
781
|
+
const handleCopy = () => {
|
|
782
|
+
navigator.clipboard.writeText(window.location.href);
|
|
783
|
+
setCopied(true);
|
|
784
|
+
setTimeout(() => setCopied(false), 2e3);
|
|
785
|
+
};
|
|
779
786
|
if (!isHydrated) return null;
|
|
780
787
|
return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(ResizableLayout, { hideControls, children: /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(ControlsProvider, { children: [
|
|
788
|
+
hideControls && /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(
|
|
789
|
+
"button",
|
|
790
|
+
{
|
|
791
|
+
onClick: handleCopy,
|
|
792
|
+
className: "absolute top-4 right-4 z-50 flex items-center gap-1 rounded bg-black/70 px-3 py-1 text-white hover:bg-black",
|
|
793
|
+
children: [
|
|
794
|
+
copied ? /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_lucide_react4.Check, { size: 16 }) : /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_lucide_react4.Copy, { size: 16 }),
|
|
795
|
+
copied ? "Copied!" : "Share"
|
|
796
|
+
]
|
|
797
|
+
}
|
|
798
|
+
),
|
|
781
799
|
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)(PreviewContainer_default, { hideControls, children }),
|
|
782
800
|
!hideControls && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(ControlPanel_default, {})
|
|
783
801
|
] }) });
|
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
// src/components/Playground/Playground.tsx
|
|
2
2
|
import { useEffect as useEffect4, useMemo as useMemo3, useState as useState5 } from "react";
|
|
3
|
+
import { Check as Check3, Copy as Copy2 } from "lucide-react";
|
|
3
4
|
|
|
4
5
|
// src/context/ResizableLayout.tsx
|
|
5
6
|
import {
|
|
@@ -743,6 +744,7 @@ import { jsx as jsx11, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
|
743
744
|
var NO_CONTROLS_PARAM = "nocontrols";
|
|
744
745
|
function Playground({ children }) {
|
|
745
746
|
const [isHydrated, setIsHydrated] = useState5(false);
|
|
747
|
+
const [copied, setCopied] = useState5(false);
|
|
746
748
|
useEffect4(() => {
|
|
747
749
|
setIsHydrated(true);
|
|
748
750
|
}, []);
|
|
@@ -750,8 +752,24 @@ function Playground({ children }) {
|
|
|
750
752
|
if (typeof window === "undefined") return false;
|
|
751
753
|
return new URLSearchParams(window.location.search).get(NO_CONTROLS_PARAM) === "true";
|
|
752
754
|
}, []);
|
|
755
|
+
const handleCopy = () => {
|
|
756
|
+
navigator.clipboard.writeText(window.location.href);
|
|
757
|
+
setCopied(true);
|
|
758
|
+
setTimeout(() => setCopied(false), 2e3);
|
|
759
|
+
};
|
|
753
760
|
if (!isHydrated) return null;
|
|
754
761
|
return /* @__PURE__ */ jsx11(ResizableLayout, { hideControls, children: /* @__PURE__ */ jsxs5(ControlsProvider, { children: [
|
|
762
|
+
hideControls && /* @__PURE__ */ jsxs5(
|
|
763
|
+
"button",
|
|
764
|
+
{
|
|
765
|
+
onClick: handleCopy,
|
|
766
|
+
className: "absolute top-4 right-4 z-50 flex items-center gap-1 rounded bg-black/70 px-3 py-1 text-white hover:bg-black",
|
|
767
|
+
children: [
|
|
768
|
+
copied ? /* @__PURE__ */ jsx11(Check3, { size: 16 }) : /* @__PURE__ */ jsx11(Copy2, { size: 16 }),
|
|
769
|
+
copied ? "Copied!" : "Share"
|
|
770
|
+
]
|
|
771
|
+
}
|
|
772
|
+
),
|
|
755
773
|
/* @__PURE__ */ jsx11(PreviewContainer_default, { hideControls, children }),
|
|
756
774
|
!hideControls && /* @__PURE__ */ jsx11(ControlPanel_default, {})
|
|
757
775
|
] }) });
|