You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
58 lines
1.5 KiB
TypeScript
58 lines
1.5 KiB
TypeScript
2 years ago
|
import clsx from "clsx";
|
||
|
import { useContext } from "react";
|
||
|
import { t } from "../../i18n";
|
||
|
import { useDevice } from "../App";
|
||
|
import { SidebarPropsContext } from "./common";
|
||
2 years ago
|
import { CloseIcon, PinIcon } from "../icons";
|
||
2 years ago
|
import { Tooltip } from "../Tooltip";
|
||
2 years ago
|
import { Button } from "../Button";
|
||
2 years ago
|
|
||
2 years ago
|
export const SidebarHeader = ({
|
||
|
children,
|
||
|
className,
|
||
|
}: {
|
||
2 years ago
|
children?: React.ReactNode;
|
||
|
className?: string;
|
||
2 years ago
|
}) => {
|
||
2 years ago
|
const device = useDevice();
|
||
|
const props = useContext(SidebarPropsContext);
|
||
|
|
||
2 years ago
|
const renderDockButton = !!(
|
||
1 year ago
|
device.editor.canFitSidebar && props.shouldRenderDockButton
|
||
2 years ago
|
);
|
||
2 years ago
|
|
||
|
return (
|
||
|
<div
|
||
2 years ago
|
className={clsx("sidebar__header", className)}
|
||
2 years ago
|
data-testid="sidebar-header"
|
||
|
>
|
||
|
{children}
|
||
2 years ago
|
<div className="sidebar__header__buttons">
|
||
|
{renderDockButton && (
|
||
|
<Tooltip label={t("labels.sidebarLock")}>
|
||
|
<Button
|
||
|
onSelect={() => props.onDock?.(!props.docked)}
|
||
|
selected={!!props.docked}
|
||
|
className="sidebar__dock"
|
||
|
data-testid="sidebar-dock"
|
||
|
aria-label={t("labels.sidebarLock")}
|
||
2 years ago
|
>
|
||
2 years ago
|
{PinIcon}
|
||
|
</Button>
|
||
|
</Tooltip>
|
||
|
)}
|
||
|
<Button
|
||
|
data-testid="sidebar-close"
|
||
|
className="sidebar__close"
|
||
|
onSelect={props.onCloseRequest}
|
||
|
aria-label={t("buttons.close")}
|
||
|
>
|
||
|
{CloseIcon}
|
||
|
</Button>
|
||
|
</div>
|
||
2 years ago
|
</div>
|
||
|
);
|
||
|
};
|
||
|
|
||
2 years ago
|
SidebarHeader.displayName = "SidebarHeader";
|