Newer
Older
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
67
68
69
70
71
72
73
import styled, { keyframes } from 'styled-components'
const checking = keyframes`
0% {
transform: scale(0.8);
}
20% {
transform: scale(1.2);
}
80% {
transform: scale(1);
}
100% {
transform: scale(1);
}
`
const Root = styled.label`
align-items: center;
display: ${props => (props.inline ? 'inline-flex' : 'flex')};
font-family: var(--font-author);
font-size: 1em;
font-style: italic;
letter-spacing: 1px;
transition: all 2s;
&:not(:last-child) {
margin-right: ${props => (props.inline ? '2.7em' : '0')};
margin-bottom: ${props => (props.inline ? '0' : '0.5rem')};
}
& input {
display: none;
margin-right: 0.25rem;
}
& span {
border-bottom: 1px solid transparent;
font-size: 1.1em;
transition: color 0.5s;
}
&:hover span {
color: var(--color-primary);
}
& span::before {
--local-border-size: 3px;
--local-borderTwo-size: 1px;
content: ' ';
display: inline-block;
vertical-align: middle;
width: 0.7em;
height: 0.7em;
margin-right: 0.5em;
background: ${props => (props.checked ? 'currentcolor' : 'transparent')};
border: var(--local-border-size) solid white;
box-shadow: 0 0 0 var(--local-borderTwo-size) currentcolor;
transition: border 0.5s ease, background-size 0.3s ease;
}
&:hover span::before {
animation: ${checking} 0.5s;
background: var(--color-primary);
box-shadow: 0 0 0 var(--local-borderTwo-size) var(--color-primary);
}
`
const Checkbox = ({
inline,
name,
value,
label,
checked,
required,
onChange,
}) => {
checked = checked || false
return (
<Root checked={checked}>
<input
checked={checked}
name={name}
onChange={onChange}
required={required}
type="checkbox"
value={value}
/>
<span>{label}</span>
</Root>
)
}