@lemonadejs/switch 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js ADDED
@@ -0,0 +1,29 @@
1
+ if (!lemonade && typeof (require) === 'function') {
2
+ var lemonade = require('lemonadejs');
3
+ }
4
+
5
+ ; (function (global, factory) {
6
+ typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
7
+ typeof define === 'function' && define.amd ? define(factory) :
8
+ global.Switch = factory();
9
+ }(this, (function () {
10
+ const Switch = function () {
11
+ let self = this;
12
+
13
+ return `<label class="lm-switch">
14
+ <input type="checkbox" name="{{self.name}}" disabled="{{self.disabled}}" :checked="self.checked" :value="self.value"> <span>{{self.text}}</span>
15
+ </label>`
16
+ }
17
+
18
+ lemonade.setComponents({ Switch: Switch });
19
+
20
+ return function (root, options) {
21
+ if (typeof (root) === 'object') {
22
+ lemonade.render(Tabs, root, options, template)
23
+ return options;
24
+ } else {
25
+ return Switch.call(this, root);
26
+ }
27
+ }
28
+
29
+ })));
package/dist/style.css ADDED
@@ -0,0 +1,122 @@
1
+ .lm-switch {
2
+ position: relative;
3
+ display: inline-block;
4
+ z-index: 0;
5
+ }
6
+
7
+ .lm-switch > input {
8
+ appearance: none;
9
+ -moz-appearance: none;
10
+ -webkit-appearance: none;
11
+ z-index: -1;
12
+ position: absolute;
13
+ right: 6px;
14
+ top: -8px;
15
+ display: block;
16
+ margin: 0;
17
+ border-radius: 50%;
18
+ width: 40px;
19
+ height: 40px;
20
+ outline: none;
21
+ opacity: 0;
22
+ transform: scale(1);
23
+ pointer-events: none;
24
+ transition: opacity 0.3s 0.1s, transform 0.2s 0.1s;
25
+ }
26
+
27
+ .lm-switch > span {
28
+ display: inline-block;
29
+ width: 100%;
30
+ line-height: 24px;
31
+ cursor: pointer;
32
+ margin: 0 5px 0 0;
33
+ }
34
+
35
+ .lm-switch > span:empty {
36
+ margin: 0;
37
+ }
38
+
39
+ .lm-switch > span::before {
40
+ content: "";
41
+ float: right;
42
+ display: inline-block;
43
+ margin: 5px 0 5px 0;
44
+ border-radius: 7px;
45
+ width: 36px;
46
+ height: 14px;
47
+ background-color: rgba(var(--lm-switch-front-color, 0,0,0), 0.38);
48
+ vertical-align: top;
49
+ transition: background-color 0.2s, opacity 0.2s;
50
+ }
51
+
52
+ .lm-switch > span::after {
53
+ content: "";
54
+ position: absolute;
55
+ top: 2px;
56
+ right: 16px;
57
+ border-radius: 50%;
58
+ width: 20px;
59
+ height: 20px;
60
+ background-color: rgb(var(---lm-switch-primary-color, 255,255,255));
61
+ box-shadow: 0 3px 1px -2px rgba(0, 0, 0, 0.2), 0 2px 2px 0 rgba(0, 0, 0, 0.14), 0 1px 5px 0 rgba(0, 0, 0, 0.12);
62
+ transition: background-color 0.2s, transform 0.2s;
63
+ }
64
+
65
+ .lm-switch > input:checked {
66
+ right: -10px;
67
+ background-color: rgb(var(--pure-material-primary-rgb, 33,150,243));
68
+ }
69
+
70
+ .lm-switch > input:checked + span::before {
71
+ background-color: rgba(var(--pure-material-primary-rgb, 33,150,243), 0.6);
72
+ }
73
+
74
+ .lm-switch > input:checked + span::after {
75
+ background-color: rgb(var(--pure-material-primary-rgb, 33,150,243));
76
+ transform: translateX(16px);
77
+ }
78
+
79
+ /* Hover, Focus */
80
+ .lm-switch:hover > input {
81
+ opacity: 0.04;
82
+ }
83
+
84
+ .lm-switch > input:focus {
85
+ opacity: 0.12;
86
+ }
87
+
88
+ .lm-switch:hover > input:focus {
89
+ opacity: 0.16;
90
+ }
91
+
92
+ .lm-switch > input:active {
93
+ opacity: 1;
94
+ transform: scale(0);
95
+ transition: transform 0s, opacity 0s;
96
+ }
97
+
98
+ .lm-switch > input:active + span::before {
99
+ background-color: rgba(var(--pure-material-primary-rgb, 33,150,243), 0.6);
100
+ }
101
+
102
+ .lm-switch > input:checked:active + span::before {
103
+ background-color: rgba(var(--lm-switch-front-color, 0,0,0), 0.38);
104
+ }
105
+
106
+ .lm-switch > input:disabled {
107
+ opacity: 0;
108
+ }
109
+
110
+ .lm-switch > input:disabled + span {
111
+ color: rgb(var(--lm-switch-front-color,0,0,0));
112
+ opacity: 0.38;
113
+ cursor: default;
114
+ }
115
+
116
+ .lm-switch > input:disabled + span::before {
117
+ background-color: rgba(var(--lm-switch-front-color,0,0,0), 0.38);
118
+ }
119
+
120
+ .lm-switch > input:checked:disabled + span::before {
121
+ background-color: rgba(var(--pure-material-primary-rgb,33,150,243), 0.6);
122
+ }
package/package.json ADDED
@@ -0,0 +1,20 @@
1
+ {
2
+ "name": "@lemonadejs/switch",
3
+ "title": "JavaScript Switch",
4
+ "description": "LemonadeJS JavaScript reactive material switch",
5
+ "author": {
6
+ "name": "Contact <contact@lemonadejs.net>",
7
+ "url": "https://lemonadejs.net"
8
+ },
9
+ "keywords": [
10
+ "javascript switch",
11
+ "lemonadejs switch",
12
+ "js switch",
13
+ "switch js"
14
+ ],
15
+ "dependencies": {
16
+ "lemonadejs": "^4.0.7"
17
+ },
18
+ "main": "dist/index.js",
19
+ "version": "1.0.0"
20
+ }