mirror of
https://github.com/jnsahaj/tweakcn.git
synced 2026-09-01 15:37:45 +08:00
d51c6c8620
- 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.
17 lines
555 B
TypeScript
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);
|