chore: clean up repo for public release
- Remove BMAD framework, IDE configs, dev screenshots, test files, internal docs, and backup files - Rename keep-notes/ to memento-note/ - Update all references from keep-notes to memento-note - Add Apache 2.0 license with Commons Clause (non-commercial restriction) - Add clean .gitignore and .env.docker.example
This commit is contained in:
36
memento-note/context/home-view-context.tsx
Normal file
36
memento-note/context/home-view-context.tsx
Normal file
@@ -0,0 +1,36 @@
|
||||
'use client'
|
||||
|
||||
import { createContext, useContext, useMemo, useState, type ReactNode } from 'react'
|
||||
|
||||
export type HomeUiControls = {
|
||||
isTabsMode: boolean
|
||||
openNoteComposer: () => void
|
||||
}
|
||||
|
||||
type Ctx = {
|
||||
controls: HomeUiControls | null
|
||||
setControls: (c: HomeUiControls | null) => void
|
||||
}
|
||||
|
||||
const HomeViewContext = createContext<Ctx | null>(null)
|
||||
|
||||
export function HomeViewProvider({ children }: { children: ReactNode }) {
|
||||
const [controls, setControls] = useState<HomeUiControls | null>(null)
|
||||
const value = useMemo(() => ({ controls, setControls }), [controls])
|
||||
|
||||
return <HomeViewContext.Provider value={value}>{children}</HomeViewContext.Provider>
|
||||
}
|
||||
|
||||
/** Enregistré par la page d’accueil ; la sidebar lit `controls` */
|
||||
export function useHomeView() {
|
||||
const ctx = useContext(HomeViewContext)
|
||||
if (!ctx) {
|
||||
throw new Error('useHomeView must be used within HomeViewProvider')
|
||||
}
|
||||
return ctx
|
||||
}
|
||||
|
||||
/** Sidebar / shells : ne pas planter si hors provider */
|
||||
export function useHomeViewOptional(): Ctx | null {
|
||||
return useContext(HomeViewContext)
|
||||
}
|
||||
Reference in New Issue
Block a user