UNPKG

@oberoncms/core

Version:

OberonCMS is a cloud deployable CMS written in typescript based on the Puck visual editor

55 lines (54 loc) 1.33 kB
"use client"; import { jsxs, jsx } from "react/jsx-runtime"; import { Button } from "@tohuhono/ui/button"; import { useState } from "react"; import { createUsePuck, useGetPuck } from "@puckeditor/core"; import { Menu } from "../menu.js"; const usePuck = createUsePuck(); const Header = ({ path, onPublish }) => { const title = usePuck((s) => s.appState.data.root.title); const getPuck = useGetPuck(); const [isPublishing, setIsPublishing] = useState(false); return /* @__PURE__ */ jsxs(Menu, { title, path, children: [ /* @__PURE__ */ jsx( Button, { onClick: () => window.open(`/cms/preview${path}`, "_blank")?.focus(), variant: "outline", size: "sm", children: "Preview" } ), /* @__PURE__ */ jsx( Button, { onClick: () => window.open(path, "_blank")?.focus(), variant: "outline", size: "sm", children: "View" } ), /* @__PURE__ */ jsx( Button, { disabled: isPublishing, onClick: async () => { setIsPublishing(true); try { await onPublish(getPuck().appState.data); } finally { setIsPublishing(false); } }, size: "sm", children: "Publish" } ) ] }); }; export { Header };