1
0
Fork 0
mirror of https://github.com/portainer/portainer.git synced 2025-07-24 15:59:41 +02:00

fix(ui): use expand button in sidebar and tables [EE-6844] (#11608)

This commit is contained in:
Chaim Lev-Ari 2024-05-15 08:26:23 +03:00 committed by GitHub
parent 413b9c3b04
commit a808f83e7d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 155 additions and 61 deletions

View file

@ -1,7 +1,6 @@
import { PropsWithChildren, ReactNode, useState } from 'react';
import { ChevronUp, ChevronRight } from 'lucide-react';
import { Icon } from '@@/Icon';
import { CollapseExpandButton } from '@@/CollapseExpandButton';
import { FormSectionTitle } from '../FormSectionTitle';
@ -26,30 +25,22 @@ export function FormSection({
htmlFor = '',
}: PropsWithChildren<Props>) {
const [isExpanded, setIsExpanded] = useState(!defaultFolded);
const id = `foldingButton${title}`;
return (
<div className={className}>
<FormSectionTitle
htmlFor={isFoldable ? `foldingButton${title}` : htmlFor}
htmlFor={isFoldable ? id : htmlFor}
titleSize={titleSize}
className={titleClassName}
>
{isFoldable && (
<button
id={`foldingButton${title}`}
type="button"
onClick={(e) => {
setIsExpanded(!isExpanded);
e.stopPropagation();
e.preventDefault();
}}
className="mx-2 !ml-0 inline-flex w-2 items-center justify-center border-0 bg-transparent"
>
<Icon
icon={isExpanded ? ChevronUp : ChevronRight}
className="shrink-0"
/>
</button>
<CollapseExpandButton
isExpanded={isExpanded}
data-cy={id}
id={id}
onClick={() => setIsExpanded((isExpanded) => !isExpanded)}
/>
)}
{title}