feat: implement Figlet, Pastel, and Unit tools with a unified layout
- 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
This commit is contained in:
36
components/layout/SidebarProvider.tsx
Normal file
36
components/layout/SidebarProvider.tsx
Normal file
@@ -0,0 +1,36 @@
|
||||
'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;
|
||||
}
|
||||
Reference in New Issue
Block a user