forked from codesandbox/codesandbox-client
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.tsx
More file actions
46 lines (39 loc) · 1.26 KB
/
index.tsx
File metadata and controls
46 lines (39 loc) · 1.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import React from 'react';
import styled from 'styled-components';
type Props = {
checked?: boolean;
style?: React.CSSProperties;
onChange?: () => void;
onClick?: () => void;
id?: string;
};
const svg =
"data:image/svg+xml;utf8,<svg viewBox='0 0 10 9' xmlns='http://www.w3.org/2000/svg'><path d='M1 4.88l2.378 2.435L9.046 1.6' stroke-width='1.6' stroke='%23FFF' fill='none' fill-rule='evenodd' stroke-linecap='round' stroke-linejoin='round'/></svg>";
const CheckBoxStyled = styled.input`
background-image: none;
border: 2px solid transparent;
background: ${props =>
props.theme.light ? 'rgba(0, 0, 0, 0.3)' : 'rgba(255, 255, 255, 0.3)'}
url('') no-repeat 50%/10px;
box-shadow: none;
display: inline-block;
border-radius: 3.5px;
width: 16px;
height: 16px;
vertical-align: middle;
margin-right: 0.75rem;
transition: 0.15s ease all;
appearance: none;
&:focus,
&:active {
border-color: ${props => props.theme.shySecondary};
}
&:checked {
background: ${props => props.theme.shySecondary} url('') no-repeat 50%/10px;
border-color: ${props => props.theme.shySecondary};
background-image: url("${encodeURIComponent(svg)}");
}
`;
export const Checkbox = (props: Props) => (
<CheckBoxStyled type="checkbox" {...props} />
);