Files
tweakcn/components/editor/section-context.tsx
T
Sahaj Jain d51c6c8620 feat: implement color control focus feature with context and highlight animation
- Added SectionContext to manage expanded state for ControlSection components.
- Enhanced ColorPicker to support programmatic focus and highlight animations.
- Introduced useColorControlFocus hook for managing color control references.
- Updated ColorPreview to utilize new focus functionality for color items.
- Added name prop to ColorPicker for identifying color controls in the focus store.
2025-06-24 02:06:49 +05:30

17 lines
555 B
TypeScript

import { createContext } from "react";
interface SectionContextType {
/** Whether the parent ControlSection is currently expanded */
isExpanded: boolean;
/** Set the expanded state explicitly */
setIsExpanded: (expanded: boolean) => void;
/** Helper to toggle the expanded state */
toggleExpanded: () => void;
}
/**
* Context that allows descendants of a ControlSection to query or mutate
* the expanded / collapsed state of their parent section.
*/
export const SectionContext = createContext<SectionContextType | undefined>(undefined);