mirror of
https://github.com/GitbookIO/gitbook.git
synced 2026-09-23 19:06:31 +00:00
44 lines
1.3 KiB
TypeScript
44 lines
1.3 KiB
TypeScript
import { Space } from '@gitbook/api';
|
|
|
|
import { tcls } from '@/lib/tailwind';
|
|
|
|
import { Dropdown, DropdownChevron, DropdownMenu } from './Dropdown';
|
|
import { SpacesDropdownMenuItem } from './SpacesDropdownMenuItem';
|
|
|
|
export function SpacesDropdown(props: { space: Space; spaces: Space[] }) {
|
|
const { space, spaces } = props;
|
|
|
|
return (
|
|
<Dropdown
|
|
button={(buttonProps) => (
|
|
<div
|
|
{...buttonProps}
|
|
data-testid="space-dropdown-button"
|
|
className={tcls(
|
|
'justify-self-start',
|
|
'flex',
|
|
'flex-row',
|
|
'items-center',
|
|
'px-3',
|
|
'py-1.5',
|
|
'text-header-link-500',
|
|
)}
|
|
>
|
|
{space.title}
|
|
<DropdownChevron />
|
|
</div>
|
|
)}
|
|
>
|
|
<DropdownMenu>
|
|
{spaces.map((otherSpace, index) => (
|
|
<SpacesDropdownMenuItem
|
|
key={`${otherSpace.id}-${index}`}
|
|
currentSpace={space}
|
|
variantSpace={otherSpace}
|
|
/>
|
|
))}
|
|
</DropdownMenu>
|
|
</Dropdown>
|
|
);
|
|
}
|