This commit is contained in:
Adam Lin 2024-05-14 10:56:03 +02:00 committed by GitHub
commit a73ea4d275
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 52 additions and 10 deletions

View File

@ -1,23 +1,64 @@
import "./Island.scss";
import React from "react";
import React, { useState } from "react";
import clsx from "clsx";
import { Button } from "./Button";
import { palette } from "./icons";
type IslandProps = {
children: React.ReactNode;
padding?: number;
className?: string | boolean;
style?: object;
collapsable?: boolean;
};
export const Island = React.forwardRef<HTMLDivElement, IslandProps>(
({ children, padding, className, style }, ref) => (
<div
className={clsx("Island", className)}
style={{ "--padding": padding, ...style }}
ref={ref}
>
{children}
</div>
),
({ children, padding, className, style, collapsable}, ref) => {
const [isVisible, setIsVisible] = useState(true);
const toggleIslandVisibility = () => { setIsVisible(!isVisible) };
if (collapsable) {
if (isVisible) {
return (
<div
className={clsx("Island", className)}
style={{ "--padding": padding, ...style }}
ref={ref}
>
<Button
onSelect={() => {toggleIslandVisibility()}}
className="ToolIcon_type_button"
>
{palette}
</Button><br/>
{children}
</div>
)
}
else {
return (
<Button
onSelect={() => {toggleIslandVisibility()}}
className="dropdown-menu-button"
>
{palette}
</Button>
)
}
}
else {
return (
<div
className={clsx("Island", className)}
style={{ "--padding": padding, ...style }}
ref={ref}
>
{children}
</div>
)
}
},
);

View File

@ -225,6 +225,7 @@ const LayerUI = ({
// approximate height of hamburgerMenu + footer
maxHeight: `${appState.height - 166}px`,
}}
collapsable
>
<SelectedShapeActions
appState={appState}