-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy path_m-checkbox-custom.scss
83 lines (74 loc) · 1.8 KB
/
_m-checkbox-custom.scss
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
@use "../01-abstract/variables" as *;
@use "m-rtl" as *;
@use "m-sr-only" as *;
@use "sass:math";
/**
* Checkbox custom
*
* @author Nicolas Langle
*
* @param $color
* @param $size
* @param $border-width
*
* Examples :
*
* input[type="checkbox"] {
* @include checkbox-custom;
*
* &:checked {
* @include checkbox-custom-checked;
* }
* }
*
*/
@mixin checkbox-custom($color: $color-primary, $size: 18px, $border-width: 1px) {
@include sr-only;
+ label {
position: relative;
display: block;
padding-inline-start: $size + 20;
cursor: pointer;
&::before {
position: absolute;
top: 1px;
left: 0;
width: $size;
height: $size;
margin: 0;
content: "";
background-color: $color-light;
border: $border-width solid $color;
@include rtl {
right: 0;
left: auto;
}
}
&::after {
position: absolute;
top: 7px;
left: math.round(math.div($size, 2));
width: math.round(math.div($size, 1.5));
height: math.round(math.div($size, 2.5));
content: "";
border-color: $color;
border-style: solid;
border-width: 0 0 2px 2px;
opacity: 0;
transition: opacity .2s;
transform: translate(-50%, -50%) rotate(-45deg);
@include rtl {
right: math.round(math.div($size, 2));
left: auto;
transform: translate(50%, -50%) rotate(-45deg);
}
}
}
}
@mixin checkbox-custom-checked {
+ label {
&::after {
opacity: 1;
}
}
}