Skip to content

Commit

Permalink
fix(wxapp): 处理兼容问题
Browse files Browse the repository at this point in the history
  • Loading branch information
SzHeJason committed Aug 2, 2018
1 parent 0d80914 commit 45b11cb
Show file tree
Hide file tree
Showing 38 changed files with 626 additions and 584 deletions.
26 changes: 13 additions & 13 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,35 +32,35 @@
"author": "O2Team <aotu.io>",
"license": "MIT",
"dependencies": {
"@tarojs/components": "1.0.0-beta.2",
"@tarojs/router": "1.0.0-beta.2",
"@tarojs/taro": "1.0.0-beta.2",
"@tarojs/taro-h5": "1.0.0-beta.2",
"@tarojs/taro-weapp": "1.0.0-beta.2",
"@tarojs/components": "1.0.0-beta.5",
"@tarojs/router": "1.0.0-beta.5",
"@tarojs/taro": "1.0.0-beta.5",
"@tarojs/taro-h5": "1.0.0-beta.5",
"@tarojs/taro-weapp": "1.0.0-beta.5",
"lodash": "^4.17.10",
"nervjs": "^1.3.0",
"prop-types": "^15.6.2"
},
"devDependencies": {
"@commitlint/cli": "^7.0.0",
"@commitlint/config-conventional": "^7.0.1",
"@tarojs/cli": "1.0.0-beta.2",
"@tarojs/plugin-babel": "1.0.0-beta.2",
"@tarojs/plugin-csso": "1.0.0-beta.2",
"@tarojs/plugin-sass": "1.0.0-beta.2",
"@tarojs/plugin-uglifyjs": "1.0.0-beta.2",
"@tarojs/webpack-runner": "1.0.0-beta.2",
"@tarojs/cli": "1.0.0-beta.5",
"@tarojs/plugin-babel": "1.0.0-beta.5",
"@tarojs/plugin-csso": "1.0.0-beta.5",
"@tarojs/plugin-sass": "1.0.0-beta.5",
"@tarojs/plugin-uglifyjs": "1.0.0-beta.5",
"@tarojs/webpack-runner": "1.0.0-beta.5",
"babel-eslint": "^8.2.3",
"babel-plugin-transform-class-properties": "^6.24.1",
"babel-plugin-transform-decorators-legacy": "^1.3.4",
"babel-plugin-transform-object-rest-spread": "^6.26.0",
"babel-preset-env": "^1.6.1",
"eslint": "^4.19.1",
"eslint-config-o2team": "^0.1.6",
"eslint-config-taro": "1.0.0-beta.2",
"eslint-config-taro": "1.0.0-beta.5",
"eslint-plugin-import": "^2.12.0",
"eslint-plugin-react": "^7.8.2",
"eslint-plugin-taro": "1.0.0-beta.2",
"eslint-plugin-taro": "1.0.0-beta.5",
"glob": "^7.1.2",
"gulp": "^3.9.1",
"gulp-clean": "^0.4.0",
Expand Down
46 changes: 23 additions & 23 deletions src/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,32 +13,32 @@ class App extends Component {
'pages/basic/icon/index',
'pages/basic/button/index',
'pages/action/toast/index',
// 'pages/action/modal/index',
'pages/action/modal/index',
'pages/action/progress/index',
// 'pages/action/action-sheet/index',
'pages/action/action-sheet/index',
'pages/action/activity-indicator/index',
'pages/form/checkbox/index',
'pages/form/input/index',
'pages/form/input-number/index',
'pages/form/radio/index',
'pages/form/textarea/index',
'pages/form/switch/index',
'pages/form/rate/index',
'pages/view/noticebar/index',
'pages/view/badge/index',
'pages/view/tag/index',
'pages/view/avatar/index',
'pages/view/article/index',
'pages/navigation/timeline/index',
// 'pages/form/checkbox/index',
// 'pages/form/input/index',
// 'pages/form/input-number/index',
// 'pages/form/radio/index',
// 'pages/form/textarea/index',
// 'pages/form/switch/index',
// 'pages/form/rate/index',
// 'pages/view/noticebar/index',
// 'pages/view/badge/index',
// 'pages/view/tag/index',
// 'pages/view/avatar/index',
// 'pages/view/article/index',
// 'pages/navigation/timeline/index',
// 'pages/navigation/drawer/index',
'pages/navigation/tabs/index',
'pages/navigation/tab-bar/index',
'pages/navigation/segmented-control/index',
'pages/navigation/nav-bar/index',
// 'pages/layout/flex/index'
// 'pages/layout/grid/index',
// 'pages/layout/float-layout/index',
// 'pages/layout/card/index',
// 'pages/navigation/tabs/index',
// 'pages/navigation/tab-bar/index',
// 'pages/navigation/segmented-control/index',
// 'pages/navigation/nav-bar/index',
'pages/layout/flex/index',
'pages/layout/grid/index',
'pages/layout/float-layout/index',
'pages/layout/card/index',
'pages/layout/list/index'
],
window: {
Expand Down
11 changes: 3 additions & 8 deletions src/components/action-sheet/body/index.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,10 @@
import Taro from '@tarojs/taro'
import Taro, { Component } from '@tarojs/taro'
import { View } from '@tarojs/components'

import AtActionSheetItem from './item/index.js'

import './index.scss'

export default class AtActionSheetBody extends Taro.Component {
static Item = AtActionSheetItem

export default class AtActionSheetBody extends Component {
render () {
const { children } = this.props
return <View className='at-action-sheet-body'>{children}</View>
return <View className='at-action-sheet-body'>{this.props.children}</View>
}
}
15 changes: 3 additions & 12 deletions src/components/action-sheet/body/item/index.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,14 @@
import Taro from '@tarojs/taro'
import { View } from '@tarojs/components'

import _isFunction from 'lodash/isFunction'

import './index.scss'

export default class AtActionSheetItem extends Taro.Component {
handleClick () {
const { onClick } = this.props
if (_isFunction(onClick)) {
return onClick()
}
}

render () {
const { children } = this.props
const { onClick } = this.props
return (
<View className='at-action-sheet-item' onClick={this.handleClick}>
{children}
<View className='at-action-sheet-item' onClick={onClick}>
{this.props.children}
</View>
)
}
Expand Down
5 changes: 2 additions & 3 deletions src/components/action-sheet/body/item/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
font-size: 36px;
padding: 25px 0;

&:not(:last-child) {
border-bottom: 1px solid rgba($color: $color-black-0, $alpha: 0.1);
}
/* prettier-ignore */
border-bottom: 1PX solid rgba($color: $color-black-0, $alpha: 0.1);
}
16 changes: 3 additions & 13 deletions src/components/action-sheet/footer/index.js
Original file line number Diff line number Diff line change
@@ -1,24 +1,14 @@
import Taro from '@tarojs/taro'
import { View } from '@tarojs/components'

import _isFunction from 'lodash/isFunction'

import './index.scss'

export default class AtActionSheetFooter extends Taro.Component {
handleClick = () => {
const { onClick, $$close } = this.props
if (_isFunction(onClick)) {
return onClick()
}
$$close()
}

render () {
const { children } = this.props
const { onClick } = this.props
return (
<View className='at-action-sheet-footer' onClick={this.handleClick}>
{children}
<View className='at-action-sheet-footer' onClick={onClick}>
{this.props.children}
</View>
)
}
Expand Down
3 changes: 1 addition & 2 deletions src/components/action-sheet/header/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import './index.scss'

export default class AtActionSheetHeader extends Taro.Component {
render () {
const { children } = this.props
return <View className='at-action-sheet-header'>{children}</View>
return <View className='at-action-sheet-header'>{this.props.children}</View>
}
}
55 changes: 18 additions & 37 deletions src/components/action-sheet/index.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
import Taro from '@tarojs/taro'
/* eslint-disable taro/function-naming */

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

import AtActionSheetBody from './body'
import AtActionSheetHeader from './header'
import AtActionSheetFooter from './footer'
import AtActionSheetBody from './body/index'
import AtActionSheetHeader from './header/index'
import AtActionSheetFooter from './footer/index'

import './index.scss'

export default class AtActionSheet extends Taro.Component {
static Body = AtActionSheetBody
static Header = AtActionSheetHeader
static Footer = AtActionSheetFooter

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

_close () {
close = () => {
this.setState({
isOpened: false
})
}

_open () {
open = () => {
this.setState({
isOpened: true
})
}

handleClickOverlay = () => {
this._close()
}

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

if (children) {
const index = children.findIndex(
item => item.name === 'AtActionSheetFooter'
)

if (index === -1) return

children[index].props = Object.assign(
{
$$close: this._close.bind(this),
$$open: this._open.bind(this)
},
children[index].props
)
}

return isOpened ? (
<View className='at-action-sheet'>
<View
onClick={this.handleClickOverlay}
className='at-action-sheet__overlay'
/>
<View className='at-action-sheet__container'>{children}</View>
<View onClick={this.close} className='at-action-sheet__overlay' />
<View className='at-action-sheet__container'>
<AtActionSheetHeader>{title}</AtActionSheetHeader>
<AtActionSheetBody>{this.props.children}</AtActionSheetBody>
<AtActionSheetFooter onClick={this.close}>
{cancleText}
</AtActionSheetFooter>
</View>
</View>
) : null
}
Expand Down
13 changes: 7 additions & 6 deletions src/components/activity-indicator/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,19 @@ export default class ActivityIndicator extends Taro.Component {
const scaleSize = size / 200

const indicatorStyle = {
width: +size,
height: +size,
transform: `translate(-${realSize}px, -${realSize}px) scale(${scaleSize}) translate(${realSize}px,${realSize}px)`
width: size ? `${+size}px` : undefined,
height: size ? `${+size}px` : undefined,
transform: realSize ? `translate(-${realSize}px, -${realSize}px) scale(${scaleSize}) translate(${realSize}px,${realSize}px)` : undefined
}

const style = {
background: color
}

const rootClassName = {
'at-activity-indicator': true,
'at-activity-indicator--center': mode === 'center'
const rootClassName = ['at-activity-indicator']

if (mode === 'center') {
rootClassName.push('at-activity-indicator--center')
}

return (
Expand Down
46 changes: 26 additions & 20 deletions src/components/card/index.js
Original file line number Diff line number Diff line change
@@ -1,41 +1,47 @@
import Taro from '@tarojs/taro'
import { View, Text, Image } from '@tarojs/components'

import { View, Text } from '@tarojs/components'

import AtIcon from '../icon/index'
import PropTypes from 'prop-types'

import './index.scss'

export default class AtCard extends Taro.Component {
render () {
const {
children,
title,
note,
icon,
iconColor,
iconSize,
extra
} = this.props
const { title, note, extra, thumb, onClick } = this.props

return (
<View className='at-card'>
<View className='at-card' onClick={onClick}>
<View className='at-card-header'>
<View className='at-card-header__icon'>
<AtIcon value={icon} size={iconSize} color={iconColor} />
</View>
{thumb && (
<View className='at-card-header__thumb'>
<Image
className='at-card-header__thumb-info'
mode='scaleToFill'
src={thumb}
/>
</View>
)}
<Text className='at-card-header__title'>{title}</Text>
<Text className='at-card-header__extra'>{extra}</Text>
{extra && <Text className='at-card-header__extra'>{extra}</Text>}
</View>
<View className='at-card-content'>
<View className='at-card-content__info'>{children}</View>
<View className='at-card-content__note'>{note}</View>
<View className='at-card-content__info'>{this.props.children}</View>
{note && <View className='at-card-content__note'>{note}</View>}
</View>
</View>
)
}
}

AtCard.defaultProps = {
iconSize: 18
iconSize: 18,
onClick: () => {}
}

AtCard.propTypes = {
note: PropTypes.string,
thumb: PropTypes.string,
title: PropTypes.string,
extra: PropTypes.string,
onClick: PropTypes.func
}
Loading

0 comments on commit 45b11cb

Please sign in to comment.