-
Notifications
You must be signed in to change notification settings - Fork 751
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
25 changed files
with
291 additions
and
124 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import Taro 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 | ||
|
||
render () { | ||
const { children } = this.props | ||
return <View className='at-action-sheet-body'>{children}</View> | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
.at-action-sheet-body { | ||
text-align: center; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
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 | ||
return ( | ||
<View className='at-action-sheet-item' onClick={this.handleClick}> | ||
{children} | ||
</View> | ||
) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
@import "../../../../style/mixins/index.scss"; | ||
@import "../../../../style/theme/default.scss"; | ||
|
||
.at-action-sheet-item { | ||
font-size: 36px; | ||
padding: 25px 0; | ||
|
||
&:not(:last-child) { | ||
border-bottom: 1px solid rgba($color: $color-black-0, $alpha: 0.1); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
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 | ||
return ( | ||
<View className='at-action-sheet-footer' onClick={this.handleClick}> | ||
{children} | ||
</View> | ||
) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
.at-action-sheet-footer { | ||
font-size: 36px; | ||
padding: 25px 0; | ||
border-top: 12px solid rgba($color: #cdcdd1, $alpha: 0.3); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import Taro from '@tarojs/taro' | ||
import { View } from '@tarojs/components' | ||
|
||
import './index.scss' | ||
|
||
export default class AtActionSheetHeader extends Taro.Component { | ||
render () { | ||
const { children } = this.props | ||
return <View className='at-action-sheet-header'>{children}</View> | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
@import "../../../style/mixins/index.scss"; | ||
@import "../../../style/theme/default.scss"; | ||
|
||
.at-action-sheet-header { | ||
font-size: 28px; | ||
padding: 25px 0; | ||
color: #888; | ||
border-bottom: 1px solid rgba($color: $color-black-0, $alpha: 0.1); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,80 @@ | ||
import Taro from '@tarojs/taro' | ||
import { View } from '@tarojs/components' | ||
|
||
import AtActionSheetBody from './body' | ||
import AtActionSheetHeader from './header' | ||
import AtActionSheetFooter from './footer' | ||
|
||
import './index.scss' | ||
|
||
export default class ActionSheet extends Taro.Component { | ||
export default class AtActionSheet extends Taro.Component { | ||
static Body = AtActionSheetBody | ||
static Header = AtActionSheetHeader | ||
static Footer = AtActionSheetFooter | ||
|
||
constructor (props) { | ||
super(...arguments) | ||
const { isOpened } = props | ||
this.state = { | ||
isOpened | ||
} | ||
} | ||
|
||
componentWillReceiveProps (nextProps) { | ||
const { isOpened } = nextProps | ||
if (isOpened !== this.state.isOpened) { | ||
this.setState({ | ||
isOpened | ||
}) | ||
} | ||
} | ||
|
||
_close () { | ||
this.setState({ | ||
isOpened: false | ||
}) | ||
} | ||
|
||
_open () { | ||
this.setState({ | ||
isOpened: true | ||
}) | ||
} | ||
|
||
handleClickOverlay = () => { | ||
this._close() | ||
} | ||
|
||
render () { | ||
return ( | ||
const { children } = this.props | ||
const { isOpened } = this.state | ||
|
||
console.log(children) | ||
|
||
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 className='at-action-sheet__overlay' /> | ||
<View className='at-action-sheet__container'> | ||
<View className='at-action-sheet__container-header'> | ||
<View>清除位置信息后, 别人将不能查看到你</View> | ||
<View>这里最多显示两行</View> | ||
</View> | ||
<View className='at-action-sheet__container-body body__list'> | ||
<View className='body__list-item'>清除位置信息并退出 </View> | ||
<View className='body__list-item'>清除位置信息并退出</View> | ||
<View className='body__list-item'>清除位置信息并退出</View> | ||
</View> | ||
<View className='at-action-sheet__container-footer'> | ||
<View>取消</View> | ||
</View> | ||
</View> | ||
<View | ||
onClick={this.handleClickOverlay} | ||
className='at-action-sheet__overlay' | ||
/> | ||
<View className='at-action-sheet__container'>{children}</View> | ||
</View> | ||
) | ||
) : null | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
.at-modal-action-button { | ||
outline: 0; | ||
flex: auto; | ||
border: none; | ||
font-size: 28px; | ||
background-color: white; | ||
|
||
&:not(:first-child) { | ||
border-left: 2px solid #e5e5e5; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,8 @@ | ||
.at-modal-footer { | ||
border-top: 2px solid #e5e5e5; | ||
|
||
&__action { | ||
display: flex; | ||
} | ||
} | ||
|
||
.at-modal-action__button { | ||
outline: 0; | ||
flex: auto; | ||
border: none; | ||
font-size: 28px; | ||
background-color: white; | ||
&:not(:first-child) { | ||
border-left: 2px solid #e5e5e5; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.