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:
parent
d970f0e2bc
commit
1ad9488ca7
25 changed files with 932 additions and 289 deletions
37
app/react/components/Blocklist/BlocklistItem.tsx
Normal file
37
app/react/components/Blocklist/BlocklistItem.tsx
Normal 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>
|
||||
);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue