Invoke is a leading creative engine that uses image and video generation models to empower professionals, artists, and enthusiasts to generate and create visual media using the latest AI-driven technologies. The solution offers an industry-leading application interface, and serves as the foundation for multiple commercial products.
TypeScript ai-artartificial-intelligencegenerative-artimage-generationimg2imginpaintinglatent-diffusionlinuxmacosoutpaintingstable-diffusiontxt2imgwindows
import type { GalleryBoardSectionId } from '@features/gallery/core/settings';
import { Collapsible, HStack, Stack, Text } from '@chakra-ui/react';
import { ChevronRightIcon } from 'lucide-react';
import { useCallback, type ReactNode } from 'react';
const INDICATOR_OPEN_STYLES = { transform: 'rotate(90deg)' } as const;
const TRIGGER_HOVER_STYLES = { color: 'fg' } as const;
/**
* One collapsible board-panel group; the trailing `action` is the trigger's sibling: no <button> inside a <button>.
*/
export const GalleryBoardSection = ({
action,
children,
count,
isOpen,
label,
sectionId,
onToggle,
}: {
action?: ReactNode;
children: ReactNode;
/** Boards in the section; shown beside the label so a collapsed section still says what it holds. */
count?: number;
isOpen: boolean;
label: string;
sectionId: GalleryBoardSectionId;
onToggle: (sectionId: GalleryBoardSectionId, isOpen: boolean) => void;
}) => {
const handleOpenChange = useCallback(
({ open }: { open: boolean }) => onToggle(sectionId, open),
[sectionId, onToggle]
);
return (
// A group that starts closed (an admin's view of other users' boards) mounts its rows only once opened.
<Collapsible.Root lazyMount open={isOpen} onOpenChange={handleOpenChange}>
<HStack gap="1" minH="6" pe="1" ps="1">
<Collapsible.Trigger
alignItems="center"
color="fg.muted"
display="flex"
flex="1"
gap="1"
minW="0"
transition="color var(--wb-motion-duration-fast) ease"
_hover={TRIGGER_HOVER_STYLES}
>
<Collapsible.Indicator _open={INDICATOR_OPEN_STYLES} transition="transform var(--wb-motion-duration-medium)">
<ChevronRightIcon size="12" />
</Collapsible.Indicator>
<Text
as="span"
fontSize="xs"
fontWeight="600"
letterSpacing="wide"
lineHeight="1"
textTransform="uppercase"
truncate
>
{label}
</Text>
{count !== undefined ? (
<Text as="span" color="fg.muted" fontSize="xs" fontVariantNumeric="tabular-nums" lineHeight="1">
{count}
</Text>
) : null}
</Collapsible.Trigger>
{action}
</HStack>
<Collapsible.Content>
<Stack gap="0.5" pb="1">
{children}
</Stack>
</Collapsible.Content>
</Collapsible.Root>
);
};