update product details
This commit is contained in:
44
app/_components/editor-shell.tsx
Normal file
44
app/_components/editor-shell.tsx
Normal file
@@ -0,0 +1,44 @@
|
||||
"use client";
|
||||
|
||||
import { useMemo } from "react";
|
||||
import { Editor } from "@reacteditor/core";
|
||||
import createTailwindCdnPlugin from "@reacteditor/plugin-tailwind-cdn";
|
||||
import type { UserConfig } from "@/config/types";
|
||||
|
||||
export type EditorShellProps = {
|
||||
config: UserConfig;
|
||||
data: any;
|
||||
routeKey?: string;
|
||||
};
|
||||
|
||||
export function EditorShell({ config, data, routeKey }: EditorShellProps) {
|
||||
const plugins = useMemo(() => [createTailwindCdnPlugin()], []);
|
||||
|
||||
const handlePublish = async (nextData: any, route?: any) => {
|
||||
const resolved = route ?? (routeKey ? { key: routeKey } : undefined);
|
||||
console.log({
|
||||
type: "PUBLISH",
|
||||
data: { data: nextData, route: JSON.stringify(resolved) },
|
||||
});
|
||||
if (typeof window !== "undefined" && window.parent !== window) {
|
||||
window.parent.postMessage(
|
||||
{ type: "PUBLISH", data: { data: nextData, route: resolved } },
|
||||
"*",
|
||||
);
|
||||
}
|
||||
await new Promise((resolve) => setTimeout(resolve, 1000));
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="h-screen w-screen">
|
||||
<Editor
|
||||
config={config as any}
|
||||
data={data}
|
||||
plugins={plugins}
|
||||
iframe={{ enabled: true }}
|
||||
ui={{ leftSideBarVisible: false }}
|
||||
onPublish={handlePublish}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
10
app/collections/[handle]/page.tsx
Normal file
10
app/collections/[handle]/page.tsx
Normal file
@@ -0,0 +1,10 @@
|
||||
"use client";
|
||||
|
||||
import { Render } from "@reacteditor/core";
|
||||
import { collectionsConfig } from "@/config/configs";
|
||||
import schema from "@/app.schema.json";
|
||||
|
||||
export default function CollectionPage() {
|
||||
const data = (schema as any)["/collections/:handle"];
|
||||
return <Render config={collectionsConfig as any} data={data} />;
|
||||
}
|
||||
16
app/editor/collections/[handle]/page.tsx
Normal file
16
app/editor/collections/[handle]/page.tsx
Normal file
@@ -0,0 +1,16 @@
|
||||
"use client";
|
||||
|
||||
import { EditorShell } from "@/app/_components/editor-shell";
|
||||
import { collectionsConfig } from "@/config/configs";
|
||||
import schema from "@/app.schema.json";
|
||||
|
||||
export default function CollectionEditorPage() {
|
||||
const data = (schema as any)["/collections/:handle"];
|
||||
return (
|
||||
<EditorShell
|
||||
config={collectionsConfig}
|
||||
data={data}
|
||||
routeKey="/collections/:handle"
|
||||
/>
|
||||
);
|
||||
}
|
||||
10
app/editor/page.tsx
Normal file
10
app/editor/page.tsx
Normal file
@@ -0,0 +1,10 @@
|
||||
"use client";
|
||||
|
||||
import { EditorShell } from "@/app/_components/editor-shell";
|
||||
import { homeConfig } from "@/config/configs";
|
||||
import schema from "@/app.schema.json";
|
||||
|
||||
export default function HomeEditorPage() {
|
||||
const data = (schema as any)["/"];
|
||||
return <EditorShell config={homeConfig} data={data} routeKey="/" />;
|
||||
}
|
||||
16
app/editor/products/[handle]/page.tsx
Normal file
16
app/editor/products/[handle]/page.tsx
Normal file
@@ -0,0 +1,16 @@
|
||||
"use client";
|
||||
|
||||
import { EditorShell } from "@/app/_components/editor-shell";
|
||||
import { productConfig } from "@/config/configs";
|
||||
import schema from "@/app.schema.json";
|
||||
|
||||
export default function ProductEditorPage() {
|
||||
const data = (schema as any)["/products/:handle"];
|
||||
return (
|
||||
<EditorShell
|
||||
config={productConfig}
|
||||
data={data}
|
||||
routeKey="/products/:handle"
|
||||
/>
|
||||
);
|
||||
}
|
||||
10
app/editor/search/page.tsx
Normal file
10
app/editor/search/page.tsx
Normal file
@@ -0,0 +1,10 @@
|
||||
"use client";
|
||||
|
||||
import { EditorShell } from "@/app/_components/editor-shell";
|
||||
import { searchConfig } from "@/config/configs";
|
||||
import schema from "@/app.schema.json";
|
||||
|
||||
export default function SearchEditorPage() {
|
||||
const data = (schema as any)["/search"];
|
||||
return <EditorShell config={searchConfig} data={data} routeKey="/search" />;
|
||||
}
|
||||
157
app/globals.css
Normal file
157
app/globals.css
Normal file
@@ -0,0 +1,157 @@
|
||||
@import "tailwindcss";
|
||||
@import "tw-animate-css";
|
||||
|
||||
@custom-variant dark (&:is(.dark *));
|
||||
|
||||
@theme inline {
|
||||
--font-family-heading: var(--font-header);
|
||||
--font-family-header: var(--font-header);
|
||||
--font-family-body: var(--font-body);
|
||||
|
||||
--color-background: var(--background);
|
||||
--color-foreground: var(--foreground);
|
||||
--color-card: var(--card);
|
||||
--color-card-foreground: var(--card-foreground);
|
||||
--color-popover: var(--popover);
|
||||
--color-popover-foreground: var(--popover-foreground);
|
||||
--color-primary: var(--primary);
|
||||
--color-primary-foreground: var(--primary-foreground);
|
||||
--color-secondary: var(--secondary);
|
||||
--color-secondary-foreground: var(--secondary-foreground);
|
||||
--color-muted: var(--muted);
|
||||
--color-muted-foreground: var(--muted-foreground);
|
||||
--color-accent: var(--accent);
|
||||
--color-accent-foreground: var(--accent-foreground);
|
||||
--color-destructive: var(--destructive);
|
||||
--color-destructive-foreground: var(--destructive-foreground);
|
||||
--color-border: var(--border);
|
||||
--color-input: var(--input);
|
||||
--color-ring: var(--ring);
|
||||
|
||||
--radius-sm: calc(var(--radius) * 0.5);
|
||||
--radius-md: calc(var(--radius) * 0.75);
|
||||
--radius-lg: var(--radius);
|
||||
--radius-xl: calc(var(--radius) * 1.5);
|
||||
|
||||
--animate-marquee: marquee var(--duration) infinite linear;
|
||||
--animate-marquee-vertical: marquee-vertical var(--duration) linear infinite;
|
||||
|
||||
@keyframes marquee {
|
||||
from { transform: translateX(0); }
|
||||
to { transform: translateX(calc(-100% - var(--gap))); }
|
||||
}
|
||||
@keyframes marquee-vertical {
|
||||
from { transform: translateY(0); }
|
||||
to { transform: translateY(calc(-100% - var(--gap))); }
|
||||
}
|
||||
--font-heading: var(--font-sans);
|
||||
--font-sans: 'Geist Variable', sans-serif;
|
||||
--color-sidebar-ring: var(--sidebar-ring);
|
||||
--color-sidebar-border: var(--sidebar-border);
|
||||
--color-sidebar-accent-foreground: var(--sidebar-accent-foreground);
|
||||
--color-sidebar-accent: var(--sidebar-accent);
|
||||
--color-sidebar-primary-foreground: var(--sidebar-primary-foreground);
|
||||
--color-sidebar-primary: var(--sidebar-primary);
|
||||
--color-sidebar-foreground: var(--sidebar-foreground);
|
||||
--color-sidebar: var(--sidebar);
|
||||
--color-chart-5: var(--chart-5);
|
||||
--color-chart-4: var(--chart-4);
|
||||
--color-chart-3: var(--chart-3);
|
||||
--color-chart-2: var(--chart-2);
|
||||
--color-chart-1: var(--chart-1);
|
||||
--radius-2xl: calc(var(--radius) * 2);
|
||||
--radius-3xl: calc(var(--radius) * 3);
|
||||
--radius-4xl: calc(var(--radius) * 4)
|
||||
}
|
||||
|
||||
:root {
|
||||
--radius: 0.625rem;
|
||||
--font-header: system-ui, -apple-system, sans-serif;
|
||||
--font-body: system-ui, -apple-system, sans-serif;
|
||||
--background: oklch(1 0 0);
|
||||
--foreground: oklch(0.145 0 0);
|
||||
--card: oklch(1 0 0);
|
||||
--card-foreground: oklch(0.145 0 0);
|
||||
--popover: oklch(1 0 0);
|
||||
--popover-foreground: oklch(0.145 0 0);
|
||||
--primary: oklch(0.205 0 0);
|
||||
--primary-foreground: oklch(0.985 0 0);
|
||||
--secondary: oklch(0.97 0 0);
|
||||
--secondary-foreground: oklch(0.205 0 0);
|
||||
--muted: oklch(0.97 0 0);
|
||||
--muted-foreground: oklch(0.556 0 0);
|
||||
--accent: oklch(0.97 0 0);
|
||||
--accent-foreground: oklch(0.205 0 0);
|
||||
--destructive: oklch(0.577 0.245 27.325);
|
||||
--destructive-foreground: #fafafa;
|
||||
--border: oklch(0.922 0 0);
|
||||
--input: oklch(0.922 0 0);
|
||||
--ring: oklch(0.708 0 0);
|
||||
--chart-1: oklch(0.87 0 0);
|
||||
--chart-2: oklch(0.556 0 0);
|
||||
--chart-3: oklch(0.439 0 0);
|
||||
--chart-4: oklch(0.371 0 0);
|
||||
--chart-5: oklch(0.269 0 0);
|
||||
--sidebar: oklch(0.985 0 0);
|
||||
--sidebar-foreground: oklch(0.145 0 0);
|
||||
--sidebar-primary: oklch(0.205 0 0);
|
||||
--sidebar-primary-foreground: oklch(0.985 0 0);
|
||||
--sidebar-accent: oklch(0.97 0 0);
|
||||
--sidebar-accent-foreground: oklch(0.205 0 0);
|
||||
--sidebar-border: oklch(0.922 0 0);
|
||||
--sidebar-ring: oklch(0.708 0 0);
|
||||
}
|
||||
|
||||
*,
|
||||
::after,
|
||||
::before,
|
||||
::backdrop,
|
||||
::file-selector-button {
|
||||
border-color: var(--border);
|
||||
}
|
||||
|
||||
@layer base {
|
||||
* { @apply outline-ring/50; }
|
||||
html, body { background-color: var(--background); color: var(--foreground); }
|
||||
body {
|
||||
font-family: var(--font-body), "Apple Color Emoji", "Segoe UI Emoji";
|
||||
margin: 0;
|
||||
@apply bg-background text-foreground;
|
||||
}
|
||||
html {
|
||||
@apply font-sans;}
|
||||
}
|
||||
|
||||
.dark {
|
||||
--background: oklch(0.145 0 0);
|
||||
--foreground: oklch(0.985 0 0);
|
||||
--card: oklch(0.205 0 0);
|
||||
--card-foreground: oklch(0.985 0 0);
|
||||
--popover: oklch(0.205 0 0);
|
||||
--popover-foreground: oklch(0.985 0 0);
|
||||
--primary: oklch(0.922 0 0);
|
||||
--primary-foreground: oklch(0.205 0 0);
|
||||
--secondary: oklch(0.269 0 0);
|
||||
--secondary-foreground: oklch(0.985 0 0);
|
||||
--muted: oklch(0.269 0 0);
|
||||
--muted-foreground: oklch(0.708 0 0);
|
||||
--accent: oklch(0.269 0 0);
|
||||
--accent-foreground: oklch(0.985 0 0);
|
||||
--destructive: oklch(0.704 0.191 22.216);
|
||||
--border: oklch(1 0 0 / 10%);
|
||||
--input: oklch(1 0 0 / 15%);
|
||||
--ring: oklch(0.556 0 0);
|
||||
--chart-1: oklch(0.87 0 0);
|
||||
--chart-2: oklch(0.556 0 0);
|
||||
--chart-3: oklch(0.439 0 0);
|
||||
--chart-4: oklch(0.371 0 0);
|
||||
--chart-5: oklch(0.269 0 0);
|
||||
--sidebar: oklch(0.205 0 0);
|
||||
--sidebar-foreground: oklch(0.985 0 0);
|
||||
--sidebar-primary: oklch(0.488 0.243 264.376);
|
||||
--sidebar-primary-foreground: oklch(0.985 0 0);
|
||||
--sidebar-accent: oklch(0.269 0 0);
|
||||
--sidebar-accent-foreground: oklch(0.985 0 0);
|
||||
--sidebar-border: oklch(1 0 0 / 10%);
|
||||
--sidebar-ring: oklch(0.556 0 0);
|
||||
}
|
||||
20
app/layout.tsx
Normal file
20
app/layout.tsx
Normal file
@@ -0,0 +1,20 @@
|
||||
import type { ReactNode } from "react";
|
||||
import "@reacteditor/core/react-editor.css";
|
||||
import "@reacteditor/plugin-media/styles.css";
|
||||
import "@reacteditor/plugin-ai/styles.css";
|
||||
import "./globals.css";
|
||||
import { Providers } from "./providers";
|
||||
|
||||
export const metadata = {
|
||||
title: "Shopify Storefront",
|
||||
};
|
||||
|
||||
export default function RootLayout({ children }: { children: ReactNode }) {
|
||||
return (
|
||||
<html lang="en">
|
||||
<body>
|
||||
<Providers>{children}</Providers>
|
||||
</body>
|
||||
</html>
|
||||
);
|
||||
}
|
||||
10
app/page.tsx
Normal file
10
app/page.tsx
Normal file
@@ -0,0 +1,10 @@
|
||||
"use client";
|
||||
|
||||
import { Render } from "@reacteditor/core";
|
||||
import { homeConfig } from "@/config/configs";
|
||||
import schema from "@/app.schema.json";
|
||||
|
||||
export default function HomePage() {
|
||||
const data = (schema as any)["/"];
|
||||
return <Render config={homeConfig as any} data={data} />;
|
||||
}
|
||||
10
app/products/[handle]/page.tsx
Normal file
10
app/products/[handle]/page.tsx
Normal file
@@ -0,0 +1,10 @@
|
||||
"use client";
|
||||
|
||||
import { Render } from "@reacteditor/core";
|
||||
import { productConfig } from "@/config/configs";
|
||||
import schema from "@/app.schema.json";
|
||||
|
||||
export default function ProductPage() {
|
||||
const data = (schema as any)["/products/:handle"];
|
||||
return <Render config={productConfig as any} data={data} />;
|
||||
}
|
||||
21
app/providers.tsx
Normal file
21
app/providers.tsx
Normal file
@@ -0,0 +1,21 @@
|
||||
"use client";
|
||||
|
||||
import { useEffect, useState, type ReactNode } from "react";
|
||||
import { ShopifyProvider } from "@/contexts/shopify-context";
|
||||
|
||||
const SHOPIFY_DOMAIN =
|
||||
process.env.NEXT_PUBLIC_SHOPIFY_DOMAIN ?? "mock.shop";
|
||||
const STOREFRONT_TOKEN =
|
||||
process.env.NEXT_PUBLIC_SHOPIFY_STOREFRONT_ACCESS_TOKEN ?? "";
|
||||
|
||||
export function Providers({ children }: { children: ReactNode }) {
|
||||
const [mounted, setMounted] = useState(false);
|
||||
useEffect(() => setMounted(true), []);
|
||||
if (!mounted) return null;
|
||||
|
||||
return (
|
||||
<ShopifyProvider domain={SHOPIFY_DOMAIN} token={STOREFRONT_TOKEN}>
|
||||
{children}
|
||||
</ShopifyProvider>
|
||||
);
|
||||
}
|
||||
10
app/search/page.tsx
Normal file
10
app/search/page.tsx
Normal file
@@ -0,0 +1,10 @@
|
||||
"use client";
|
||||
|
||||
import { Render } from "@reacteditor/core";
|
||||
import { searchConfig } from "@/config/configs";
|
||||
import schema from "@/app.schema.json";
|
||||
|
||||
export default function SearchPage() {
|
||||
const data = (schema as any)["/search"];
|
||||
return <Render config={searchConfig as any} data={data} />;
|
||||
}
|
||||
Reference in New Issue
Block a user