1 | import styled, { keyframes, css } from 'styled-components';
|
2 |
|
3 | import Colors from '../Colors';
|
4 | import Sizes from '../Sizes';
|
5 | import TextHelper from '../TextHelper';
|
6 |
|
7 | import { IProps } from './Checkbox';
|
8 |
|
9 | const bounceUp = keyframes`
|
10 | 0%,
|
11 | 20%,
|
12 | 50%,
|
13 | 80%,
|
14 | 100% { transform: scale(1); }
|
15 | 40% { transform: scale(1.3); }
|
16 | 60% { transform: scale(1.1); }
|
17 | `;
|
18 |
|
19 | const check = keyframes`
|
20 | from { stroke-dashoffset: 31.26; }
|
21 | to { stroke-dashoffset: 0; }
|
22 | `;
|
23 |
|
24 | export const CheckBox = styled.input.attrs<IProps>(() => ({
|
25 | type: 'checkbox',
|
26 | }))`
|
27 | opacity: 0;
|
28 | position: absolute;
|
29 |
|
30 | & + label .check {
|
31 | position: absolute;
|
32 | stroke-width: 2px;
|
33 | stroke: #fff;
|
34 | fill: none;
|
35 | top: 5px;
|
36 | left: 2px;
|
37 | height: 16px;
|
38 | opacity: 0;
|
39 | transition: all .2s ease;
|
40 | stroke-dasharray: 31.26;
|
41 | stroke-dashoffset: 0;
|
42 | }
|
43 |
|
44 | &:checked + label .check {
|
45 | opacity: 1;
|
46 | animation: ${css`${check}`} 0.3s linear forwards;
|
47 | }
|
48 |
|
49 | &:checked + label::before {
|
50 | animation: ${css`${bounceUp}`} .5s forwards;
|
51 | background-color: ${Colors.mongeral};
|
52 | border-color: ${Colors.mongeral};
|
53 | }
|
54 | `;
|
55 |
|
56 | export const Label = styled.label<{htmlFor: string, css?: string}>`
|
57 | position: relative;
|
58 | display: flex;
|
59 | align-items: center;
|
60 | min-height: 30px;
|
61 | padding-left: ${Sizes.s4 + 8}px;
|
62 | font-family: ${TextHelper.fontVariant('medium')};
|
63 | cursor: pointer;
|
64 |
|
65 | &:before, &:after {
|
66 | content: '';
|
67 | display: inline-block;
|
68 | position: absolute;
|
69 | }
|
70 |
|
71 | &:before {
|
72 | width: ${Sizes.s4 - 3}px;
|
73 | height: ${Sizes.s4 - 3}px;
|
74 |
|
75 | border: 2px solid ${Colors.mongeral};
|
76 | left: 0;
|
77 | top: 3px;
|
78 | }
|
79 | `;
|
80 |
|
\ | No newline at end of file |