ba86be2c5b
* Remove the {...props} pattern and props coupling, and create an eslint rule for that
Co-authored-by: v1b3m <vibenjamin6@gmail.com>
Co-authored-by: Thiago Nascimbeni <tnascimbeni@gmail.com>
* Add another test to the new rule
Co-authored-by: v1b3m <vibenjamin6@gmail.com>
Co-authored-by: Thiago Nascimbeni <tnascimbeni@gmail.com>
---------
Co-authored-by: v1b3m <vibenjamin6@gmail.com>
Co-authored-by: Thiago Nascimbeni <tnascimbeni@gmail.com>
49 lines
1.1 KiB
TypeScript
49 lines
1.1 KiB
TypeScript
import { useTheme } from '@emotion/react';
|
|
import styled from '@emotion/styled';
|
|
|
|
import { IconComponent } from '@/ui/icon/types/IconComponent';
|
|
|
|
const StyledIconButton = styled.button`
|
|
align-items: center;
|
|
background: ${({ theme }) => theme.color.blue};
|
|
border: none;
|
|
|
|
border-radius: 50%;
|
|
color: ${({ theme }) => theme.font.color.inverted};
|
|
|
|
cursor: pointer;
|
|
display: flex;
|
|
height: 20px;
|
|
|
|
justify-content: center;
|
|
|
|
outline: none;
|
|
padding: 0;
|
|
transition: color 0.1s ease-in-out, background 0.1s ease-in-out;
|
|
|
|
&:disabled {
|
|
background: ${({ theme }) => theme.background.quaternary};
|
|
color: ${({ theme }) => theme.font.color.tertiary};
|
|
cursor: default;
|
|
}
|
|
width: 20px;
|
|
`;
|
|
|
|
type RoundedIconButtonProps = {
|
|
Icon: IconComponent;
|
|
} & React.ButtonHTMLAttributes<HTMLButtonElement>;
|
|
|
|
export const RoundedIconButton = ({
|
|
Icon,
|
|
...props
|
|
}: RoundedIconButtonProps) => {
|
|
const theme = useTheme();
|
|
|
|
return (
|
|
// eslint-disable-next-line twenty/no-spread-props
|
|
<StyledIconButton {...props}>
|
|
{<Icon size={theme.icon.size.md} />}
|
|
</StyledIconButton>
|
|
);
|
|
};
|