Skip to content

Commit 166745c

Browse files
committed
Improved SASS calculation
1 parent 1e48f47 commit 166745c

File tree

8 files changed

+29
-25
lines changed

8 files changed

+29
-25
lines changed

HISTORY.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Release History
22

3+
## 1.1.2
4+
5+
* Improved `:before` and `:after` calculation
6+
37
## 1.1.1
48

59
* Fixed `line-height` issue

bower.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "bootstrap4c-custom-switch",
33
"description": "Bootstrap 4 Component - Custom switch",
4-
"version": "1.1.1",
4+
"version": "1.1.2",
55
"license": "MIT",
66
"authors": [
77
{ "name": "Martin Haubek", "email": "[email protected]", "homepage": "https://haubek.github.io" }

dist/css/component-custom-switch.css

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*
44
*
55
* Bootstrap 4 Component - Custom switch
6-
* Version: 1.1.1
6+
* Version: 1.1.2
77
* Copyright (c) 2017-18 Martin Haubek
88
*
99
*
@@ -47,8 +47,8 @@
4747
position: relative;
4848
display: block;
4949
content: "";
50-
width: 30px;
51-
height: 30px; }
50+
width: 29px;
51+
height: 29px; }
5252
.custom-switch .custom-switch-input + .custom-switch-btn:after {
5353
left: 2px;
5454
border-radius: 50%;
@@ -116,13 +116,13 @@
116116
.custom-switch-sm .custom-switch-input + .custom-switch-btn {
117117
width: 60px;
118118
height: 31px;
119-
padding: 3.26316px;
119+
padding: 3px;
120120
border-radius: 62px; }
121121
.custom-switch-sm .custom-switch-input + .custom-switch-btn:after, .custom-switch-sm .custom-switch-input + .custom-switch-btn:before {
122-
width: 25px;
123-
height: 25px; }
122+
width: 23px;
123+
height: 23px; }
124124
.custom-switch-sm .custom-switch-input + .custom-switch-btn:after {
125-
left: 1px; }
125+
left: 2px; }
126126
.custom-switch-sm .custom-switch-input:checked + .custom-switch-btn:after {
127127
left: 29px; }
128128
.custom-switch-sm .custom-switch-form-text {
@@ -154,7 +154,7 @@
154154
.custom-switch-xs .custom-switch-input + .custom-switch-btn {
155155
width: 48px;
156156
height: 24px;
157-
padding: 2.52632px;
157+
padding: 3px;
158158
border-radius: 48px; }
159159
.custom-switch-xs .custom-switch-input + .custom-switch-btn:after, .custom-switch-xs .custom-switch-input + .custom-switch-btn:before {
160160
width: 18px;

dist/css/component-custom-switch.min.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "bootstrap4c-custom-switch",
33
"description": "Bootstrap 4 Component - Custom switch",
4-
"version": "1.1.1",
4+
"version": "1.1.2",
55
"license": "MIT",
66
"author": {
77
"name": "Martin Haubek",

src/scss/_component-custom-switch.scss

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
width: ($switch-width + $switch-unit);
2626
height: ($switch-height + $switch-unit);
2727
margin: 0;
28-
padding: (($switch-height / 9.5) + $switch-unit);
28+
padding: ((round(($switch-height - (round($switch-height * .75))) / 2) - 1) + $switch-unit);
2929
background: $switch-unchecked-bg;
3030
border-radius: (($switch-height * 2) + $switch-unit);
3131
transition: all $switch-duration ease;
@@ -34,11 +34,11 @@
3434
position: relative;
3535
display: block;
3636
content: "";
37-
width: (($switch-height - 8) + $switch-unit);
38-
height: (($switch-height - 8) + $switch-unit);
37+
width: (round($switch-height * .75) + $switch-unit);
38+
height: (round($switch-height * .75) + $switch-unit);
3939
}
4040
&:after {
41-
left: 2px;
41+
left: ((round(($switch-height - (round($switch-height * .75))) / 2) - 3) + $switch-unit);
4242
border-radius: 50%;
4343
background: white;
4444
transition: all $switch-duration ease;
@@ -156,15 +156,15 @@
156156
+ .custom-switch-btn {
157157
width: ($switch-width-sm + $switch-unit);
158158
height: ($switch-height-sm + $switch-unit);
159-
padding: (($switch-height-sm / 9.5) + $switch-unit);
159+
padding: ((round(($switch-height-sm - (round($switch-height-sm * .75))) / 2) - 1) + $switch-unit);
160160
border-radius: (($switch-height-sm * 2) + $switch-unit);
161161
&:after,
162162
&:before {
163-
width: (($switch-height-sm - 6) + $switch-unit);
164-
height: (($switch-height-sm - 6) + $switch-unit);
163+
width: (round($switch-height-sm * .75) + $switch-unit);
164+
height: (round($switch-height-sm * .75) + $switch-unit);
165165
}
166166
&:after {
167-
left: 1px;
167+
left: ((round(($switch-height-sm - (round($switch-height-sm * .75))) / 2) - 2) + $switch-unit);
168168
}
169169
}
170170
&:checked + .custom-switch-btn {
@@ -229,15 +229,15 @@
229229
+ .custom-switch-btn {
230230
width: ($switch-width-xs + $switch-unit);
231231
height: ($switch-height-xs + $switch-unit);
232-
padding: (($switch-height-xs / 9.5) + $switch-unit);
232+
padding: ((round(($switch-height-xs - (round($switch-height-xs * .75))) / 2)) + $switch-unit);
233233
border-radius: (($switch-height-xs * 2) + $switch-unit);
234234
&:after,
235235
&:before {
236-
width: (($switch-height-xs - 6) + $switch-unit);
237-
height: (($switch-height-xs - 6) + $switch-unit);
236+
width: (round($switch-height-xs * .75) + $switch-unit);
237+
height: (round($switch-height-xs * .75) + $switch-unit);
238238
}
239239
&:after {
240-
left: 1px;
240+
left: ((round(($switch-height-xs - (round($switch-height-xs * .75))) / 2) - 2) + $switch-unit);
241241
}
242242
}
243243
&:checked + .custom-switch-btn {

src/scss/_component-variables.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ $switch-width-status-sm: 88;
77
$switch-width-status-xs: 76;
88
$switch-height: 38; // The default Bootstrap btn height in px
99
$switch-height-sm: 31; // The default Bootstrap small btn height in px
10-
$switch-height-xs: 24; // The default Bootstrap extra small btn height in px
10+
$switch-height-xs: 24; // Extra small btn height in px
1111
$switch-font-size: 12;
1212
$switch-font-size-sm: 11;
1313
$switch-font-size-xs: 10;

src/scss/build.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*
44
*
55
* Bootstrap 4 Component - Custom switch
6-
* Version: 1.1.1
6+
* Version: 1.1.2
77
* Copyright (c) 2017-18 Martin Haubek
88
*
99
*

0 commit comments

Comments
 (0)