feat: port TechLog Studio shell and indexes

This commit is contained in:
DongHyeonka
2026-08-15 23:29:32 +09:00
parent 2b6fa42620
commit 887f5e6eb1
15 changed files with 1187 additions and 0 deletions
@@ -0,0 +1,45 @@
import {
type ReactNode,
useCallback,
useMemo,
useState,
} from "react";
import type { StudioGateway } from "../../application/ports/studio-gateway.ts";
import { StudioContext, type StudioContextValue } from "./use-studio.ts";
type StudioProviderProps = Readonly<{
children: ReactNode;
createGateway: () => StudioGateway;
navigate?: (href: string) => void;
}>;
function defaultNavigate(href: string): void {
window.history.pushState({}, "", href);
window.dispatchEvent(new PopStateEvent("popstate"));
}
export function StudioProvider({
children,
createGateway,
navigate = defaultNavigate,
}: StudioProviderProps) {
const [gateway] = useState<StudioGateway>(() => createGateway());
const [requestAnnouncement, setRequestAnnouncement] = useState("");
const navigateInternal = useCallback((href: string) => navigate(href), [navigate]);
const value = useMemo<StudioContextValue>(
() => ({
gateway,
requestAnnouncement,
setRequestAnnouncement,
navigateInternal,
}),
[gateway, navigateInternal, requestAnnouncement],
);
return (
<StudioContext.Provider value={value}>
<div className="studio-app">{children}</div>
</StudioContext.Provider>
);
}