snapshot of https://github.com/excalidraw/excalidraw.git (master, 2026-09-16; blobs > 131072B omitted)
Some checks failed
Tests / test (push) Failing after 15s
Some checks failed
Tests / test (push) Failing after 15s
This commit is contained in:
53
packages/excalidraw/components/Sidebar/SidebarTrigger.tsx
Normal file
53
packages/excalidraw/components/Sidebar/SidebarTrigger.tsx
Normal file
@@ -0,0 +1,53 @@
|
||||
import clsx from "clsx";
|
||||
|
||||
import { useUIAppState } from "../../context/ui-appState";
|
||||
import { useExcalidrawSetAppState } from "../App";
|
||||
|
||||
import "./SidebarTrigger.scss";
|
||||
|
||||
import type { SidebarTriggerProps } from "./common";
|
||||
|
||||
export const SidebarTrigger = ({
|
||||
name,
|
||||
tab,
|
||||
icon,
|
||||
title,
|
||||
children,
|
||||
onToggle,
|
||||
className,
|
||||
style,
|
||||
}: SidebarTriggerProps) => {
|
||||
const setAppState = useExcalidrawSetAppState();
|
||||
const appState = useUIAppState();
|
||||
|
||||
const isOpen = appState.openSidebar?.name === name;
|
||||
|
||||
return (
|
||||
<button
|
||||
type="button"
|
||||
title={title}
|
||||
className="sidebar-trigger__label-element"
|
||||
aria-label={title}
|
||||
aria-keyshortcuts="0"
|
||||
aria-pressed={isOpen}
|
||||
onClick={() => {
|
||||
document
|
||||
.querySelector(".layer-ui__wrapper")
|
||||
?.classList.remove("animate");
|
||||
const nextOpen = !isOpen;
|
||||
setAppState({
|
||||
openSidebar: nextOpen ? { name, tab } : null,
|
||||
openMenu: null,
|
||||
openPopup: null,
|
||||
});
|
||||
onToggle?.(nextOpen);
|
||||
}}
|
||||
>
|
||||
<div className={clsx("sidebar-trigger", className)} style={style}>
|
||||
{icon && <div>{icon}</div>}
|
||||
{children && <div className="sidebar-trigger__label">{children}</div>}
|
||||
</div>
|
||||
</button>
|
||||
);
|
||||
};
|
||||
SidebarTrigger.displayName = "SidebarTrigger";
|
||||
Reference in New Issue
Block a user