This repository was archived by the owner on Oct 27, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- v1.0.0-beta.16
- v1.0.0-beta.13
- v1.0.0-beta.12
- v1.0.0-beta.11
- v1.0.0-beta.10
- v1.0.0-beta.9
- v1.0.0-beta.8
- v1.0.0-beta.7
- v1.0.0-beta.6
- v1.0.0-beta.5
- v1.0.0-beta.4
- v1.0.0-beta.3
- v1.0.0-beta.2
- v1.0.0-beta.1
- v1.0.0-alpha.15
- v1.0.0-alpha.14
- v1.0.0-alpha.13
- v1.0.0-alpha.12
- v1.0.0-alpha.11
- v1.0.0-alpha.10
- v1.0.0-alpha.9
- v1.0.0-alpha.8
- v1.0.0-alpha.7
- v1.0.0-alpha.6
- v1.0.0-alpha.5
- v1.0.0-alpha.4
- v1.0.0-alpha.3
- v1.0.0-alpha.2
- v1.0.0-alpha.1
- v1.0.0-alpha.0
- v0.0.10
pengshanglong
committed
May 14, 2020
1 parent
879ff8d
commit 2cf6336
Showing
7 changed files
with
260 additions
and
20 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,9 @@ | ||
export default { | ||
pages: [ | ||
'pages/index/index' | ||
], | ||
pages: ['pages/index/index'], | ||
window: { | ||
backgroundTextStyle: 'light', | ||
navigationBarBackgroundColor: '#fff', | ||
navigationBarTitleText: 'WeChat', | ||
navigationBarTextStyle: 'black' | ||
} | ||
navigationBarTextStyle: 'black', | ||
}, | ||
} |
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,143 @@ | ||
import Vue, { VNode } from 'vue' | ||
import classNames from 'classnames' | ||
import { CommonEvent } from '@tarojs/components/types/common' | ||
import mixins from '../mixins' | ||
|
||
function clampNumber(value: number, lower: number, upper: number): number { | ||
return Math.max(lower, Math.min(upper, value)) | ||
} | ||
|
||
const AtSlider = Vue.extend({ | ||
name: 'AtSlider', | ||
mixins: [mixins], | ||
props: { | ||
customStyle: { | ||
type: [Object, String], | ||
default: () => {}, | ||
}, | ||
className: { | ||
type: [Object, String], | ||
default: () => {}, | ||
}, | ||
min: { | ||
type: Number, | ||
default: 0, | ||
}, | ||
max: { | ||
type: Number, | ||
default: 100, | ||
}, | ||
step: { | ||
type: Number, | ||
default: 1, | ||
}, | ||
value: { | ||
type: Number, | ||
default: 0, | ||
}, | ||
disabled: { | ||
type: Boolean, | ||
default: false, | ||
}, | ||
activeColor: { | ||
type: String, | ||
default: '#6190e8', | ||
}, | ||
backgroundColor: { | ||
type: String, | ||
default: '#e9e9e9', | ||
}, | ||
blockSize: { | ||
type: Number, | ||
default: 28, | ||
}, | ||
blockColor: { | ||
type: String, | ||
default: '#ffffff', | ||
}, | ||
showValue: { | ||
type: Boolean, | ||
default: false, | ||
}, | ||
onChange: { | ||
type: Function, | ||
default: () => () => {}, | ||
}, | ||
onChanging: { | ||
type: Function, | ||
default: () => () => {}, | ||
}, | ||
}, | ||
data() { | ||
const { value, min, max } = this | ||
return { | ||
state: { | ||
_value: clampNumber(value, min, max), | ||
}, | ||
} | ||
}, | ||
methods: { | ||
clampNumber, | ||
handleChanging(e: CommonEvent): void { | ||
const { _value } = this.state | ||
const { value }: { value: number } = e.detail | ||
|
||
if (value !== _value) { | ||
this.setState({ _value: value }) | ||
} | ||
this.onChanging && this.onChanging(value) | ||
}, | ||
handleChange(e: CommonEvent): void { | ||
const { value } = e.detail | ||
|
||
this.setState({ _value: value }) | ||
this.onChange && this.onChange(value) | ||
}, | ||
}, | ||
render(): VNode { | ||
const { _value } = this.state | ||
const { | ||
customStyle, | ||
className, | ||
min, | ||
max, | ||
step, | ||
disabled, | ||
activeColor, | ||
backgroundColor, | ||
blockSize, | ||
blockColor, | ||
showValue, | ||
} = this | ||
|
||
return ( | ||
<view | ||
class={classNames( | ||
{ | ||
'at-slider': true, | ||
'at-slider--disabled': disabled, | ||
}, | ||
className | ||
)} | ||
style={customStyle}> | ||
<view class="at-slider__inner"> | ||
<slider | ||
min={min} | ||
max={max} | ||
step={step} | ||
value={_value} | ||
disabled={disabled} | ||
activeColor={activeColor} | ||
backgroundColor={backgroundColor} | ||
blockSize={blockSize} | ||
blockColor={blockColor} | ||
onChanging={this.handleChanging.bind(this)} | ||
onChange={this.handleChange.bind(this)}></slider> | ||
</view> | ||
{showValue && <view clas="at-slider__text">{`${_value}`}</view>} | ||
</view> | ||
) | ||
}, | ||
}) | ||
|
||
export default AtSlider |
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,79 @@ | ||
import Vue, { VNode } from 'vue' | ||
import classNames from 'classnames' | ||
import { CommonEvent } from '@tarojs/components/types/common' | ||
|
||
const AtSwitch = Vue.extend({ | ||
name: 'AtSwitch', | ||
props: { | ||
customStyle: { | ||
type: [Object, String], | ||
default: () => {}, | ||
}, | ||
className: { | ||
type: [Object, String], | ||
default: () => {}, | ||
}, | ||
title: { | ||
type: String, | ||
default: '', | ||
}, | ||
color: { | ||
type: String, | ||
default: '#6190e8', | ||
}, | ||
border: { | ||
type: Boolean, | ||
default: true, | ||
}, | ||
disabled: { | ||
type: Boolean, | ||
default: false, | ||
}, | ||
checked: { | ||
type: Boolean, | ||
default: false, | ||
}, | ||
onChange: { | ||
type: Function, | ||
default: () => () => {}, | ||
}, | ||
}, | ||
methods: { | ||
handleChange(event: CommonEvent): void { | ||
const { value, checked } = event.detail | ||
const state = typeof value === 'undefined' ? checked : value | ||
this.onChange && this.onChange(state) | ||
}, | ||
}, | ||
render(): VNode { | ||
const { customStyle, className, disabled, border, title, checked, color } = this | ||
|
||
const rootCls = classNames( | ||
'at-switch', | ||
{ | ||
'at-switch--without-border': !border, | ||
}, | ||
className | ||
) | ||
const containerCls = classNames('at-switch__container', { | ||
'at-switch--disabled': disabled, | ||
}) | ||
|
||
return ( | ||
<view class={rootCls} style={customStyle}> | ||
<view class="at-switch__title">{title}</view> | ||
<view class={containerCls}> | ||
<view class="at-switch__mask"></view> | ||
<switch | ||
class="at-switch__switch" | ||
checked={checked} | ||
color={color} | ||
onChange={this.handleChange} | ||
/> | ||
</view> | ||
</view> | ||
) | ||
}, | ||
}) | ||
|
||
export default AtSwitch |
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 @@ | ||
;<template> | ||
<view> | ||
<text>demo</text> | ||
<slider /> | ||
<switch /> | ||
</view> | ||
</template> |
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