- Add Figlet text converter with font selection and history - Add Pastel color palette generator and manipulation suite - Add comprehensive Units converter with category-based logic - Introduce AppShell with Sidebar and Header for navigation - Modernize theme system with CSS variables and new animations - Update project configuration and dependencies
37 lines
1.0 KiB
TypeScript
37 lines
1.0 KiB
TypeScript
'use client';
|
|
|
|
import * as React from 'react';
|
|
|
|
interface SidebarContextType {
|
|
isOpen: boolean;
|
|
isCollapsed: boolean;
|
|
toggle: () => void;
|
|
toggleCollapse: () => void;
|
|
close: () => void;
|
|
}
|
|
|
|
const SidebarContext = React.createContext<SidebarContextType | undefined>(undefined);
|
|
|
|
export function SidebarProvider({ children }: { children: React.ReactNode }) {
|
|
const [isOpen, setIsOpen] = React.useState(false);
|
|
const [isCollapsed, setIsCollapsed] = React.useState(false);
|
|
|
|
const toggle = React.useCallback(() => setIsOpen((prev) => !prev), []);
|
|
const toggleCollapse = React.useCallback(() => setIsCollapsed((prev) => !prev), []);
|
|
const close = React.useCallback(() => setIsOpen(false), []);
|
|
|
|
return (
|
|
<SidebarContext.Provider value={{ isOpen, isCollapsed, toggle, toggleCollapse, close }}>
|
|
{children}
|
|
</SidebarContext.Provider>
|
|
);
|
|
}
|
|
|
|
export function useSidebar() {
|
|
const context = React.useContext(SidebarContext);
|
|
if (!context) {
|
|
throw new Error('useSidebar must be used within a SidebarProvider');
|
|
}
|
|
return context;
|
|
}
|