mirror of
https://github.com/Unleash/unleash.git
synced 2025-01-06 00:07:44 +01:00
4167a60588
Follows up on https://github.com/Unleash/unleash/pull/4853 to add Biome to the frontend as well. ![image](https://github.com/Unleash/unleash/assets/14320932/1906faf1-fc29-4172-a4d4-b2716d72cd65) Added a few `biome-ignore` to speed up the process but we may want to check and fix them in the future.
72 lines
2.1 KiB
TypeScript
72 lines
2.1 KiB
TypeScript
import React from 'react';
|
|
import { useMediaQuery } from '@mui/material';
|
|
import { ConditionallyRender } from 'component/common/ConditionallyRender/ConditionallyRender';
|
|
import PermissionButton from 'component/common/PermissionButton/PermissionButton';
|
|
import PermissionIconButton from 'component/common/PermissionIconButton/PermissionIconButton';
|
|
import { ITooltipResolverProps } from '../TooltipResolver/TooltipResolver';
|
|
|
|
interface IResponsiveButtonProps {
|
|
Icon: React.ElementType;
|
|
endIcon?: React.ReactNode;
|
|
tooltipProps?: Omit<ITooltipResolverProps, 'children'>;
|
|
onClick: () => void;
|
|
disabled?: boolean;
|
|
permission: string | string[];
|
|
projectId?: string;
|
|
environmentId?: string;
|
|
maxWidth: string;
|
|
className?: string;
|
|
}
|
|
|
|
const ResponsiveButton: React.FC<IResponsiveButtonProps> = ({
|
|
Icon,
|
|
onClick,
|
|
maxWidth,
|
|
disabled = false,
|
|
children,
|
|
permission,
|
|
environmentId,
|
|
projectId,
|
|
endIcon,
|
|
...rest
|
|
}) => {
|
|
const smallScreen = useMediaQuery(`(max-width:${maxWidth})`);
|
|
|
|
return (
|
|
<ConditionallyRender
|
|
condition={smallScreen}
|
|
show={
|
|
<PermissionIconButton
|
|
disabled={disabled}
|
|
onClick={onClick}
|
|
permission={permission}
|
|
projectId={projectId}
|
|
environmentId={environmentId}
|
|
data-loading
|
|
{...rest}
|
|
>
|
|
<Icon />
|
|
</PermissionIconButton>
|
|
}
|
|
elseShow={
|
|
<PermissionButton
|
|
onClick={onClick}
|
|
permission={permission}
|
|
projectId={projectId}
|
|
color='primary'
|
|
variant='contained'
|
|
disabled={disabled}
|
|
environmentId={environmentId}
|
|
endIcon={endIcon}
|
|
data-loading
|
|
{...rest}
|
|
>
|
|
{children}
|
|
</PermissionButton>
|
|
}
|
|
/>
|
|
);
|
|
};
|
|
|
|
export default ResponsiveButton;
|