Initial import

This commit is contained in:
how2ice
2026-04-21 03:33:23 +09:00
commit 9e4b70f1f1
495 changed files with 94680 additions and 0 deletions

View File

@@ -0,0 +1,49 @@
import {
createContext,
useContext,
useMemo,
useState,
type PropsWithChildren,
} from 'react';
import type { AppPageDescriptor, AppStoreSnapshot } from '../types';
type AppStoreContextValue = AppStoreSnapshot & {
setCurrentPage: (page: AppPageDescriptor) => void;
setFocusedComponentId: (focusedComponentId: string | null) => void;
};
const defaultPage: AppPageDescriptor = {
id: 'plans:all',
title: '메모 / Plan',
topMenu: 'plans',
section: 'all',
};
const AppStoreContext = createContext<AppStoreContextValue | null>(null);
export function AppStoreProvider({ children }: PropsWithChildren) {
const [currentPage, setCurrentPage] = useState<AppPageDescriptor>(defaultPage);
const [focusedComponentId, setFocusedComponentId] = useState<string | null>(null);
const value = useMemo<AppStoreContextValue>(
() => ({
currentPage,
focusedComponentId,
setCurrentPage,
setFocusedComponentId,
}),
[currentPage, focusedComponentId],
);
return <AppStoreContext.Provider value={value}>{children}</AppStoreContext.Provider>;
}
export function useAppStoreContext() {
const context = useContext(AppStoreContext);
if (!context) {
throw new Error('useAppStoreContext must be used within an AppStoreProvider.');
}
return context;
}

View File

@@ -0,0 +1,5 @@
import { useAppStoreContext } from '../context/AppStoreContext';
export function useAppStore() {
return useAppStoreContext();
}

3
src/store/appStore/index.ts Executable file
View File

@@ -0,0 +1,3 @@
export * from './context/AppStoreContext';
export * from './hooks/useAppStore';
export * from './types';

View File

@@ -0,0 +1,11 @@
export type AppPageDescriptor = {
id: string;
title: string;
topMenu: 'docs' | 'apis' | 'plans' | 'chat' | 'play';
section: string;
};
export type AppStoreSnapshot = {
currentPage: AppPageDescriptor;
focusedComponentId: string | null;
};

1
src/store/index.ts Executable file
View File

@@ -0,0 +1 @@
export * from './appStore';