Skip to content

Commit

Permalink
feat(base): 按钮样式
Browse files Browse the repository at this point in the history
  • Loading branch information
cos2004 committed Jul 19, 2018
1 parent 9a8da97 commit af0158d
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 10 deletions.
11 changes: 8 additions & 3 deletions src/components/button/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import Taro from "@tarojs/taro"
import { View } from "@tarojs/components"
import { AtIcon } from "../icon/index"

import './index.scss'

Expand All @@ -24,8 +25,8 @@ export default class AtButton extends Taro.Component {
}

onClick(e) {
if (!this.props.disabled) {
this.props.onClick && this.props.onClick(e)
if (!this.props.disabled && this.props.onClick) {
this.props.onClick(e)
}
}

Expand All @@ -43,12 +44,16 @@ export default class AtButton extends Taro.Component {
let disabledClass = disabled? 'at-button--disabled': ''
let typeClass = TYPE_CLASS[type]? `at-button--${type}`: ''
let activeClass = active? 'at-button--active': ''
// let loadingClass = loading? 'at-button--loading': ''
// let iconClass = loading? 'at-button--icon': ''

rootClassName.push(`at-button--${sizeClass}`, disabledClass, typeClass, activeClass)
rootClassName = rootClassName.filter(str => str != '')
// console.log(this.props, this.state)
console.log('loading====', loading)
return (
<View className={rootClassName} onClick={this.onClick.bind(this)}>
{loading && <AtIcon value="arrow-left"></AtIcon>}
{icon && <AtIcon value={icon}></AtIcon>}
{this.props.children}
</View>
)
Expand Down
4 changes: 2 additions & 2 deletions src/components/icon/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export default class AtIcon extends Taro.Component {
}

render() {
let { value, size = 24, color = '#000'} = this.props
let { value = '', size = 24, color = '#000'} = this.props

const rootStyle = {
// width: `${+size}px`,
Expand All @@ -19,7 +19,7 @@ export default class AtIcon extends Taro.Component {
}

let rootClassName = ['at-icon', `at-icon-${value}`]

console.log('value====',value)
return (
<View className={rootClassName} style={rootStyle}></View>
)
Expand Down
10 changes: 5 additions & 5 deletions src/pages/view/button/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,7 @@ export default class ButtonPage extends Taro.Component {
constructor() {
super(...arguments)
this.state = {
// icons: [
// 'arrow-left',
// 'arrow-down-left',
// ]

}
}

Expand All @@ -32,7 +29,10 @@ export default class ButtonPage extends Taro.Component {
<AtButton type="primary" onClick={this.onButtonClick.bind(this)}>页面主操作</AtButton>
</View>
<View className='example'>
<AtButton type="primary" onClick={this.onButtonClick.bind(this)}>带icon</AtButton>
<AtButton type="primary" loading onClick={this.onButtonClick.bind(this)}>带loading</AtButton>
</View>
<View className='example'>
<AtButton type="primary" icon="arrow-left" onClick={this.onButtonClick.bind(this)}>带icon</AtButton>
</View>
<View className='example'>
<AtButton type="primary" active onClick={this.onButtonClick.bind(this)}>点击态</AtButton>
Expand Down

0 comments on commit af0158d

Please sign in to comment.