Skip to content

Commit e0ba8b7

Browse files
authored
Merge pull request #1473 from TaleLin/develop
chore: 升级版本 0.9.7
2 parents 516bc1a + 2527db3 commit e0ba8b7

File tree

25 files changed

+291
-3
lines changed

25 files changed

+291
-3
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,6 @@ yarn-error.log
1919
.vscode
2020
package-lock.json
2121
examples/project.config.json
22+
examples/project.private.config.json
2223
/.run
2324
yarn.lock

commitlint.config.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,8 @@ module.exports = {
7575
'TabBar',
7676
'DynamicBuild',
7777
'Calendar',
78-
'Script'
78+
'Script',
79+
'Switch'
7980
]
8081
]
8182
}

dist/switch/index.js

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

dist/switch/index.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"component":true,"usingComponents":{}}

dist/switch/index.wxml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<view class="switch {{disabled ? 'switch-disabled l-disabled-class' : 'l-class'}} {{ checked === activeValue ? 'switch-on' : '' }}" style="background-color:{{checked === activeValue ? selectColor : color}};font-size:{{size}};" bind:tap="onClick">
2+
<view class="switch-node"></view>
3+
</view>

dist/switch/index.wxss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.switch{position:relative;display:inline-block;box-sizing:content-box;width:2em;height:1em;background-color:#fff;border:1px solid rgba(0,0,0,.1);border-radius:1em;transition:background-color .3s}.switch-node{position:absolute;top:0;left:0;border-radius:100%;z-index:1;width:1em;height:1em;background-color:#fff;box-shadow:0 3px 1px 0 rgba(0,0,0,.05),0 2px 2px 0 rgba(0,0,0,.1),0 3px 3px 0 rgba(0,0,0,.05);transition:.3s cubic-bezier(.3,1.05,.4,1.05)}.switch-on .switch-node{transform:translateX(calc(1em))}.switch-disabled{opacity:.5}

examples/app.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@
9393
{
9494
"root": "pages/components/form",
9595
"pages": [
96+
"pages/switch/index",
9697
"pages/input/index",
9798
"pages/radio/index",
9899
"pages/checkbox/index",

examples/dist/switch/index.js

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
import eventBus from '../core/utils/event-bus';
2+
3+
Component({
4+
externalClasses: ['l-class', 'l-disabled-class'],
5+
properties: {
6+
checked: {
7+
type: null,
8+
optionalTypes: [Boolean, String, Number],
9+
value: false
10+
},
11+
size: {
12+
type: String,
13+
value: '38rpx'
14+
},
15+
color: {
16+
type: String,
17+
value: '#fff'
18+
},
19+
// 选中后的颜色
20+
selectColor: {
21+
type: String,
22+
value: '#3963BC'
23+
},
24+
activeValue: {
25+
type: null,
26+
value: true,
27+
},
28+
inactiveValue: {
29+
type: null,
30+
value: false,
31+
},
32+
// 不可选状态
33+
disabled: {
34+
type: Boolean,
35+
value: false
36+
},
37+
},
38+
methods: {
39+
onClick() {
40+
const { activeValue, inactiveValue, disabled } = this.data;
41+
42+
if (disabled) {
43+
return;
44+
}
45+
46+
const checked = this.data.checked === activeValue;
47+
const value = checked ? inactiveValue : activeValue;
48+
49+
this.setData({
50+
checked: value
51+
});
52+
53+
this.triggerEvent('linchange', { checked: value });
54+
eventBus.emit(`lin-form-change-${this.id}`, this.id);
55+
},
56+
57+
getValues() {
58+
return this.data.checked;
59+
},
60+
61+
reset() {
62+
this.setData({
63+
checked: this.data.inactiveValue
64+
});
65+
}
66+
}
67+
});

examples/dist/switch/index.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"component": true,
3+
"usingComponents": {}
4+
}

examples/dist/switch/index.wxml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<view
2+
class="switch {{disabled ? 'switch-disabled l-disabled-class' : 'l-class'}} {{ checked === activeValue ? 'switch-on' : '' }}"
3+
style="background-color:{{checked === activeValue ? selectColor : color}};font-size:{{size}};"
4+
bind:tap="onClick">
5+
<view class="switch-node"></view>
6+
</view>

0 commit comments

Comments
 (0)