diff --git a/src/app.js b/src/app.js index c4c490290..ce38337c1 100644 --- a/src/app.js +++ b/src/app.js @@ -26,6 +26,8 @@ class App extends Component { '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/layout/flex/index' // 'pages/layout/grid/index', diff --git a/src/components/drawer/index.js b/src/components/drawer/index.js new file mode 100644 index 000000000..af429ca31 --- /dev/null +++ b/src/components/drawer/index.js @@ -0,0 +1,76 @@ +import Taro from '@tarojs/taro' +import { View } from '@tarojs/components' +import PropTypes from 'prop-types' +import AtIcon from '../icon/index' + +import './index.scss' + +export default class AtDrawer extends Taro.Component { + constructor () { + super(...arguments) + this.state = { + + } + this.onItemClick = this.onItemClick.bind(this) + } + + onItemClick (index) { + console.log('=====', index) + } + + render () { + const { + show, + mask, + width, + right, + items, + } = this.props + let rootClassName = ['at-drawer'] + const showAnimClass = show ? 'anim-show' : 'anim-hide' + const rootStyle = { + display: show ? 'block' : 'none', + } + const maskStyle = { + display: mask ? 'block' : 'none', + } + const listStyle = { + width, + } + if (right) { + listStyle.right = '0px' + listStyle.left = 'auto' + } + rootClassName.push(showAnimClass) + rootClassName = rootClassName.filter(str => str !== '') + + return ( + + + + + + { + items.map((name, index) => {name}) + } + + + + ) + } +} + +AtDrawer.defaultProps = { + show: false, + mask: true, + width: '230px', + right: false, + items: [], +} + +AtDrawer.propTypes = { + show: PropTypes.bool, + mask: PropTypes.bool, + width: PropTypes.string, + items: PropTypes.arrayOf(PropTypes.string), +} diff --git a/src/components/drawer/index.scss b/src/components/drawer/index.scss new file mode 100644 index 000000000..b7fe700bd --- /dev/null +++ b/src/components/drawer/index.scss @@ -0,0 +1,39 @@ + +.at-drawer { + position: relative; + z-index: 900; + + &__mask { + position: fixed; + left: 0; + right: 0; + top: 0; + bottom: 0; + background-color: rgba(0, 0, 0, 0.3); + } + + &__content { + position: fixed; + left: 0; + top: 0; + bottom: 0; + width: 460px; + background-color: #fff; + z-index: 1; + text-align: left; + } + + &__list { + margin: 0 0 0 18px; + max-height: 100%; + overflow-y: scroll; + + &-item { + height: 90px; + line-height: 90px; + font-size: 34px; + color: #000; + border-bottom: 1px solid #ddd; + } + } +} diff --git a/src/components/timeline/index.js b/src/components/timeline/index.js new file mode 100644 index 000000000..14a966f55 --- /dev/null +++ b/src/components/timeline/index.js @@ -0,0 +1,40 @@ +import Taro from '@tarojs/taro' +import { View } from '@tarojs/components' +import PropTypes from 'prop-types' + +import './index.scss' + +export default class AtTimeline extends Taro.Component { + constructor () { + super(...arguments) + this.state = { + + } + } + + onClick () { + } + + render () { + const { + pending, + } = this.props + let rootClassName = ['at-timeline'] + const pendingClass = pending ? 'at-timeline--pending' : '' + rootClassName.push(pendingClass) + rootClassName = rootClassName.filter(str => str !== '') + return ( + + {this.props.children} + + ) + } +} + +AtTimeline.defaultProps = { + pending: false, +} + +AtTimeline.propTypes = { + pending: PropTypes.bool, +} diff --git a/src/components/timeline/index.scss b/src/components/timeline/index.scss new file mode 100644 index 000000000..ae97c09eb --- /dev/null +++ b/src/components/timeline/index.scss @@ -0,0 +1,118 @@ + +.at-timelineitem { + position: relative; + padding: 0 0 12px; + + &__content { + font-size: 28px; + color: #333; + text-align: left; + margin-left: 36px; + height: 50px; + } + + &__dot, + &__icon { + font-size: 0; + position: absolute; + left: 0; + top: 8px; + width: 36px; + height: 30px; + box-sizing: border-box; + background-color: #fff; + z-index: 1; + text-align: left; + } + + &__dot { + &::after { + content: ''; + width: 20px; + height: 18px; + display: inline-block; + box-sizing: border-box; + border: 2px solid transparent; + border-radius: 50%; + border-color: #78A4FA; + margin-top: 5px; + } + + &.at-timelineitem__icon { + &::after { + display: none; + } + } + } + + &__icon { + left: -5px; + // top: 7px; + color: #78A4FA; + // padding-top: 2px; + } + + &--green { + .at-timelineitem__icon { + color: #00D06D; + } + + .at-timelineitem__dot { + &::after { + border-color: #00D06D; + } + } + } + + &--red { + .at-timelineitem__icon { + color: #FF4849; + } + + .at-timelineitem__dot { + &::after { + border-color: #FF4849; + } + } + } + + &--yellow { + .at-timelineitem__icon { + color: #FFCA3E; + } + + .at-timelineitem__dot { + &::after { + border-color: #FFCA3E; + } + } + } + + &__tail { + position: absolute; + top: 20px; + bottom: -10px; + left: 8px; + border-left: 2px solid #ececec; + } +} + +.at-timeline { + .at-timelineitem:last-child { + .at-timelineitem__tail { + display: none; + } + } + + &--pending { + .at-timelineitem:nth-last-child(2) { + .at-timelineitem__content { + height: 80px; + } + + .at-timelineitem__tail { + border-left-style: dotted; + } + } + } +} diff --git a/src/components/timeline/item.js b/src/components/timeline/item.js new file mode 100644 index 000000000..88c164b24 --- /dev/null +++ b/src/components/timeline/item.js @@ -0,0 +1,53 @@ +import Taro from '@tarojs/taro' +import { View } from '@tarojs/components' +import PropTypes from 'prop-types' +import AtIcon from '../icon/index' + +import './index.scss' + +export default class AtTimelineItem extends Taro.Component { + constructor () { + super(...arguments) + this.state = { + + } + } + + onClick () { + } + + render () { + const { + color, + icon, + } = this.props + let rootClassName = ['at-timelineitem'] + const colorClass = color ? `at-timelineitem--${color}` : '' + rootClassName.push(colorClass) + rootClassName = rootClassName.filter(str => str !== '') + const dotClass = ['at-timelineitem__dot'] + if (icon) dotClass.push('at-timelineitem__icon') + + return ( + + + + {icon && } + + + {this.props.children} + + + ) + } +} + +AtTimelineItem.defaultProps = { + color: 'blue', + icon: '', +} + +AtTimelineItem.propTypes = { + color: PropTypes.string, + icon: PropTypes.string, +} diff --git a/src/pages/index/index.js b/src/pages/index/index.js index f2f32441d..676699175 100644 --- a/src/pages/index/index.js +++ b/src/pages/index/index.js @@ -167,6 +167,10 @@ export default class Index extends Taro.Component { { title: '抽屉', name: 'Drawer' + }, + { + title: '时间轴', + name: 'Timeline' } ] } diff --git a/src/pages/navigation/drawer/index.js b/src/pages/navigation/drawer/index.js new file mode 100644 index 000000000..e217a9aa5 --- /dev/null +++ b/src/pages/navigation/drawer/index.js @@ -0,0 +1,42 @@ +import Taro from '@tarojs/taro' +import { View } from '@tarojs/components' +import AtDrawer from '../../../components/drawer/index' +import AtButton from '../../../components/button/index' + +import './index.scss' + +export default class DrawerPage extends Taro.Component { + config = { + navigationBarTitleText: 'Drawer Page' + } + constructor () { + super(...arguments) + this.state = { + drawerShow: true, + } + } + + onClick () { + this.setState({ + drawerShow: !this.state.drawerShow, + }) + } + + onClose () { + this.setState({ + drawerShow: false, + }) + } + + render () { + return ( + + + + 显示drawer + + + + ) + } +} diff --git a/src/pages/navigation/drawer/index.scss b/src/pages/navigation/drawer/index.scss new file mode 100644 index 000000000..47eb50d73 --- /dev/null +++ b/src/pages/navigation/drawer/index.scss @@ -0,0 +1,16 @@ + + +.page { + background-color: #fff; +} + +.example { + margin-bottom: 15px; + text-align: center; + + &-item { + vertical-align: middle; + display: inline-block; + margin: 0 20px; + } +} diff --git a/src/pages/navigation/timeline/index.js b/src/pages/navigation/timeline/index.js new file mode 100644 index 000000000..1baf09b33 --- /dev/null +++ b/src/pages/navigation/timeline/index.js @@ -0,0 +1,29 @@ +import Taro from '@tarojs/taro' +import { View } from '@tarojs/components' +import AtTimeline from '../../../components/timeline/index' +import AtTimelineItem from '../../../components/timeline/item' + +import './index.scss' + +export default class TimelinePage extends Taro.Component { + config = { + navigationBarTitleText: 'Timeline Page' + } + + render () { + return ( + + + + + 刷牙洗脸 + 吃早餐 + 上班 + 睡觉 + + + + + ) + } +} diff --git a/src/pages/navigation/timeline/index.scss b/src/pages/navigation/timeline/index.scss new file mode 100644 index 000000000..47eb50d73 --- /dev/null +++ b/src/pages/navigation/timeline/index.scss @@ -0,0 +1,16 @@ + + +.page { + background-color: #fff; +} + +.example { + margin-bottom: 15px; + text-align: center; + + &-item { + vertical-align: middle; + display: inline-block; + margin: 0 20px; + } +}