当前位置:首页 > 开发 > 软件应用 > 正文

React confim popup components 弹出确认框组件的实现

发表于: 2016-06-03   作者:qiaolevip   来源:转载   浏览:
摘要: 先来张效果图:1.Components//components importReactfrom'react'; import{Link}from'react-router'; classConfirmWinsextendsReact.Component{ constructor(){ super(); } render(){ constprops=this.props;

先来张效果图:
React confim popup components 弹出确认框组件的实现_第1张图片

1.Components

// components

import React from 'react';
import { Link } from 'react-router';

class ConfirmWins extends React.Component {
  constructor() {
    super();
  }

  render() {
    const props = this.props;
    return (
      <div className="confirm-wins-container">
        <div className="wins">
          <div className="title text-center">{props.title}</div>
          <div className="desc gray-text96">{props.desc}</div>
          <div className="fn-btn text-center">
            {props.leftBtn?<span className="btn left-btn" onClick={props.onLeftClick}>{props.leftBtn.text}</span>:''}
            <span className="btn right-btn" onClick={props.onRightClick}>{props.rightBtn.text}</span>
          </div>
        </div>
      </div>
    );
  }
}

ConfirmWins.propTypes = {
  title: React.PropTypes.string.isRequired,
  desc: React.PropTypes.string.isRequired,
  leftBtn: React.PropTypes.object,
  rightBtn: React.PropTypes.object.isRequired,
  onLeftClick: React.PropTypes.func,
  onRightClick: React.PropTypes.func.isRequired,
};

export default ConfirmWins;

 

 

2. Stylus css

@import '../util/constant'

.confirm-wins-container
  position: fixed;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  z-index: 30;
  background: rgba(0, 0, 0, 0.5);

  .wins
    position: absolute;
    margin-top: 50%;
    background: $bgColor;
    width: 80%;
    margin-left: 10%;
    padding: 1em;
    border-radius 4px

    .title
      font-size: 16px;
      margin: .5em;

    .fn-btn
      margin-top 1em

      .btn
        display: inline-block;
        border: 1px solid $brandMainColor;
        height: 3em;
        width: 8em;
        line-height: 3em;
        border-radius 4px

      .left-btn
        float: left;
        color $brandMainColor

      .right-btn
        float: right;
        border: 1px solid $brandMainColor;
        background $brandMainColor
        color #fff

 

3.应用

const addressConfirm = {
      title: '很抱歉',
      desc: '您还没有设置收货地址,请设置您的收货地址',
      leftBtn: {
        text: '确认'
      },
      rightBtn: {
        text: '设置地址'
      }
    };


{state.isShowAddressPopUp?<ConfirmWins {...addressConfirm} onLeftClick={this.closePopUp.bind(this, 'isShowAddressPopUp')} onRightClick={this.goLink.bind(this, '#/address/add')} />:''}

 

 

写在最后,关于更多React Components请访问:

https://github.com/qiaolevip/react-mobile

React confim popup components 弹出确认框组件的实现

  • 0

    开心

    开心

  • 0

    板砖

    板砖

  • 0

    感动

    感动

  • 0

    有用

    有用

  • 0

    疑问

    疑问

  • 0

    难过

    难过

  • 0

    无聊

    无聊

  • 0

    震惊

    震惊

版权所有 IT知识库 CopyRight © 2009-2015 IT知识库 IT610.com , All Rights Reserved. 京ICP备09083238号