Skip to content

Commit

Permalink
feat: 组件改为继承自 AtComponent 基类
Browse files Browse the repository at this point in the history
  • Loading branch information
koppthe committed Aug 29, 2018
1 parent ec822bc commit 87de708
Show file tree
Hide file tree
Showing 24 changed files with 69 additions and 30 deletions.
4 changes: 3 additions & 1 deletion src/components/avatar/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import Taro from '@tarojs/taro'
import { View, Image, Text } from '@tarojs/components'
import PropTypes from 'prop-types'

import AtComponent from '../../common/component'

import './index.scss'

const SIZE_CLASS = {
Expand All @@ -10,7 +12,7 @@ const SIZE_CLASS = {
small: 'small',
}

export default class AtAvatar extends Taro.Component {
export default class AtAvatar extends AtComponent {
constructor () {
super(...arguments)
this.state = {
Expand Down
4 changes: 3 additions & 1 deletion src/components/badge/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@ import PropTypes from 'prop-types'
import Taro from '@tarojs/taro'
import { View } from '@tarojs/components'
import isNaN from 'lodash/isNaN'

import AtComponent from '../../common/component'
import './index.scss'


export default class AtBadge extends Taro.Component {
export default class AtBadge extends AtComponent {
constructor () {
super(...arguments)
this.state = {}
Expand Down
3 changes: 2 additions & 1 deletion src/components/button/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { View } from '@tarojs/components'
import PropTypes from 'prop-types'
import AtLoading from '../loading/index'

import AtComponent from '../../common/component'
import './index.scss'

const SIZE_CLASS = {
Expand All @@ -17,7 +18,7 @@ const TYPE_CLASS = {
}


export default class AtButton extends Taro.Component {
export default class AtButton extends AtComponent {
constructor () {
super(...arguments)
this.state = {
Expand Down
4 changes: 3 additions & 1 deletion src/components/checkbox/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import Taro from '@tarojs/taro'
import { View } from '@tarojs/components'
import PropTypes from 'prop-types'

import AtIcon from '../../components/icon/index'
import AtComponent from '../../common/component'
import './index.scss'

/**
Expand All @@ -11,7 +13,7 @@ import './index.scss'
* @prop selectedList {Array} 被选中的选项列表 eg: ['苹果']
* @prop options {Array} 选项列表 eg: [{value:'apple', label: '苹果', desc:'这个苹果又大又甜'}]
*/
class AtCheckbox extends Taro.Component {
class AtCheckbox extends AtComponent {
handleClick (option) {
if (option.disabled) return
const value = option.value
Expand Down
5 changes: 3 additions & 2 deletions src/components/drawer/index.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import Taro from '@tarojs/taro'
import { View } from '@tarojs/components'
import PropTypes from 'prop-types'

import AtList from '../list/index'
import AtListItem from '../list/item/index'

import AtComponent from '../../common/component'
import './index.scss'

export default class AtDrawer extends Taro.Component {
export default class AtDrawer extends AtComponent {
constructor () {
super(...arguments)
this.state = { animShow: false }
Expand Down
4 changes: 3 additions & 1 deletion src/components/form/index.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import Taro from '@tarojs/taro'
import { View } from '@tarojs/components'
import PropTypes from 'prop-types'

import AtComponent from '../../common/component'
import './index.scss'

class AtForm extends Taro.Component {
class AtForm extends AtComponent {
render () {
return <View className='at-form' style={this.props.style}>
{this.props.children}
Expand Down
4 changes: 3 additions & 1 deletion src/components/icon/index.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import Taro from '@tarojs/taro'
import PropTypes from 'prop-types'
import { Text } from '@tarojs/components'

import AtComponent from '../../common/component'
import './index.scss'

export default class AtIcon extends Taro.Component {
export default class AtIcon extends AtComponent {
handleClick () {
this.props.onClick(...arguments)
}
Expand Down
4 changes: 3 additions & 1 deletion src/components/input-number/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import Taro from '@tarojs/taro'
import { View, Input } from '@tarojs/components'
import PropTypes from 'prop-types'

import AtIcon from '../../components/icon/index'
import AtComponent from '../../common/component'
import './index.scss'

/**
Expand All @@ -14,7 +16,7 @@ import './index.scss'
* @prop disabled {Boolean} 是否禁止点击 default: false
* @prop onChange {Function} 监听事件改变函数
*/
class AtInputNumber extends Taro.Component {
class AtInputNumber extends AtComponent {
// 实现两数相加并保留小数点后最短尾数
static addNum (num1, num2) {
let sq1, sq2
Expand Down
5 changes: 4 additions & 1 deletion src/components/input/index.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import Taro from '@tarojs/taro'
import { View, Input, Label } from '@tarojs/components'
import PropTypes from 'prop-types'

import AtIcon from '../../components/icon/index'
import AtComponent from '../../common/component'
import './index.scss'

/**
* @author:chenzeji
* @description 单行输入框
Expand All @@ -26,7 +29,7 @@ import './index.scss'
* @prop onConfirm {Function} 点击完成按钮时触发
* @prop onErrorClick {Function} 点击错误按钮触发的事件
*/
class AtInput extends Taro.Component {
class AtInput extends AtComponent {
handleInput (e) {
this.props.onChange(e.target.value, ...arguments)
}
Expand Down
4 changes: 3 additions & 1 deletion src/components/loading/index.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import Taro from '@tarojs/taro'
import PropTypes from 'prop-types'
import { View } from '@tarojs/components'

import AtComponent from '../../common/component'
import './index.scss'

class AtLoading extends Taro.Component {
class AtLoading extends AtComponent {
render () {
const { color, size } = this.props
const sizeStyle = {
Expand Down
4 changes: 3 additions & 1 deletion src/components/nav-bar/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import Taro from '@tarojs/taro'
import { View, Text } from '@tarojs/components'
import PropTypes from 'prop-types'

import AtIcon from '../../components/icon/index'
import AtComponent from '../../common/component'
import './index.scss'

/**
Expand All @@ -18,7 +20,7 @@ import './index.scss'
* @prop onClickRightFirstIcon {Function} 从右到左第一个图标类型点击事件
* @prop onClickRightSecondIcon {Function} 从右到左第二个图标类型点击事件
*/
class AtNavBar extends Taro.Component {
class AtNavBar extends AtComponent {
handleClickLeftView () {
this.props.onClickLeftIcon(...arguments)
}
Expand Down
5 changes: 3 additions & 2 deletions src/components/noticebar/index.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import PropTypes from 'prop-types'
import Taro from '@tarojs/taro'
import { View, Text } from '@tarojs/components'
import AtIcon from '../icon/index'

import AtComponent from '../../common/component'
import AtIcon from '../icon/index'
import './index.scss'

export default class AtNoticebar extends Taro.Component {
export default class AtNoticebar extends AtComponent {
constructor () {
super(...arguments)
const animElemId = `J_${Math.ceil(Math.random() * 10e5).toString(36)}`
Expand Down
5 changes: 3 additions & 2 deletions src/components/pagination/index.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import Taro from '@tarojs/taro'
import { View, Text } from '@tarojs/components'
import PropTypes from 'prop-types'

import AtButton from '../button/index'
import AtIcon from '../icon/index'

import AtComponent from '../../common/component'
import './index.scss'

export default class AtPagination extends Taro.Component {
export default class AtPagination extends AtComponent {
constructor () {
super(...arguments)
let { current, pageSize, total } = this.props
Expand Down
4 changes: 3 additions & 1 deletion src/components/radio/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import Taro from '@tarojs/taro'
import { View } from '@tarojs/components'
import PropTypes from 'prop-types'

import AtIcon from '../../components/icon/index'
import AtComponent from '../../common/component'
import './index.scss'

/**
Expand All @@ -11,7 +13,7 @@ import './index.scss'
* @prop options {Array} 选项列表 eg:[{label:'苹果',value:'apple'}]
* @prop onClick {Function} 点击选项触发事件
*/
class AtRadio extends Taro.Component {
class AtRadio extends AtComponent {
handleClick (option) {
if (option.disabled) return
this.props.onClick(option.value, ...arguments)
Expand Down
4 changes: 3 additions & 1 deletion src/components/rate/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import Taro from '@tarojs/taro'
import { View } from '@tarojs/components'
import PropTypes from 'prop-types'

import AtIcon from '../../components/icon/index'
import AtComponent from '../../common/component'
import './index.scss'

/**
Expand All @@ -13,7 +15,7 @@ import './index.scss'
* @prop margin {Number} 星星间隔,单位根据环境转为rpx或rem default:5
* @prop onChange {Function} 监听函数,数值改变时触发
*/
class AtRate extends Taro.Component {
class AtRate extends AtComponent {
handleClick (i) {
this.props.onChange(i + 1, ...arguments)
}
Expand Down
4 changes: 3 additions & 1 deletion src/components/segmented-control/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import Taro from '@tarojs/taro'
import { View } from '@tarojs/components'
import PropTypes from 'prop-types'

import AtComponent from '../../common/component'
import './index.scss'

/**
Expand All @@ -14,7 +16,7 @@ import './index.scss'
* @prop fontSize {String|Number} 字体大小,单位h5为rem,小程序为rem default:'28'
* @prop onClick {Function} 点击时触发事件,回调参数 数组索引值
*/
class AtSegmentedControl extends Taro.Component {
class AtSegmentedControl extends AtComponent {
handleClick (i, disable) {
if (disable) return
this.props.onClick(i, ...arguments)
Expand Down
4 changes: 3 additions & 1 deletion src/components/switch/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import Taro from '@tarojs/taro'
import { View, Switch } from '@tarojs/components'
import PropTypes from 'prop-types'

import AtComponent from '../../common/component'
import './index.scss'

/**
Expand All @@ -12,7 +14,7 @@ import './index.scss'
* @prop disabled {Boolean} 是否禁用 default:false
* @prop onChange {Function} 监听函数,数值改变时触发
*/
class AtSwitch extends Taro.Component {
class AtSwitch extends AtComponent {
handleChange (e) {
this.props.onChange(e.detail.value)
}
Expand Down
4 changes: 3 additions & 1 deletion src/components/tab-bar/index.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import Taro from '@tarojs/taro'
import { View } from '@tarojs/components'
import PropTypes from 'prop-types'

import AtIcon from '../../components/icon/index'
import AtBadge from '../../components/badge/index'
import AtComponent from '../../common/component'
import './index.scss'

/**
Expand All @@ -25,7 +27,7 @@ import './index.scss'
* 示例: [{ title: '标签页1',iconType: '', dot: true, iconSize:24, selectedIconType: '',text: 8 }, { title: '标签页2' }]
* @prop onClick {Function} 点击时触发事件,回调参数:列表索引值
*/
class AtTabBar extends Taro.Component {
class AtTabBar extends AtComponent {
constructor () {
super(...arguments)
this.state = {
Expand Down
4 changes: 3 additions & 1 deletion src/components/tabs-pane/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import Taro from '@tarojs/taro'
import { View } from '@tarojs/components'

import AtComponent from '../../common/component'
import './index.scss'

/**
Expand All @@ -11,7 +13,7 @@ import './index.scss'
* @prop tabList {Array} tab 列表 eg: [{ title: '标签页1' }, { title: '标签页2' }]
* @prop onClick {Function} 点击时触发事件,回调参数 {value: 1}
*/
class AtTabsPane extends Taro.Component {
class AtTabsPane extends AtComponent {
render () {
return <View className='tabs-pane'>
{this.props.children}
Expand Down
4 changes: 3 additions & 1 deletion src/components/tabs/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import Taro from '@tarojs/taro'
import { View } from '@tarojs/components'
import PropTypes from 'prop-types'

import AtComponent from '../../common/component'
import './index.scss'

/**
Expand All @@ -11,7 +13,7 @@ import './index.scss'
* @prop tabList {Array} tab 列表 eg: [{ title: '标签页1' }, { title: '标签页2' }]
* @prop onClick {Function} 点击时触发事件,回调参数 {value: 1}
*/
class AtTabs extends Taro.Component {
class AtTabs extends AtComponent {
constructor () {
super(...arguments)
// 触摸时的原点
Expand Down
3 changes: 2 additions & 1 deletion src/components/tag/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import Taro from '@tarojs/taro'
import { View } from '@tarojs/components'
import PropTypes from 'prop-types'

import AtComponent from '../../common/component'
import './index.scss'

const SIZE_CLASS = {
Expand All @@ -14,7 +15,7 @@ const TYPE_CLASS = {
}


export default class AtTag extends Taro.Component {
export default class AtTag extends AtComponent {
constructor () {
super(...arguments)
this.state = {
Expand Down
4 changes: 3 additions & 1 deletion src/components/textarea/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import Taro from '@tarojs/taro'
import { View, Textarea } from '@tarojs/components'
import PropTypes from 'prop-types'

import AtComponent from '../../common/component'
import './index.scss'

/**
Expand All @@ -20,7 +22,7 @@ import './index.scss'
* @prop onBlur {Function} 输入框失去焦点时触发
* @prop onConfirm {Function} 点击完成时触发
*/
class AtTextarea extends Taro.Component {
class AtTextarea extends AtComponent {
handleInput (e) {
this.props.onChange(e, ...arguments)
}
Expand Down
5 changes: 3 additions & 2 deletions src/components/timeline/index.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import PropTypes from 'prop-types'
import Taro from '@tarojs/taro'
import { View } from '@tarojs/components'
import AtIcon from '../icon/index'

import AtIcon from '../icon/index'
import AtComponent from '../../common/component'
import './index.scss'

export default class AtTimeline extends Taro.Component {
export default class AtTimeline extends AtComponent {
constructor () {
super(...arguments)
this.state = {
Expand Down
Loading

0 comments on commit 87de708

Please sign in to comment.