feat: add better provider support, icons, regen, and a lot more
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
const SIDENAV_CONTEXT_KEY = Symbol('sidenav-context');
|
||||
|
||||
export interface SidenavContext {
|
||||
isHovered: Readonly<Ref<boolean>>;
|
||||
sidebarWidth: Readonly<Ref<number>>;
|
||||
isOpen: Readonly<Ref<boolean>>;
|
||||
close: () => void;
|
||||
}
|
||||
|
||||
export const provideSidenavContext = (context: SidenavContext) => {
|
||||
provide(SIDENAV_CONTEXT_KEY, context);
|
||||
};
|
||||
|
||||
export const useSidenavContext = (): SidenavContext => {
|
||||
const context = inject<SidenavContext>(SIDENAV_CONTEXT_KEY);
|
||||
if (!context) {
|
||||
throw new Error('useSidenavContext must be used within a Sidenav provider');
|
||||
}
|
||||
return context;
|
||||
};
|
||||
Reference in New Issue
Block a user