1
0
Fork 0
mirror of https://github.com/portainer/portainer.git synced 2025-07-25 08:19:40 +02:00

refactor(templates): migrate template item to react [EE-6203] (#10429)

This commit is contained in:
Chaim Lev-Ari 2023-10-19 21:09:15 +02:00 committed by GitHub
parent d970f0e2bc
commit 1ad9488ca7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
25 changed files with 932 additions and 289 deletions

View file

@ -0,0 +1,37 @@
import clsx from 'clsx';
import { ComponentProps, ComponentType, ElementType } from 'react';
export type AsComponentProps<E extends ElementType = ElementType> =
ComponentProps<E> & {
as?: E;
};
export function BlocklistItem<T extends ElementType>({
className,
isSelected,
children,
as = 'button',
...props
}: AsComponentProps & {
isSelected?: boolean;
as?: ComponentType<T>;
}) {
const Component = as as 'button';
return (
<Component
type="button"
className={clsx(
className,
'blocklist-item flex items-stretch overflow-hidden bg-transparent w-full !ml-0',
{
'blocklist-item--selected': isSelected,
}
)}
// eslint-disable-next-line react/jsx-props-no-spreading
{...props}
>
{children}
</Component>
);
}