forked from tdjsnelling/sqtracker
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCheckbox.js
More file actions
66 lines (63 loc) · 1.85 KB
/
Copy pathCheckbox.js
File metadata and controls
66 lines (63 loc) · 1.85 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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
import React from "react";
import styled from "styled-components";
import { space } from "styled-system";
import css from "@styled-system/css";
import { transparentize } from "polished";
import Box from "./Box";
import Text from "./Text";
const Container = styled.label(
({ theme }) =>
css({
display: "flex",
alignItems: "center",
cursor: "pointer",
input: {
opacity: 0,
height: 0,
width: 0,
"&:focus, &:active": {
"& ~ .check": {
borderColor: "primary",
bg: transparentize(0.8, theme.colors.primary),
},
},
"&:checked": {
"& ~ .check": {
borderColor: "primary",
".inner": {
// prettier-ignore
backgroundImage: `url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" style="fill:%23${theme.colors.text.replace('#','')}"><path d="m10 15.586-3.293-3.293-1.414 1.414L10 18.414l9.707-9.707-1.414-1.414z"></path></svg>')`,
backgroundPosition: "center",
backgroundSize: "18px 18px",
},
},
},
},
".check": {
display: "inline-flex",
bg: "grey9",
border: "2px solid",
borderColor: "text",
borderRadius: 1,
width: "20px",
height: "20px",
},
".inner": {
width: "20px",
height: "20px",
},
}),
space
);
const Checkbox = ({ label, name, inputProps, ...rest }) => (
<Container {...rest}>
<input type="checkbox" name={name} {...inputProps} />
<Box alignItems="center" justifyContent="center" className="check">
<Box className="inner" />
</Box>
<Text as="span" display="inline-block" ml={3} lineHeight="22px">
{label}
</Text>
</Container>
);
export default Checkbox;