Browse Source

v3.4 (#699)

* v3.4 for Bootstrap 4 support

* v3.4 for Bootstrap 4 support

* v3.4 for Bootstrap 4 support

* v3.4 for Bootstrap 4 support

* v3.4 for Bootstrap 4 support

* Update package.json

* 3.4

* Update README.md

* Upgrade

* Fix semver
Emanuele 6 years ago
parent
commit
19275e7273

+ 4 - 0
CHANGELOG.md

@@ -1,5 +1,9 @@
 # Changelog
 
+## 3.4
+
+- Full Bootstrap 4 integration of CSS + sources SASS/SCSS
+
 ## 3.3.4
 
 - Fix Object.assign not working for IE <= 11 [#616](https://github.com/Bttstrp/bootstrap-switch/issues/616)

+ 7 - 0
README.md

@@ -4,6 +4,9 @@
 [![NPM Version](http://img.shields.io/npm/v/bootstrap-switch.svg?style=flat)](https://www.npmjs.org/)
 
 Turn checkboxes and radio buttons into toggle switches. Created by [Mattia Larentis](http://github.com/nostalgiaz), maintained by [Emanuele Marchi](http://github.com/lostcrew) and [Peter Stein](http://www.bdmdesign.org) with the help of the community.
+Compatible with Bootstrap 4, Bootstrap 3 and Bootstrap 2.
+
+Play with [demo on my fiddle](https://jsfiddle.net/djibe89/vL87w0j8/).
 
 ## Quick start
 
@@ -49,6 +52,10 @@ IE9+ and all the other modern browsers.
 - For Bootstrap 2 (no longer officially supported), import `src/less/bootstrap2/bootstrap-switch.less`
 - For Bootstrap 3, import `src/less/bootstrap3/bootstrap-switch.less`
 
+## SASS/SCSS
+
+- For Bootstrap 4, import `src/sass/bootstrap4/bootstrap-switch.scss`
+
 ## Bugs and feature requests
 
 Have a bug or a feature request? Please first search for existing and closed issues. If your problem or idea is not addressed yet, [please open a new issue](https://github.com/Bttstrp/bootstrap-switch/issues/new).

+ 174 - 0
dist/css/bootstrap4/bootstrap-switch.css

@@ -0,0 +1,174 @@
+/**
+  * bootstrap-switch - Turn checkboxes and radio buttons into toggle switches.
+  *
+  * @version v3.4 for Bootstrap 4.x
+  * @homepage https://bttstrp.github.io/bootstrap-switch
+  * @author Mattia Larentis <[email protected]> (http://larentis.eu)
+  * & djibe
+  * @license Apache-2.0
+  */
+.bootstrap-switch {
+  display: inline-block;
+  direction: ltr;
+  cursor: pointer;
+  border-radius: 4px;
+  border: 1px solid #ccc;
+  position: relative;
+  text-align: left;
+  overflow: hidden;
+  line-height: 8px;
+  z-index: 0;
+  -webkit-user-select: none;
+     -moz-user-select: none;
+      -ms-user-select: none;
+          user-select: none;
+  vertical-align: middle;
+  -webkit-transition: border-color ease-in-out .15s, -webkit-box-shadow ease-in-out .15s;
+  transition: border-color ease-in-out .15s, -webkit-box-shadow ease-in-out .15s;
+  transition: border-color ease-in-out .15s, box-shadow ease-in-out .15s;
+  transition: border-color ease-in-out .15s, box-shadow ease-in-out .15s, -webkit-box-shadow ease-in-out .15s;
+}
+.bootstrap-switch .bootstrap-switch-container {
+  display: inline-block;
+  top: 0;
+  border-radius: 4px;
+  -webkit-transform: translate3d(0, 0, 0);
+          transform: translate3d(0, 0, 0);
+}
+.bootstrap-switch .bootstrap-switch-handle-on,
+.bootstrap-switch .bootstrap-switch-handle-off,
+.bootstrap-switch .bootstrap-switch-label {
+  -webkit-box-sizing: border-box;
+          box-sizing: border-box;
+  cursor: pointer;
+  display: table-cell;
+  vertical-align: middle;
+  padding: 6px 12px;
+  font-size: 14px;
+  line-height: 20px;
+  font-weight: 500;
+}
+.bootstrap-switch .bootstrap-switch-handle-on,
+.bootstrap-switch .bootstrap-switch-handle-off {
+  text-align: center;
+  z-index: 1;
+}
+.bootstrap-switch .bootstrap-switch-handle-on.bootstrap-switch-primary,
+.bootstrap-switch .bootstrap-switch-handle-off.bootstrap-switch-primary {
+  background: #007bff;
+  color: #fff;
+}
+.bootstrap-switch .bootstrap-switch-handle-on.bootstrap-switch-default,
+.bootstrap-switch .bootstrap-switch-handle-off.bootstrap-switch-default {
+  background: #eee;
+  color: rgba(0, 0, 0, 0.87);
+}
+.bootstrap-switch .bootstrap-switch-handle-on.bootstrap-switch-secondary,
+.bootstrap-switch .bootstrap-switch-handle-off.bootstrap-switch-secondary {
+  background: #6c757d;
+  color: #fff;
+}
+.bootstrap-switch .bootstrap-switch-handle-on.bootstrap-switch-info,
+.bootstrap-switch .bootstrap-switch-handle-off.bootstrap-switch-info {
+  background: #17a2b8;
+  color: #fff;
+}
+.bootstrap-switch .bootstrap-switch-handle-on.bootstrap-switch-success,
+.bootstrap-switch .bootstrap-switch-handle-off.bootstrap-switch-success {
+  background: #28a745;
+  color: #fff;
+}
+.bootstrap-switch .bootstrap-switch-handle-on.bootstrap-switch-warning,
+.bootstrap-switch .bootstrap-switch-handle-off.bootstrap-switch-warning {
+  background: #ffc107;
+  color: #fff;
+}
+.bootstrap-switch .bootstrap-switch-handle-on.bootstrap-switch-danger,
+.bootstrap-switch .bootstrap-switch-handle-off.bootstrap-switch-danger {
+  background: #dc3545;
+  color: #fff;
+}
+.bootstrap-switch .bootstrap-switch-label {
+  text-align: center;
+  margin-top: -1px;
+  margin-bottom: -1px;
+  z-index: 100;
+  color: #333;
+  background: #fff;
+  padding: 8px 12px;
+}
+.bootstrap-switch span::before {
+  content: "\200b";
+}
+.bootstrap-switch .bootstrap-switch-handle-on {
+  border-bottom-left-radius: 3px;
+  border-top-left-radius: 3px;
+}
+.bootstrap-switch .bootstrap-switch-handle-off {
+  border-bottom-right-radius: 3px;
+  border-top-right-radius: 3px;
+}
+.bootstrap-switch input[type='radio'],
+.bootstrap-switch input[type='checkbox'] {
+  position: absolute !important;
+  top: 0;
+  left: 0;
+  margin: 0;
+  z-index: -1;
+  opacity: 0;
+  filter: alpha(opacity=0);
+  visibility: hidden;
+}
+.bootstrap-switch.bootstrap-switch-mini .bootstrap-switch-handle-on,
+.bootstrap-switch.bootstrap-switch-mini .bootstrap-switch-handle-off,
+.bootstrap-switch.bootstrap-switch-mini .bootstrap-switch-label {
+  padding: 1px 5px;
+  font-size: 12px;
+  line-height: 1.5;
+}
+.bootstrap-switch.bootstrap-switch-small .bootstrap-switch-handle-on,
+.bootstrap-switch.bootstrap-switch-small .bootstrap-switch-handle-off,
+.bootstrap-switch.bootstrap-switch-small .bootstrap-switch-label {
+  padding: 5px 10px;
+  font-size: 12px;
+  line-height: 1.5;
+}
+.bootstrap-switch.bootstrap-switch-large .bootstrap-switch-handle-on,
+.bootstrap-switch.bootstrap-switch-large .bootstrap-switch-handle-off,
+.bootstrap-switch.bootstrap-switch-large .bootstrap-switch-label {
+  padding: 6px 16px;
+  font-size: 18px;
+  line-height: 1.3333333;
+}
+.bootstrap-switch.bootstrap-switch-disabled, .bootstrap-switch.bootstrap-switch-readonly, .bootstrap-switch.bootstrap-switch-indeterminate {
+  cursor: default !important;
+}
+.bootstrap-switch.bootstrap-switch-disabled .bootstrap-switch-handle-on, .bootstrap-switch.bootstrap-switch-readonly .bootstrap-switch-handle-on, .bootstrap-switch.bootstrap-switch-indeterminate .bootstrap-switch-handle-on, .bootstrap-switch.bootstrap-switch-disabled .bootstrap-switch-handle-off, .bootstrap-switch.bootstrap-switch-readonly .bootstrap-switch-handle-off, .bootstrap-switch.bootstrap-switch-indeterminate .bootstrap-switch-handle-off, .bootstrap-switch.bootstrap-switch-disabled .bootstrap-switch-label, .bootstrap-switch.bootstrap-switch-readonly .bootstrap-switch-label, .bootstrap-switch.bootstrap-switch-indeterminate .bootstrap-switch-label {
+  opacity: 0.5;
+  filter: alpha(opacity=50);
+  cursor: default !important;
+}
+.bootstrap-switch.bootstrap-switch-animate .bootstrap-switch-container {
+  -webkit-transition: margin-left 0.5s;
+  transition: margin-left 0.5s;
+}
+.bootstrap-switch.bootstrap-switch-inverse .bootstrap-switch-handle-on {
+  border-radius: 0 3px 3px 0;
+}
+.bootstrap-switch.bootstrap-switch-inverse .bootstrap-switch-handle-off {
+  border-radius: 3px 0 0 3px;
+}
+.bootstrap-switch.bootstrap-switch-focused {
+  border-color: #66afe9;
+  outline: 0;
+  -webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 8px rgba(102, 175, 233, 0.6);
+          box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 8px rgba(102, 175, 233, 0.6);
+}
+.bootstrap-switch.bootstrap-switch-on .bootstrap-switch-label, .bootstrap-switch.bootstrap-switch-inverse.bootstrap-switch-off .bootstrap-switch-label {
+  border-bottom-right-radius: 3px;
+  border-top-right-radius: 3px;
+}
+.bootstrap-switch.bootstrap-switch-off .bootstrap-switch-label, .bootstrap-switch.bootstrap-switch-inverse.bootstrap-switch-on .bootstrap-switch-label {
+  border-bottom-left-radius: 3px;
+  border-top-left-radius: 3px;
+}

File diff suppressed because it is too large
+ 0 - 0
dist/css/bootstrap4/bootstrap-switch.min.css


+ 1 - 1
docs/css/main.css

@@ -1 +1 @@
-body{font-family:'Helvetica Neue',Helvetica,Arial,sans-serif;padding-bottom:50px}.bs-docs-masthead,.bs-docs-header{color:#cdbfe3;text-shadow:0 1px 0 rgba(0,0,0,0.1);background-color:#6f5499;background-image:-webkit-gradient(linear,left top,left bottom,from(#563d7c),to(#6f5499));background-image:-webkit-linear-gradient(top,#563d7c 0,#6f5499 100%);background-image:linear-gradient(to bottom,#563d7c 0,#6f5499 100%);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#563d7c',endColorstr='#6F5499',GradientType=0);background-repeat:repeat-x}.bs-docs-masthead h1{font-weight:500}.page-header{text-align:left}#github{display:none;position:fixed;width:150px;height:150px;top:0;right:0;z-index:2000}.bottom{border-top:1px solid #eee;margin-top:40px;padding-top:20px;padding-bottom:20px;text-align:center}.hljs{background-color:transparent}@media (min-width:768px){#github{display:block}}
+body{font-family:'Helvetica Neue',Helvetica,Arial,sans-serif;padding-bottom:50px}.bs-docs-masthead,.bs-docs-header{color:#cdbfe3;text-shadow:0 1px 0 rgba(0,0,0,0.1);background-color:#6f5499;background-image:-webkit-gradient(linear,left top,left bottom,color-stop(0,#563d7c),to(#6f5499));background-image:linear-gradient(to bottom,#563d7c 0,#6f5499 100%);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#563d7c',endColorstr='#6F5499',GradientType=0);background-repeat:repeat-x}.bs-docs-masthead h1{font-weight:500}.page-header{text-align:left}#github{display:none;position:fixed;width:150px;height:150px;top:0;right:0;z-index:2000}.bottom{border-top:1px solid #eee;margin-top:40px;padding-top:20px;padding-bottom:20px;text-align:center}.hljs{background-color:transparent}@media (min-width:768px){#github{display:block}}

+ 5 - 4
package.json

@@ -1,7 +1,7 @@
 {
   "name": "bootstrap-switch",
   "description": "Turn checkboxes and radio buttons into toggle switches.",
-  "version": "3.3.5",
+  "version": "3.4.0",
   "keywords": [
     "bootstrap",
     "switch",
@@ -16,7 +16,7 @@
   ],
   "main": "dist/js/bootstrap-switch.js",
   "peerDependencies": {
-    "bootstrap": "^3.3.7",
+    "bootstrap": "^4.3.1",
     "jquery": ">=1.12.4"
   },
   "repository": {
@@ -39,7 +39,7 @@
     "eslint": "^3.19.0",
     "eslint-config-airbnb-base": "^11.2.0",
     "eslint-plugin-import": "^2.2.0",
-    "harp": "^0.23.0",
+    "harp": "^0.30.0",
     "headr": "0.0.4",
     "jasmine": "^2.5.3",
     "jasmine-core": "^2.5.2",
@@ -53,7 +53,7 @@
     "karma-phantomjs-launcher": "^1.0.2",
     "less": "^2.7.2",
     "less-plugin-clean-css": "^1.5.0",
-    "npm-run-all": "^4.0.1",
+    "npm-run-all": "^4.1.5",
     "regenerator-runtime": "^0.11.1",
     "wintersmith": "^2.3.6"
   },
@@ -94,6 +94,7 @@
   ],
   "dependencies": {},
   "jest": {
+    "testURL": "http://localhost/",
     "setupFiles": [
       "./src/setup-test.js"
     ]

+ 214 - 0
src/sass/bootstrap4/bootstrap-switch.scss

@@ -0,0 +1,214 @@
+/**
+  * bootstrap-switch - Turn checkboxes and radio buttons into toggle switches.
+  *
+  * @version v3.4 for Bootstrap 4.x
+  * @homepage https://bttstrp.github.io/bootstrap-switch
+  * @author Mattia Larentis <[email protected]> (http://larentis.eu)
+  * & djibe
+  * @license Apache-2.0
+  */
+
+$bootstrap-switch-border-radius: 4px;
+$bootstrap-switch-handle-border-radius: 3px;
+
+@import "../bootstrap-4.2.1/functions";
+@import "../bootstrap-4.2.1/variables";
+
+.bootstrap-switch {
+	display: inline-block;
+	direction: ltr;
+	cursor: pointer;
+	border-radius: $bootstrap-switch-border-radius;
+	border: 1px solid #ccc;
+	position: relative;
+	text-align: left;
+	overflow: hidden;
+	line-height: 8px;
+	z-index: 0;
+	user-select: none;
+	vertical-align: middle;
+	transition: border-color ease-in-out .15s, box-shadow ease-in-out .15s;
+
+	.bootstrap-switch-container {
+		display: inline-block;
+		top: 0;
+		border-radius: $bootstrap-switch-border-radius;
+		transform: translate3d(0, 0, 0);
+	}
+
+	.bootstrap-switch-handle-on,
+	.bootstrap-switch-handle-off,
+	.bootstrap-switch-label {
+		box-sizing: border-box;
+		cursor: pointer;
+		display: table-cell;
+		vertical-align: middle;
+		padding: 6px 12px;
+		font-size: 14px;
+		line-height: 20px;
+		font-weight: 500;
+	}
+
+	.bootstrap-switch-handle-on,
+	.bootstrap-switch-handle-off {
+		text-align: center;
+		z-index: 1;
+
+		&.bootstrap-switch-primary {
+			background: $primary;
+			color: #fff;
+		}
+
+		&.bootstrap-switch-default {
+			background: #eee;
+			color: rgba(0, 0, 0, .87);
+		}
+
+		&.bootstrap-switch-secondary {
+			background: $secondary;
+			color: #fff;
+		}
+
+		&.bootstrap-switch-info {
+			background: $info;
+			color: #fff;
+		}
+
+		&.bootstrap-switch-success {
+			background: $success;
+			color: #fff;
+		}
+
+		&.bootstrap-switch-warning {
+			background: $warning;
+			color: #fff;
+		}
+
+		&.bootstrap-switch-danger {
+			background: $danger;
+			color: #fff;
+		}
+	}
+
+	.bootstrap-switch-label {
+		text-align: center;
+		margin-top: -1px;
+		margin-bottom: -1px;
+		z-index: 100;
+		color: #333;
+		background: #fff;
+		padding: 8px 12px; //test https://github.com/Bttstrp/bootstrap-switch/issues/693
+	}
+
+	span::before {
+		content: "\200b";
+	}
+
+	.bootstrap-switch-handle-on {
+		border-bottom-left-radius: $bootstrap-switch-handle-border-radius;
+		border-top-left-radius: $bootstrap-switch-handle-border-radius;
+	}
+
+	.bootstrap-switch-handle-off {
+		border-bottom-right-radius: $bootstrap-switch-handle-border-radius;
+		border-top-right-radius: $bootstrap-switch-handle-border-radius;
+	}
+
+	input[type='radio'],
+	input[type='checkbox'] {
+		position: absolute !important;
+		top: 0;
+		left: 0;
+		margin: 0;
+		z-index: -1;
+		opacity: 0;
+		filter: alpha(opacity=0);
+		visibility: hidden;
+	}
+
+	&.bootstrap-switch-mini {
+
+		.bootstrap-switch-handle-on,
+		.bootstrap-switch-handle-off,
+		.bootstrap-switch-label {
+			padding: 1px 5px;
+			font-size: 12px;
+			line-height: 1.5;
+		}
+	}
+
+	&.bootstrap-switch-small {
+
+		.bootstrap-switch-handle-on,
+		.bootstrap-switch-handle-off,
+		.bootstrap-switch-label {
+
+			padding: 5px 10px;
+			font-size: 12px;
+			line-height: 1.5;
+		}
+	}
+
+	&.bootstrap-switch-large {
+
+		.bootstrap-switch-handle-on,
+		.bootstrap-switch-handle-off,
+		.bootstrap-switch-label {
+			padding: 6px 16px;
+			font-size: 18px;
+			line-height: 1.3333333;
+		}
+	}
+
+	&.bootstrap-switch-disabled,
+	&.bootstrap-switch-readonly,
+	&.bootstrap-switch-indeterminate {
+		cursor: default !important;
+	}
+
+	&.bootstrap-switch-disabled .bootstrap-switch-handle-on,
+	&.bootstrap-switch-readonly .bootstrap-switch-handle-on,
+	&.bootstrap-switch-indeterminate .bootstrap-switch-handle-on,
+	&.bootstrap-switch-disabled .bootstrap-switch-handle-off,
+	&.bootstrap-switch-readonly .bootstrap-switch-handle-off,
+	&.bootstrap-switch-indeterminate .bootstrap-switch-handle-off,
+	&.bootstrap-switch-disabled .bootstrap-switch-label,
+	&.bootstrap-switch-readonly .bootstrap-switch-label,
+	&.bootstrap-switch-indeterminate .bootstrap-switch-label {
+		opacity: 0.5;
+		filter: alpha(opacity=50);
+		cursor: default !important;
+	}
+
+	&.bootstrap-switch-animate .bootstrap-switch-container {
+		transition: margin-left 0.5s;
+	}
+
+	&.bootstrap-switch-inverse {
+		.bootstrap-switch-handle-on {
+			border-radius: 0 $bootstrap-switch-handle-border-radius $bootstrap-switch-handle-border-radius 0;
+		}
+
+		.bootstrap-switch-handle-off {
+			border-radius: $bootstrap-switch-handle-border-radius 0 0 $bootstrap-switch-handle-border-radius;
+		}
+	}
+
+	&.bootstrap-switch-focused {
+		border-color: #66afe9;
+		outline: 0;
+		box-shadow: inset 0 1px 1px rgba(0, 0, 0, .075), 0 0 8px rgba(102, 175, 233, 0.6);
+	}
+
+	&.bootstrap-switch-on .bootstrap-switch-label,
+	&.bootstrap-switch-inverse.bootstrap-switch-off .bootstrap-switch-label {
+		border-bottom-right-radius: $bootstrap-switch-handle-border-radius;
+		border-top-right-radius: $bootstrap-switch-handle-border-radius;
+	}
+
+	&.bootstrap-switch-off .bootstrap-switch-label,
+	&.bootstrap-switch-inverse.bootstrap-switch-on .bootstrap-switch-label {
+		border-bottom-left-radius: $bootstrap-switch-handle-border-radius;
+		border-top-left-radius: $bootstrap-switch-handle-border-radius;
+	}
+}

File diff suppressed because it is too large
+ 449 - 208
yarn.lock


Some files were not shown because too many files changed in this diff