This repository has been archived on 2022-08-14. You can view files and clone it, but cannot push or open issues or pull requests.
Files
outline/frontend/components/Icon/Icon.js
2017-10-21 15:23:23 -07:00

41 lines
914 B
JavaScript

// @flow
import React from 'react';
import styled from 'styled-components';
import { color } from 'styles/constants';
export type Props = {
className?: string,
light?: boolean,
black?: boolean,
primary?: boolean,
color?: string,
size?: number,
};
type BaseProps = {
children?: React$Element<*>,
};
export default function Icon({ children, ...rest }: Props & BaseProps) {
return (
<Wrapper {...rest}>
{children}
</Wrapper>
);
}
const Wrapper = styled.span`
svg {
width: ${props => (props.size ? props.size + 'px' : 'auto')};
height: ${props => (props.size ? props.size + 'px' : 'auto')};
fill: ${props => {
if (props.color) return props.color;
if (props.light) return color.white;
if (props.black) return color.black;
if (props.primary) return color.primary;
return color.slateDark;
}};
}
`;