diff --git a/src/app.js b/src/app.js
index cce1e41e1..1874d634b 100644
--- a/src/app.js
+++ b/src/app.js
@@ -8,7 +8,7 @@ class App extends Component {
pages: [
'pages/index/index',
'pages/action/toast/index',
- // 'pages/action/modal/index',
+ 'pages/action/modal/index',
'pages/action/progress/index',
'pages/action/action-sheet/index',
'pages/action/activity-indicator/index',
diff --git a/src/components/action-sheet/body/index.js b/src/components/action-sheet/body/index.js
new file mode 100644
index 000000000..72ae15e28
--- /dev/null
+++ b/src/components/action-sheet/body/index.js
@@ -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 {children}
+ }
+}
diff --git a/src/components/action-sheet/body/index.scss b/src/components/action-sheet/body/index.scss
new file mode 100644
index 000000000..14b458d60
--- /dev/null
+++ b/src/components/action-sheet/body/index.scss
@@ -0,0 +1,3 @@
+.at-action-sheet-body {
+ text-align: center;
+}
diff --git a/src/components/action-sheet/body/item/index.js b/src/components/action-sheet/body/item/index.js
new file mode 100644
index 000000000..8c6aa213a
--- /dev/null
+++ b/src/components/action-sheet/body/item/index.js
@@ -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 (
+
+ {children}
+
+ )
+ }
+}
diff --git a/src/components/action-sheet/body/item/index.scss b/src/components/action-sheet/body/item/index.scss
new file mode 100644
index 000000000..2d4350210
--- /dev/null
+++ b/src/components/action-sheet/body/item/index.scss
@@ -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);
+ }
+}
diff --git a/src/components/action-sheet/footer/index.js b/src/components/action-sheet/footer/index.js
new file mode 100644
index 000000000..0c9cc60c1
--- /dev/null
+++ b/src/components/action-sheet/footer/index.js
@@ -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 (
+
+ {children}
+
+ )
+ }
+}
diff --git a/src/components/action-sheet/footer/index.scss b/src/components/action-sheet/footer/index.scss
new file mode 100644
index 000000000..998c6def0
--- /dev/null
+++ b/src/components/action-sheet/footer/index.scss
@@ -0,0 +1,5 @@
+.at-action-sheet-footer {
+ font-size: 36px;
+ padding: 25px 0;
+ border-top: 12px solid rgba($color: #cdcdd1, $alpha: 0.3);
+}
diff --git a/src/components/action-sheet/header/index.js b/src/components/action-sheet/header/index.js
new file mode 100644
index 000000000..111993d98
--- /dev/null
+++ b/src/components/action-sheet/header/index.js
@@ -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 {children}
+ }
+}
diff --git a/src/components/action-sheet/header/index.scss b/src/components/action-sheet/header/index.scss
new file mode 100644
index 000000000..855ca4153
--- /dev/null
+++ b/src/components/action-sheet/header/index.scss
@@ -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);
+}
diff --git a/src/components/action-sheet/index.js b/src/components/action-sheet/index.js
index 13ec256cc..21679677c 100644
--- a/src/components/action-sheet/index.js
+++ b/src/components/action-sheet/index.js
@@ -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 ? (
-
-
-
- 清除位置信息后, 别人将不能查看到你
- 这里最多显示两行
-
-
- 清除位置信息并退出
- 清除位置信息并退出
- 清除位置信息并退出
-
-
- 取消
-
-
+
+ {children}
- )
+ ) : null
}
}
diff --git a/src/components/action-sheet/index.scss b/src/components/action-sheet/index.scss
index cf8a2eb8d..90a7cfbf6 100644
--- a/src/components/action-sheet/index.scss
+++ b/src/components/action-sheet/index.scss
@@ -19,31 +19,5 @@
text-align: center;
position: absolute;
background-color: white;
-
- &-header {
- font-size: 28px;
- padding: 25px 0;
- color: #888;
- border-bottom: 1px solid rgba($color: $color-black-0, $alpha: 0.1);
- }
-
- &-footer {
- font-size: 36px;
- padding: 25px 0;
- border-top: 12px solid rgba($color: #cdcdd1, $alpha: 0.3);
- }
- }
-}
-
-.body__list {
- text-align: center;
-
- &-item {
- font-size: 36px;
- padding: 25px 0;
-
- &:not(:last-child) {
- border-bottom: 1px solid rgba($color: $color-black-0, $alpha: 0.1);
- }
}
}
diff --git a/src/components/modal/action/button.js b/src/components/modal/action/button/index.js
similarity index 50%
rename from src/components/modal/action/button.js
rename to src/components/modal/action/button/index.js
index 849fb7866..12b9f11dd 100644
--- a/src/components/modal/action/button.js
+++ b/src/components/modal/action/button/index.js
@@ -5,20 +5,19 @@ import _isFunction from 'lodash/isFunction'
import './index.scss'
-export default class ModalButton extends Taro.Component {
- constructor() {
- super(...arguments)
- }
-
+export default class AtModalButton extends Taro.Component {
handleClick = () => {
- const { onClick } = this.props
- _isFunction(onClick) && onClick()
+ const { onClick, $$close } = this.props
+ if (_isFunction(onClick)) {
+ return onClick()
+ }
+ $$close()
}
- render() {
+ render () {
const { children } = this.props
return (
-