-
-
Notifications
You must be signed in to change notification settings - Fork 487
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1473 from TaleLin/develop
chore: 升级版本 0.9.7
- Loading branch information
Showing
25 changed files
with
291 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -75,7 +75,8 @@ module.exports = { | |
'TabBar', | ||
'DynamicBuild', | ||
'Calendar', | ||
'Script' | ||
'Script', | ||
'Switch' | ||
] | ||
] | ||
} | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"component":true,"usingComponents":{}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<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"> | ||
<view class="switch-node"></view> | ||
</view> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +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} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
import eventBus from '../core/utils/event-bus'; | ||
|
||
Component({ | ||
externalClasses: ['l-class', 'l-disabled-class'], | ||
properties: { | ||
checked: { | ||
type: null, | ||
optionalTypes: [Boolean, String, Number], | ||
value: false | ||
}, | ||
size: { | ||
type: String, | ||
value: '38rpx' | ||
}, | ||
color: { | ||
type: String, | ||
value: '#fff' | ||
}, | ||
// 选中后的颜色 | ||
selectColor: { | ||
type: String, | ||
value: '#3963BC' | ||
}, | ||
activeValue: { | ||
type: null, | ||
value: true, | ||
}, | ||
inactiveValue: { | ||
type: null, | ||
value: false, | ||
}, | ||
// 不可选状态 | ||
disabled: { | ||
type: Boolean, | ||
value: false | ||
}, | ||
}, | ||
methods: { | ||
onClick() { | ||
const { activeValue, inactiveValue, disabled } = this.data; | ||
|
||
if (disabled) { | ||
return; | ||
} | ||
|
||
const checked = this.data.checked === activeValue; | ||
const value = checked ? inactiveValue : activeValue; | ||
|
||
this.setData({ | ||
checked: value | ||
}); | ||
|
||
this.triggerEvent('linchange', { checked: value }); | ||
eventBus.emit(`lin-form-change-${this.id}`, this.id); | ||
}, | ||
|
||
getValues() { | ||
return this.data.checked; | ||
}, | ||
|
||
reset() { | ||
this.setData({ | ||
checked: this.data.inactiveValue | ||
}); | ||
} | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"component": true, | ||
"usingComponents": {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<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"> | ||
<view class="switch-node"></view> | ||
</view> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +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} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// pages/components/form/pages/switch/index.js | ||
Page({ | ||
/** | ||
* 页面的初始数据 | ||
*/ | ||
data: { | ||
customValue: 0 | ||
}, | ||
|
||
onChange(e) { | ||
this.setData({ | ||
customValue: e.detail.checked | ||
}); | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"usingComponents": { | ||
"content-title": "/components/content-title/index", | ||
"content-card": "/components/content-card/index", | ||
"l-switch": "/dist/switch/index" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<!--pages/components/form/pages/switch/index.wxml--> | ||
<view class='container'> | ||
<content-title name="Switch" describe="开关"> | ||
<content-card | ||
class="content" | ||
name="基本案例" | ||
> | ||
<l-switch /> | ||
|
||
</content-card> | ||
|
||
<!-- 设置禁用 --> | ||
<content-card | ||
class="content" | ||
name="设置禁用" | ||
> | ||
<l-switch disabled /> | ||
</content-card> | ||
|
||
<content-card | ||
class="content" | ||
name="自定义大小" | ||
> | ||
<l-switch size="50rpx" /> | ||
</content-card> | ||
|
||
<content-card | ||
class="content" | ||
name="自定义颜色" | ||
> | ||
<l-switch color="#ccc" select-color="#34BFA3"/> | ||
</content-card> | ||
|
||
<content-card | ||
class="content" | ||
name="自定义打开或关闭的值" | ||
> | ||
<l-switch checked="{{ customValue }}" active-value="{{ 1 }}" inactive-value="{{ 0 }}" bind:linchange="onChange"/> | ||
<view>当前选中的值:{{ customValue }}</view> | ||
</content-card> | ||
</content-title> | ||
</view> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/* pages/components/form/pages/switch/index.wxss */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
import eventBus from '../core/utils/event-bus'; | ||
|
||
Component({ | ||
externalClasses: ['l-class', 'l-disabled-class'], | ||
properties: { | ||
checked: { | ||
type: null, | ||
optionalTypes: [Boolean, String, Number], | ||
value: false | ||
}, | ||
size: { | ||
type: String, | ||
value: '38rpx' | ||
}, | ||
color: { | ||
type: String, | ||
value: '#fff' | ||
}, | ||
// 选中后的颜色 | ||
selectColor: { | ||
type: String, | ||
value: '#3963BC' | ||
}, | ||
activeValue: { | ||
type: null, | ||
value: true, | ||
}, | ||
inactiveValue: { | ||
type: null, | ||
value: false, | ||
}, | ||
// 不可选状态 | ||
disabled: { | ||
type: Boolean, | ||
value: false | ||
}, | ||
}, | ||
methods: { | ||
onClick() { | ||
const { activeValue, inactiveValue, disabled } = this.data; | ||
|
||
if (disabled) { | ||
return; | ||
} | ||
|
||
const checked = this.data.checked === activeValue; | ||
const value = checked ? inactiveValue : activeValue; | ||
|
||
this.setData({ | ||
checked: value | ||
}); | ||
|
||
this.triggerEvent('linchange', { checked: value }); | ||
eventBus.emit(`lin-form-change-${this.id}`, this.id); | ||
}, | ||
|
||
getValues() { | ||
return this.data.checked; | ||
}, | ||
|
||
reset() { | ||
this.setData({ | ||
checked: this.data.inactiveValue | ||
}); | ||
} | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"component": true, | ||
"usingComponents": {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
.switch { | ||
position: relative; | ||
display: inline-block; | ||
box-sizing: content-box; | ||
width: 2em; | ||
height: 1em; | ||
background-color: #fff; | ||
border: 1px solid rgba(0, 0, 0, 0.1); | ||
border-radius: 1em; | ||
transition: background-color 0.3s; | ||
|
||
&-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, 0.05), | ||
0 2px 2px 0 rgba(0, 0, 0, 0.1), 0 3px 3px 0 rgba(0, 0, 0, 0.05); | ||
transition: 0.3s cubic-bezier(0.3, 1.05, 0.4, 1.05); | ||
} | ||
|
||
&-on { | ||
.switch-node { | ||
transform: translateX(calc(1em)); | ||
} | ||
} | ||
|
||
&-disabled { | ||
opacity: 0.5; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<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"> | ||
<view class="switch-node"></view> | ||
</view> |