MCPcopy
hub / github.com/OpenCut-app/OpenCut / SectionHeader

Function SectionHeader

apps/web/src/components/section.tsx:92–160  ·  view source on GitHub ↗
({
	children,
	trailing,
	leading,
	actions,
	onClick,
	className,
}: SectionHeaderProps)

Source from the content-addressed store, hash-verified

90}
91
92export function SectionHeader({
93 children,
94 trailing,
95 leading,
96 actions,
97 onClick,
98 className,
99}: SectionHeaderProps) {
100 const ctx = useSectionContext();
101 const isCollapsible = ctx?.collapsible ?? false;
102 const isOpen = ctx?.isOpen ?? true;
103 const isInteractive = isCollapsible || !!onClick;
104 const handleClick = isCollapsible ? ctx?.toggle : onClick;
105
106 const chevronIcon = (
107 <HugeiconsIcon
108 icon={ArrowDownIcon}
109 className={cn(
110 "size-4 shrink-0 transition-transform duration-200 ease-out",
111 isOpen
112 ? "rotate-0 text-foreground"
113 : "-rotate-90 text-muted-foreground",
114 )}
115 />
116 );
117
118 const trailingArea =
119 trailing || isCollapsible ? (
120 <div className="flex items-center">
121 {trailing}
122 {isCollapsible && (
123 <Button
124 variant="ghost"
125 size="icon"
126 aria-label={isOpen ? "Collapse section" : "Expand section"}
127 onClick={handleClick}
128 >
129 {chevronIcon}
130 </Button>
131 )}
132 </div>
133 ) : null;
134
135 const innerContent = isInteractive ? (
136 <button
137 type="button"
138 className="min-w-0 flex-1 flex items-center gap-2 h-full cursor-pointer text-left"
139 onClick={handleClick}
140 >
141 {leading}
142 <div className="min-w-0 flex-1 flex items-center">{children}</div>
143 </button>
144 ) : (
145 <>
146 {leading}
147 <div className="min-w-0 flex-1 flex items-center">{children}</div>
148 </>
149 );

Callers

nothing calls this directly

Calls 2

cnFunction · 0.90
useSectionContextFunction · 0.70

Tested by

no test coverage detected