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

refactor(docker/images): convert table to react [EE-4668] (#8910)

This commit is contained in:
Chaim Lev-Ari 2023-07-13 10:47:20 +03:00 committed by GitHub
parent 0e9902fee9
commit ecd54ab929
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
26 changed files with 496 additions and 441 deletions

View file

@ -1,6 +1,7 @@
import {
AriaAttributes,
ComponentType,
forwardRef,
MouseEventHandler,
PropsWithChildren,
ReactNode,
@ -39,9 +40,17 @@ export interface Props<TasProps = unknown>
type?: Type;
as?: ComponentType<TasProps> | string;
onClick?: MouseEventHandler<HTMLButtonElement>;
mRef?: React.ForwardedRef<HTMLButtonElement>;
props?: TasProps;
}
export const ButtonWithRef = forwardRef<HTMLButtonElement, Omit<Props, 'mRef'>>(
(props, ref) => (
// eslint-disable-next-line react/jsx-props-no-spreading
<Button {...props} mRef={ref} />
)
);
export function Button<TasProps = unknown>({
type = 'button',
color = 'primary',
@ -54,15 +63,19 @@ export function Button<TasProps = unknown>({
children,
as = 'button',
props,
mRef,
...ariaProps
}: PropsWithChildren<Props<TasProps>>) {
const Component = as as 'button';
return (
<Component
ref={mRef}
/* eslint-disable-next-line react/button-has-type */
type={type}
disabled={disabled}
className={clsx(`btn btn-${color}`, sizeClass(size), className)}
className={clsx(`btn btn-${color}`, sizeClass(size), className, {
disabled,
})}
onClick={(e) => {
if (!disabled) {
onClick?.(e);