Skip to content

Commit

Permalink
fix(components): 检查PropType没有添加的组件 修复体验问题
Browse files Browse the repository at this point in the history
  • Loading branch information
SzHeJason committed Aug 16, 2018
1 parent fcfc04d commit 85a4cbb
Show file tree
Hide file tree
Showing 12 changed files with 69 additions and 32 deletions.
6 changes: 6 additions & 0 deletions src/components/action-sheet/body/item/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 './index.scss'

export default class AtActionSheetItem extends Taro.Component {
Expand All @@ -13,3 +15,7 @@ export default class AtActionSheetItem extends Taro.Component {
)
}
}

AtActionSheetItem.propTypes = {
onClick: PropTypes.func
}
6 changes: 6 additions & 0 deletions src/components/action-sheet/footer/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import Taro, { Component } from '@tarojs/taro'
import { View } from '@tarojs/components'

import PropTypes from 'prop-types'

import './index.scss'

export default class AtActionSheetFooter extends Component {
Expand All @@ -13,3 +15,7 @@ export default class AtActionSheetFooter extends Component {
)
}
}

AtActionSheetFooter.propTypes = {
onClick: PropTypes.func
}
4 changes: 2 additions & 2 deletions src/components/action-sheet/header/index.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import Taro from '@tarojs/taro'
import Taro, { Component } from '@tarojs/taro'
import { View, Text } from '@tarojs/components'

import './index.scss'

export default class AtActionSheetHeader extends Taro.Component {
export default class AtActionSheetHeader extends Component {
render () {
return (
<View className='at-action-sheet-header'>
Expand Down
2 changes: 0 additions & 2 deletions src/components/action-sheet/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
/* eslint-disable taro/function-naming */

import Taro, { Component } from '@tarojs/taro'
import { View } from '@tarojs/components'

Expand Down
4 changes: 0 additions & 4 deletions src/components/card/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,6 @@ export default class AtCard extends Taro.Component {
}
}

AtCard.defaultProps = {
onClick: () => {}
}

AtCard.propTypes = {
note: PropTypes.string,
isFull: PropTypes.bool,
Expand Down
5 changes: 3 additions & 2 deletions src/components/list/item/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ $item-horizontal-padding: 24px;
@include align-items(center);
@include active;

padding: $spacing-v-lg $spacing-h-xl;
padding: $spacing-v-lg $spacing-h-lg;
position: relative;
box-sizing: border-box;
color: $color-text-base;
Expand Down Expand Up @@ -93,7 +93,8 @@ $item-horizontal-padding: 24px;
}

&__icon {
margin-left: $spacing-h-lg;
margin-left: $spacing-h-sm;
margin-right: -$spacing-h-sm;
}

&__switch {
Expand Down
18 changes: 15 additions & 3 deletions src/components/modal/action/index.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,28 @@
import Taro from '@tarojs/taro'
import Taro, { Component } from '@tarojs/taro'
import { View } from '@tarojs/components'

import PropTypes from 'prop-types'

import './index.scss'

export default class AtModalFooter extends Taro.Component {
export default class AtModalAction extends Component {
render () {
const rootClass = ['at-modal-footer']

if (this.props.isSimple) {
rootClass.push('at-modal-footer--simple')
}

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

AtModalAction.propTypes = {
isSimple: PropTypes.bool
}
6 changes: 5 additions & 1 deletion src/components/modal/action/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,12 @@
}

&:first-child:last-child {
color: $color-error;
color: $color-brand;
}
}
}

&--simple .at-modal-action > button:last-child:nth-child(2) {
color: $color-brand;
}
}
29 changes: 18 additions & 11 deletions src/components/modal/index.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
import Taro from '@tarojs/taro'
import Taro, { Component } from '@tarojs/taro'
import { View, Button, Text } from '@tarojs/components'

import PropTypes from 'prop-types'

import AtModalHeader from './header/index'
import AtModalAction from './action/index'
import AtModalContent from './content/index'

import './index.scss'

export default class AtModal extends Taro.Component {
export default class AtModal extends Component {
constructor (props) {
super(...arguments)
const { isOpened } = props
Expand All @@ -27,20 +29,14 @@ export default class AtModal extends Taro.Component {

render () {
const { isOpened } = this.state
const {
title,
content,
cancleText,
confirmText
} = this.props
const { title, content, cancleText, confirmText } = this.props

const rootClass = ['at-modal']

if (isOpened) {
rootClass.push('at-modal--active')
}


if (title || content) {
const isRenderAction = cancleText || confirmText
return (
Expand All @@ -60,8 +56,10 @@ export default class AtModal extends Taro.Component {
</AtModalContent>
)}
{isRenderAction && (
<AtModalAction>
{cancleText && <Button onClick={this.props.onCancle}>{cancleText}</Button>}
<AtModalAction isSimple>
{cancleText && (
<Button onClick={this.props.onCancle}>{cancleText}</Button>
)}
{confirmText && (
<Button onClick={this.props.onConfirm}>{confirmText}</Button>
)}
Expand All @@ -80,3 +78,12 @@ export default class AtModal extends Taro.Component {
)
}
}

AtModal.propTypes = {
title: PropTypes.string,
onCancle: PropTypes.func,
onConfirm: PropTypes.func,
content: PropTypes.string,
cancleText: PropTypes.string,
confirmText: PropTypes.string,
}
3 changes: 2 additions & 1 deletion src/components/toast/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,9 @@ $toast-loading-size: 100px;
}

&__info {
margin-top: $spacing-v-sm;
margin-top: $spacing-v-md;
color: $color-white;
line-height: $line-height-zh;
font-size: $font-size-base;
text-align: center;
}
Expand Down
14 changes: 10 additions & 4 deletions src/pages/action/progress/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,22 +23,28 @@ export default class ProgressPage extends Taro.Component {
}

reduce = () => {
const { percent } = this.state
let { percent } = this.state
if (percent === 0) {
return
}

percent = percent - OFFSET < 0 ? 0 : percent - OFFSET

this.setState({
percent: this.state.percent - OFFSET
percent
})
}

increase = () => {
const { percent } = this.state
let { percent } = this.state
if (percent === 100) {
return
}

percent = percent + OFFSET > 100 ? 100 : percent + OFFSET

this.setState({
percent: this.state.percent + OFFSET
percent
})
}

Expand Down
4 changes: 2 additions & 2 deletions src/pages/layout/flex/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ export default class FlexPage extends Taro.Component {
</View>

<View className='panel'>
<View className='panel__title'>侧轴方向上 方式</View>
<View className='panel__title'>侧轴方向的对齐方式</View>
<View className='panel__content'>
<View className='example-item'>
<View className='at-flex'>
Expand Down Expand Up @@ -142,7 +142,7 @@ export default class FlexPage extends Taro.Component {
</View>

<View className='panel'>
<View className='panel__title'>主轴方向上 排列方式</View>
<View className='panel__title'>主轴方向的排列方式</View>
<View className='panel__content'>
<View className='example-item'>
<View className='at-flex'>
Expand Down

0 comments on commit 85a4cbb

Please sign in to comment.