1
0
Fork 0
mirror of https://github.com/portainer/portainer.git synced 2025-07-22 06:49:40 +02:00

feat(ui/buttons): introduce Add and Delete buttons [EE-6296] (#10585)

This commit is contained in:
Chaim Lev-Ari 2023-11-14 12:36:15 +02:00 committed by GitHub
parent 66635ba6b1
commit 1f2f4525e3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 108 additions and 47 deletions

View file

@ -1,35 +1,38 @@
import clsx from 'clsx';
import { PlusCircle } from 'lucide-react';
import { Plus } from 'lucide-react';
import { ComponentProps, PropsWithChildren } from 'react';
import { Icon } from '@/react/components/Icon';
import { AutomationTestingProps } from '@/types';
import styles from './AddButton.module.css';
import { Link } from '@@/Link';
export interface Props {
className?: string;
label: string;
disabled?: boolean;
onClick: () => void;
}
import { Button } from './Button';
export function AddButton({ label, onClick, className, disabled }: Props) {
export function AddButton({
to = '.new',
params,
children,
color = 'primary',
disabled,
'data-cy': dataCy,
}: PropsWithChildren<
{
to?: string;
params?: object;
color?: ComponentProps<typeof Button>['color'];
disabled?: boolean;
} & AutomationTestingProps
>) {
return (
<button
className={clsx(
className,
'label',
'label-default',
'vertical-center',
'interactive',
'vertical-center',
styles.addButton
)}
type="button"
onClick={onClick}
<Button
as={Link}
props={{ to, params }}
icon={Plus}
className="!m-0"
data-cy={dataCy}
color={color}
disabled={disabled}
>
<Icon icon={PlusCircle} />
{label}
</button>
{children || 'Add'}
</Button>
);
}