|
1 | 1 | <style> |
2 | | -:host { |
3 | | - display: inline-block; |
4 | | -} |
| 2 | + :host { |
| 3 | + display: inline-block; |
| 4 | + } |
5 | 5 |
|
6 | | -label { |
7 | | - position: relative; |
8 | | - margin: 0; |
9 | | -} |
| 6 | + label { |
| 7 | + position: relative; |
| 8 | + margin: 0; |
| 9 | + } |
10 | 10 |
|
11 | | -span { |
12 | | - display: inline-block; |
13 | | - font-weight: normal; |
14 | | - line-height: 20px; |
15 | | - margin: 0 4px; |
16 | | - min-height: 24px; |
17 | | - min-width: 18px; |
18 | | - position: relative; |
19 | | -} |
| 11 | + span { |
| 12 | + display: inline-block; |
| 13 | + font-weight: normal; |
| 14 | + line-height: 20px; |
| 15 | + margin: 0 4px; |
| 16 | + min-height: 24px; |
| 17 | + min-width: 18px; |
| 18 | + position: relative; |
| 19 | + } |
20 | 20 |
|
21 | | -span::before { |
22 | | - font-family: Arial, Helvetica, sans-serif; |
23 | | - border-style: solid; |
24 | | - border-width: 1px; |
25 | | - box-shadow: inset 0px 2px 2px 0px rgba(0, 0, 0, .2); |
26 | | - color: #999999; |
27 | | - display: inline-block; |
28 | | - font-weight: bold; |
29 | | - height: 20px; |
30 | | - margin-right: 8px; |
31 | | - overflow: hidden; |
32 | | - padding: 0; |
33 | | - position: relative; |
34 | | - text-align: left; |
35 | | - text-indent: -19px; |
36 | | - top: 5px; |
37 | | - transition: text-indent .4s ease; |
38 | | - width: 52px; |
39 | | -} |
| 21 | + span::before { |
| 22 | + font-family: Arial, Helvetica, sans-serif; |
| 23 | + border-style: solid; |
| 24 | + border-width: 1px; |
| 25 | + box-shadow: inset 0px 2px 2px 0px rgba(0, 0, 0, .2); |
| 26 | + color: #999999; |
| 27 | + display: inline-block; |
| 28 | + font-weight: bold; |
| 29 | + height: 20px; |
| 30 | + margin-right: 8px; |
| 31 | + overflow: hidden; |
| 32 | + padding: 0; |
| 33 | + position: relative; |
| 34 | + text-align: left; |
| 35 | + text-indent: -19px; |
| 36 | + top: 5px; |
| 37 | + transition: text-indent .4s ease; |
| 38 | + width: 52px; |
| 39 | + } |
40 | 40 |
|
41 | | -span::after { |
42 | | - -webkit-box-shadow: 0px 1px 1px 1px rgba(0, 0, 0, .3); |
43 | | - -webkit-transition: left .4s ease; |
44 | | - box-shadow: 0px 1px 1px 1px rgba(0, 0, 0, .3); |
45 | | - font-family: Arial, Helvetica, sans-serif; |
46 | | - font-size: 10px; |
47 | | - font-weight: lighter; |
48 | | - left: -3px; |
49 | | - line-height: 20px; |
50 | | - height: 22px; |
51 | | - padding: 0; |
52 | | - position: absolute; |
53 | | - text-align: center; |
54 | | - text-shadow: -1px 0px 0 rgba(0, 0, 0, 0.15); |
55 | | - top: 4px; |
56 | | - transition: left .4s ease; |
57 | | - width: 22px; |
58 | | -} |
| 41 | + span::after { |
| 42 | + -webkit-box-shadow: 0px 1px 1px 1px rgba(0, 0, 0, .3); |
| 43 | + -webkit-transition: left .4s ease; |
| 44 | + box-shadow: 0px 1px 1px 1px rgba(0, 0, 0, .3); |
| 45 | + font-family: Arial, Helvetica, sans-serif; |
| 46 | + font-size: 10px; |
| 47 | + font-weight: lighter; |
| 48 | + left: -3px; |
| 49 | + line-height: 20px; |
| 50 | + height: 22px; |
| 51 | + padding: 0; |
| 52 | + position: absolute; |
| 53 | + text-align: center; |
| 54 | + text-shadow: -1px 0px 0 rgba(0, 0, 0, 0.15); |
| 55 | + top: 4px; |
| 56 | + transition: left .4s ease; |
| 57 | + width: 22px; |
| 58 | + } |
59 | 59 |
|
60 | | -input { |
61 | | - cursor: pointer; |
62 | | - height: 25px; |
63 | | - opacity: 0; |
64 | | - position: absolute; |
65 | | - width: 55px; |
66 | | -} |
| 60 | + input { |
| 61 | + cursor: pointer; |
| 62 | + height: 25px; |
| 63 | + opacity: 0; |
| 64 | + position: absolute; |
| 65 | + width: 55px; |
| 66 | + } |
67 | 67 |
|
68 | | -input:checked + span::before { |
69 | | - text-indent: 9px; |
70 | | -} |
| 68 | + input:checked + span::before { |
| 69 | + text-indent: 9px; |
| 70 | + } |
71 | 71 |
|
72 | | -input:checked + span::after { |
73 | | - left: 34px; |
74 | | -} |
| 72 | + input:checked + span::after { |
| 73 | + left: 34px; |
| 74 | + } |
75 | 75 | </style> |
76 | | -<script form observe="checked,disabled,name,readonly,required,value"> |
| 76 | +<script> |
77 | 77 | import StyleSet from '@stackpress/ink/dist/style/StyleSet'; |
78 | 78 | import { getHandlers } from '../utilities/option'; |
79 | 79 | //get props |
80 | 80 | const { |
81 | 81 | error, rounded, onoff, |
82 | 82 | yesno, checkex, sunmoon, |
83 | 83 | ridge, smooth, blue, |
84 | | - orange, green, change, |
85 | | - update, label = '', |
86 | | - //we dont need these |
87 | | - 'class': _, style, |
88 | | - ...attributes |
| 84 | + orange, green, label = '', |
| 85 | + name, value, checked, |
| 86 | + //event handlers |
| 87 | + change, update, click, |
89 | 88 | } = this.props; |
90 | 89 | //override default styles |
91 | 90 | const styles = new StyleSet(); |
@@ -170,13 +169,18 @@ input:checked + span::after { |
170 | 169 | } |
171 | 170 |
|
172 | 171 | //handlers |
173 | | - const handlers = getHandlers(this, change, update); |
| 172 | + const handlers = getHandlers(this, click, change, update); |
174 | 173 | </script> |
175 | | -<label mount={handlers.mount}> |
176 | | - <input |
177 | | - {...attributes} |
178 | | - type="checkbox" |
179 | | - change={handlers.change} |
180 | | - /> |
181 | | - <span >{label}</span> |
182 | | -</label> |
| 174 | +<template type="light"> |
| 175 | + <input type="checkbox" name={name} value={value} checked={checked} /> |
| 176 | +</template> |
| 177 | +<template type="shadow"> |
| 178 | + <label> |
| 179 | + <input |
| 180 | + type="checkbox" |
| 181 | + change={handlers.change} |
| 182 | + checked={checked} |
| 183 | + /> |
| 184 | + <span>{label}</span> |
| 185 | + </label> |
| 186 | +</template> |
0 commit comments