1
0
mirror of https://github.com/SomboChea/ui synced 2024-09-29 04:47:47 +07:00
verdaccio-ui/src/components/Icon/styles.ts
2019-07-16 16:15:56 +02:00

57 lines
1.1 KiB
TypeScript

import styled, { css } from 'react-emotion';
import { Breakpoint } from '@material-ui/core/styles/createBreakpoints';
import { StyledOtherComponent } from 'create-emotion-styled';
import { DetailedHTMLProps, HTMLAttributes } from 'react';
const getSize = (size: Breakpoint): string => {
switch (size) {
case 'md':
return `
width: 18px;
height: 18px;
`;
default:
return `
width: 14px;
height: 16px;
`;
}
};
const commonStyle = ({ size = 'sm' as Breakpoint, pointer, modifiers = null }): string => css`
&& {
display: inline-block;
cursor: ${pointer ? 'pointer' : 'default'};
${getSize(size)};
${modifiers && modifiers};
}
`;
export const Svg = styled('svg')`
&& {
${commonStyle};
}
`;
export const ImgWrapper: StyledOtherComponent<
{
size?: Breakpoint;
pointer: boolean;
modifiers?: null | undefined;
name?: string | unknown;
},
DetailedHTMLProps<HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>,
{}
> = styled('span')`
&& {
${commonStyle};
}
`;
export const Img = styled('img')({
'&&': {
width: '100%',
height: 'auto',
},
});