feat(sidebar): add SidebarContext for composable sidebar
Create context and hook to share collapsed state and toggle callback between compound component sub-components. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
14
src/design-system/layout/Sidebar/SidebarContext.ts
Normal file
14
src/design-system/layout/Sidebar/SidebarContext.ts
Normal file
@@ -0,0 +1,14 @@
|
||||
import { createContext, useContext } from 'react'
|
||||
|
||||
export interface SidebarContextValue {
|
||||
collapsed: boolean
|
||||
onCollapseToggle?: () => void
|
||||
}
|
||||
|
||||
export const SidebarContext = createContext<SidebarContextValue>({
|
||||
collapsed: false,
|
||||
})
|
||||
|
||||
export function useSidebarContext(): SidebarContextValue {
|
||||
return useContext(SidebarContext)
|
||||
}
|
||||
Reference in New Issue
Block a user