mirror of
https://github.com/docmost/docmost.git
synced 2026-06-10 01:52:43 +08:00
36 lines
918 B
TypeScript
36 lines
918 B
TypeScript
import React from "react";
|
|
import {
|
|
IconLayoutSidebarRightCollapse,
|
|
IconLayoutSidebarRightExpand
|
|
} from "@tabler/icons-react";
|
|
import { ActionIcon, BoxProps, ElementProps, MantineColor, MantineSize } from "@mantine/core";
|
|
|
|
export interface SidebarToggleProps extends BoxProps, ElementProps<"button"> {
|
|
size?: MantineSize | `compact-${MantineSize}` | (string & {});
|
|
color?: MantineColor;
|
|
opened?: boolean;
|
|
}
|
|
|
|
const SidebarToggle = React.forwardRef<HTMLButtonElement, SidebarToggleProps>(
|
|
({ opened, size = "sm", ...others }, ref) => {
|
|
return (
|
|
<ActionIcon
|
|
size={size}
|
|
aria-expanded={opened}
|
|
{...others}
|
|
variant="subtle"
|
|
color="gray"
|
|
ref={ref}
|
|
>
|
|
{opened ? (
|
|
<IconLayoutSidebarRightExpand />
|
|
) : (
|
|
<IconLayoutSidebarRightCollapse />
|
|
)}
|
|
</ActionIcon>
|
|
);
|
|
}
|
|
);
|
|
|
|
export default SidebarToggle;
|