Skip to content

Commit c7f15c1

Browse files
committed
feat: enhance IconLogoEditorClient with shared logo state management and update AppShell to include ShareButton
1 parent adbb68e commit c7f15c1

3 files changed

Lines changed: 22 additions & 4 deletions

File tree

src/app/iconlogo/editor/IconLogoEditorClient.tsx

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,28 @@
11
"use client";
22

3+
import { useEffect, useState } from "react";
4+
import type { LogoState } from "@/iconlogo/domain/logo/logo.types";
5+
import { sanitizeLogoState } from "@/iconlogo/domain/logo/logo.validators";
36
import TanStackQueryProvider from "@/iconlogo/integrations/tanstack-query/root-provider";
47
import { AppShell } from "@/iconlogo/features/editor/AppShell";
58

69
export default function IconLogoEditorClient() {
10+
const [sharedLogo, setSharedLogo] = useState<LogoState | null>(null);
11+
12+
useEffect(() => {
13+
const raw = new URLSearchParams(window.location.search).get("s");
14+
if (!raw) return;
15+
try {
16+
setSharedLogo(sanitizeLogoState(JSON.parse(decodeURIComponent(raw))));
17+
} catch {
18+
setSharedLogo(null);
19+
}
20+
}, []);
21+
722
return (
823
<TanStackQueryProvider>
924
<main className="min-h-screen bg-black text-white overflow-hidden">
10-
<AppShell />
25+
<AppShell sharedLogo={sharedLogo} />
1126
</main>
1227
</TanStackQueryProvider>
1328
);
Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
import { useLogoStore } from "#/store/logo-store";
2-
import { createShareFn } from "#/server/share.create";
32

43
export async function createShareLink(): Promise<string> {
54
const logo = useLogoStore.getState().present;
6-
const result = await createShareFn({ data: { logoState: logo } });
7-
return `${window.location.origin}/editor?s=${result.id}`;
5+
const payload = encodeURIComponent(JSON.stringify(logo));
6+
return `${window.location.origin}/iconlogo/editor?s=${payload}`;
87
}

src/iconlogo/features/editor/AppShell.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { Tooltip } from "@heroui/react";
44
import type { LogoState } from "#/domain/logo/logo.types";
55
import { loadLogoFromState } from "#/commands/logo/load-logo";
66
import { CollectionsButton } from "#/features/collections/CollectionsButton";
7+
import { ShareButton } from "#/features/share/ShareButton";
78
import { EditorPage } from "./EditorPage";
89
import { FABs } from "./FABs";
910
import { MobileTopBar } from "./MobileTopBar";
@@ -90,6 +91,9 @@ export function AppShell({
9091
</Tooltip.Content>
9192
</Tooltip>
9293
</motion.div>
94+
<motion.div variants={itemVariants}>
95+
<ShareButton />
96+
</motion.div>
9397
<motion.div variants={itemVariants}>
9498
<CollectionsButton />
9599
</motion.div>

0 commit comments

Comments
 (0)