Skip to content

Instantly share code, notes, and snippets.

@tommoor
Created November 16, 2017 05:41
Show Gist options
  • Save tommoor/d39518332f525292d5e96068e6c8a3e3 to your computer and use it in GitHub Desktop.
Save tommoor/d39518332f525292d5e96068e6c8a3e3 to your computer and use it in GitHub Desktop.
// @flow
import React from 'react';
import Icon from './Icon';
import type { Props } from './Icon';
export default function CheckboxIcon({
checked,
...rest
}: Props & { checked: boolean }) {
return (
<Icon {...rest}>
{checked ? (
<path d="M8,5 L16,5 L16,5 C17.6568542,5 19,6.34314575 19,8 L19,16 C19,17.6568542 17.6568542,19 16,19 L8,19 L8,19 C6.34314575,19 5,17.6568542 5,16 L5,8 L5,8 C5,6.34314575 6.34314575,5 8,5 L8,5 Z M10.958729,12.8883948 L9.26824635,10.8598156 C8.91468227,10.4355387 8.28411757,10.3782146 7.85984067,10.7317787 C7.43556378,11.0853428 7.37823971,11.7159075 7.73180379,12.1401844 L10.2318038,15.1401844 C10.6450125,15.6360348 11.4127535,15.616362 11.8000251,15.1 L16.3000251,9.1 C16.6313959,8.6581722 16.5418529,8.03137085 16.1000251,7.7 C15.6581973,7.36862915 15.0313959,7.4581722 14.7000251,7.9 L10.958729,12.8883948 Z" />
) : (
<path
d="M8,5 L16,5 L16,5 C17.6568542,5 19,6.34314575 19,8 L19,16 C19,17.6568542 17.6568542,19 16,19 L8,19 L8,19 C6.34314575,19 5,17.6568542 5,16 L5,8 L5,8 C5,6.34314575 6.34314575,5 8,5 L8,5 Z M8,7 C7.44771525,7 7,7.44771525 7,8 L7,16 C7,16.5522847 7.44771525,17 8,17 L16,17 C16.5522847,17 17,16.5522847 17,16 L17,8 C17,7.44771525 16.5522847,7 16,7 L8,7 Z"
id="path-1"
/>
)}
</Icon>
);
}
// @flow
import React from 'react';
import { color } from 'shared/styles/constants';
export type Props = {
className?: string,
light?: boolean,
black?: boolean,
primary?: boolean,
color?: string,
size?: number,
onClick?: Function,
};
type BaseProps = {
children?: React$Element<*>,
};
export default function Icon({
children,
className,
onClick,
...rest
}: Props & BaseProps) {
const size = rest.size ? rest.size + 'px' : '24px';
let fill = color.slateDark;
if (rest.color) fill = rest.color;
if (rest.light) fill = color.white;
if (rest.black) fill = color.black;
if (rest.primary) fill = color.primary;
return (
<svg
fill={fill}
width={size}
height={size}
viewBox="0 0 24 24"
xmlns="http://www.w3.org/2000/svg"
className={className}
onClick={onClick}
>
{children}
</svg>
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment