Skip to content

Commit

Permalink
feat(customize-theme): 调整代码结构,更改 css 命名
Browse files Browse the repository at this point in the history
  • Loading branch information
koppthe committed Dec 24, 2018
1 parent b12fe13 commit 8ab1764
Show file tree
Hide file tree
Showing 19 changed files with 417 additions and 335 deletions.
40 changes: 21 additions & 19 deletions src/components/list/item/index.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import Taro from '@tarojs/taro'
import { View, Image, Switch } from '@tarojs/components'
import { View, Image, Switch, Text } from '@tarojs/components'
import PropTypes from 'prop-types'
import classNames from 'classnames'
import _isFunction from 'lodash/isFunction'

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

export default class AtListItem extends AtComponent {
Expand Down Expand Up @@ -50,35 +48,39 @@ export default class AtListItem extends AtComponent {
},
this.props.className
)
const iconClass = classNames(
iconInfo.prefixClass || 'at-icon',
{
[`${iconInfo.prefixClass || 'at-icon'}-${iconInfo.value}`]: iconInfo.value,
},
iconInfo.className
)

return (
<View className={rootClass} onClick={this.handleClick}>
<View className='at-list__item-container'>
{thumb ? (
{thumb && (
<View className='at-list__item-thumb item-thumb'>
<Image
className='item-thumb__info'
mode='scaleToFill'
src={thumb}
/>
</View>
) : null}
{iconInfo.value ? (
)}
{iconInfo.value && (
<View className='at-list__item-icon item-icon'>
<AtIcon
customStyle={
this.mergeStyle(
{ fontSize: `${iconInfo.size || 24}px` },
iconInfo.customStyle
)
<Text
className={iconClass}
style={
this.mergeStyle({
color: iconInfo.color || '',
fontSize: `${iconInfo.size || 24}px`,
}, iconInfo.customStyle)
}
value={iconInfo.value}
color={iconInfo.color}
className={iconInfo.className}
prefixClass={iconInfo.prefixClass}
/>
></Text>
</View>
) : null}
)}
<View className='at-list__item-content item-content'>
<View className='item-content__info'>
<View className='item-content__info-title'>{title}</View>
Expand Down Expand Up @@ -114,7 +116,7 @@ export default class AtListItem extends AtComponent {

{arrow && (
<View className='item-extra__icon'>
<AtIcon customStyle={{ fontSize: '24px' }} value={`chevron-${arrow}`} color='#c7c7cc' />
<Text className={classNames('at-icon', { [`at-icon-chevron-${arrow}`]: arrow }, 'item-extra__icon-arrow')}></Text>
</View>
)}
</View>
Expand Down
72 changes: 36 additions & 36 deletions src/components/load-more/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,42 +8,6 @@ import AtButton from '../../components/button/index'
import AtComponent from '../../common/component'

export default class AtLoadMore extends AtComponent {
static defaultProps = {
customStyle: '',
className: '',
noMoreTextStyle: '',
moreBtnStyle: '',
status: 'more',
loadingText: '加载中',
moreText: '查看更多',
noMoreText: '没有更多',
onClick: () => {}
}

static propTypes = {
customStyle: PropTypes.oneOfType([
PropTypes.object,
PropTypes.string
]),
className: PropTypes.oneOfType([
PropTypes.array,
PropTypes.string
]),
noMoreTextStyle: PropTypes.oneOfType([
PropTypes.object,
PropTypes.string
]),
moreBtnStyle: PropTypes.oneOfType([
PropTypes.object,
PropTypes.string
]),
status: PropTypes.oneOf(['more', 'loading', 'noMore']),
loadingText: PropTypes.string,
moreText: PropTypes.string,
noMoreText: PropTypes.string,
onClick: PropTypes.func
}

onClick () {
this.props.onClick(...arguments)
}
Expand Down Expand Up @@ -90,3 +54,39 @@ export default class AtLoadMore extends AtComponent {
)
}
}

AtLoadMore.defaultProps = {
customStyle: '',
className: '',
noMoreTextStyle: '',
moreBtnStyle: '',
status: 'more',
loadingText: '加载中',
moreText: '查看更多',
noMoreText: '没有更多',
onClick: () => {},
}

AtLoadMore.propTypes = {
customStyle: PropTypes.oneOfType([
PropTypes.object,
PropTypes.string
]),
className: PropTypes.oneOfType([
PropTypes.array,
PropTypes.string
]),
noMoreTextStyle: PropTypes.oneOfType([
PropTypes.object,
PropTypes.string
]),
moreBtnStyle: PropTypes.oneOfType([
PropTypes.object,
PropTypes.string
]),
status: PropTypes.oneOf(['more', 'loading', 'noMore']),
loadingText: PropTypes.string,
moreText: PropTypes.string,
noMoreText: PropTypes.string,
onClick: PropTypes.func,
}
33 changes: 16 additions & 17 deletions src/components/loading/index.js
Original file line number Diff line number Diff line change
@@ -1,26 +1,9 @@
import Taro from '@tarojs/taro'
import PropTypes from 'prop-types'
import { View } from '@tarojs/components'

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

export default class AtLoading extends AtComponent {
static defaultProps = {
size: '18',
color: '#fff'
}

static propTypes = {
size: PropTypes.oneOfType([
PropTypes.string,
PropTypes.number
]),
color: PropTypes.oneOfType([
PropTypes.string,
PropTypes.number
])
}

render () {
const { color, size } = this.props
const sizeStyle = {
Expand All @@ -42,3 +25,19 @@ export default class AtLoading extends AtComponent {
)
}
}

AtLoading.defaultProps = {
size: '18',
color: '#fff',
}

AtLoading.propTypes = {
size: PropTypes.oneOfType([
PropTypes.string,
PropTypes.number
]),
color: PropTypes.oneOfType([
PropTypes.string,
PropTypes.number
]),
}
33 changes: 16 additions & 17 deletions src/components/message/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,9 @@ import Taro from '@tarojs/taro'
import PropTypes from 'prop-types'
import { View } from '@tarojs/components'
import classNames from 'classnames'

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

export default class AtMessage extends AtComponent {
static defaultProps = {
customStyle: '',
className: ''
}

static propTypes = {
customStyle: PropTypes.oneOfType([
PropTypes.object,
PropTypes.string
]),
className: PropTypes.oneOfType([
PropTypes.array,
PropTypes.string
]),
}

constructor () {
super(...arguments)
this.state = {
Expand Down Expand Up @@ -92,3 +75,19 @@ export default class AtMessage extends AtComponent {
)
}
}

AtMessage.defaultProps = {
customStyle: '',
className: '',
}

AtMessage.propTypes = {
customStyle: PropTypes.oneOfType([
PropTypes.object,
PropTypes.string
]),
className: PropTypes.oneOfType([
PropTypes.array,
PropTypes.string
]),
}
12 changes: 8 additions & 4 deletions src/components/modal/action/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,27 @@ import AtComponent from '../../../common/component'
export default class AtModalAction extends AtComponent {
render () {
const rootClass = classNames(
'at-modal-footer',
'at-modal__footer',
{
'at-modal-footer--simple': this.props.isSimple
'at-modal__footer--simple': this.props.isSimple
},
this.props.className
)

return (
<View className={rootClass}>
<View className='at-modal-footer__action at-modal-action'>
<View className='at-modal__action'>
{this.props.children}
</View>
</View>
)
}
}

AtModalAction.defaultProps = {
isSimple: false,
}

AtModalAction.propTypes = {
isSimple: PropTypes.bool
isSimple: PropTypes.bool,
}
2 changes: 1 addition & 1 deletion src/components/modal/content/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import AtComponent from '../../../common/component'

export default class AtModalContent extends AtComponent {
render () {
const rootClass = classNames('at-modal-content', this.props.className)
const rootClass = classNames('at-modal__content', this.props.className)
return <View className={rootClass}>{this.props.children}</View>
}
}
2 changes: 1 addition & 1 deletion src/components/modal/header/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import AtComponent from '../../../common/component'

export default class AtModalHeader extends AtComponent {
render () {
const rootClass = classNames('at-modal-header', this.props.className)
const rootClass = classNames('at-modal__header', this.props.className)
return <View className={rootClass}>{this.props.children}</View>
}
}
Loading

0 comments on commit 8ab1764

Please sign in to comment.