mirror of
https://github.com/hazemKrimi/crimson-quirks-ui.git
synced 2026-05-01 18:20:28 +00:00
Add icon button component
This commit is contained in:
@@ -0,0 +1,33 @@
|
|||||||
|
import { Wrapper } from './styles';
|
||||||
|
|
||||||
|
type IconButtonProps = Omit<
|
||||||
|
React.AllHTMLAttributes<HTMLButtonElement>,
|
||||||
|
'size'
|
||||||
|
> & {
|
||||||
|
color:
|
||||||
|
| 'client'
|
||||||
|
| 'productOwner'
|
||||||
|
| 'developer'
|
||||||
|
| 'admin'
|
||||||
|
| 'success'
|
||||||
|
| 'warning'
|
||||||
|
| 'error';
|
||||||
|
size?: 'small' | 'big';
|
||||||
|
icon?: React.SVGProps<SVGSVGElement>;
|
||||||
|
onClick: () => void;
|
||||||
|
};
|
||||||
|
|
||||||
|
const IconButton = ({
|
||||||
|
color,
|
||||||
|
size = 'small',
|
||||||
|
icon,
|
||||||
|
onClick,
|
||||||
|
}: IconButtonProps) => {
|
||||||
|
return (
|
||||||
|
<Wrapper color={color} size={size} onClick={onClick}>
|
||||||
|
{icon}
|
||||||
|
</Wrapper>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default IconButton;
|
||||||
@@ -0,0 +1,71 @@
|
|||||||
|
import styled, { css } from 'styled-components';
|
||||||
|
|
||||||
|
type WrapperProps = {
|
||||||
|
color:
|
||||||
|
| 'client'
|
||||||
|
| 'productOwner'
|
||||||
|
| 'developer'
|
||||||
|
| 'admin'
|
||||||
|
| 'success'
|
||||||
|
| 'warning'
|
||||||
|
| 'error';
|
||||||
|
size?: 'small' | 'big';
|
||||||
|
icon?: React.SVGProps<SVGSVGElement>;
|
||||||
|
};
|
||||||
|
|
||||||
|
export const Wrapper = styled.button<WrapperProps>`
|
||||||
|
cursor: pointer;
|
||||||
|
outline: none;
|
||||||
|
border: none;
|
||||||
|
border-radius: 50%;
|
||||||
|
background: none;
|
||||||
|
font-weight: bold;
|
||||||
|
background: ${({ theme, color }) => theme.colors[color].main};
|
||||||
|
display: grid;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
|
||||||
|
svg {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
|
||||||
|
path {
|
||||||
|
stroke: ${({ theme }) => theme.colors.white.main};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
${({ size }) => {
|
||||||
|
switch (size) {
|
||||||
|
case 'small':
|
||||||
|
return css`
|
||||||
|
width: 25px;
|
||||||
|
height: 25px;
|
||||||
|
|
||||||
|
svg {
|
||||||
|
width: 12.5px;
|
||||||
|
height: 12.5px;
|
||||||
|
}
|
||||||
|
`;
|
||||||
|
case 'big':
|
||||||
|
return css`
|
||||||
|
width: 50px;
|
||||||
|
height: 50px;
|
||||||
|
|
||||||
|
svg {
|
||||||
|
width: 24.5px;
|
||||||
|
height: 24.5px;
|
||||||
|
}
|
||||||
|
`;
|
||||||
|
default:
|
||||||
|
return css`
|
||||||
|
width: 25px;
|
||||||
|
height: 25px;
|
||||||
|
|
||||||
|
svg {
|
||||||
|
width: 12.5px;
|
||||||
|
height: 12.5px;
|
||||||
|
}
|
||||||
|
`;
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
`;
|
||||||
Reference in New Issue
Block a user