Welink React-ui表单组件Button

举报
云会议运营喵大人 发表于 2020/02/21 18:03:19 2020/02/21
【摘要】 Button按钮。Button UI 提供与WeLink规范一致的视图。 按钮的类型包括:页面主操作、页面次要操作、警告类操作和页面一般操作。参数说明参数类型默认值说明typestring'primary'按钮的类型,可选值:primary,default,warnprimary:页面主操作default:页面次要操作warn:警告类操作sizestring-按钮的大小,可选值:normal...

Button


按钮。Button UI 提供与WeLink规范一致的视图。 按钮的类型包括:页面主操作、页面次要操作、警告类操作和页面一般操作。

参数说明

参数类型默认值说明
typestring'primary'按钮的类型,可选值:primary,default,warn
primary:页面主操作
default:页面次要操作
warn:警告类操作
sizestring-按钮的大小,可选值:normal,small
plainboolfalse是否为白色背景
iconcomponent-按钮图标

import React from 'react';
import { Button, ButtonArea } from '@wecode/react-weui';
import './button.less';

const imgStyle = { display: 'inline-block', verticalAlign: 'middle' };
export default class ButtonDemo extends React.Component {
  state = {
    btnType: 'spacingBtns'
  };

  handleChangeValue = (key, value) => {
    this.setState({ [key]: value });
  };

  clickBtns(type) {
    this.setState({ btnType: type });
  }

  render() {
    const { btnType } = this.state;
    return (
      <div>
        <section>
          {btnType === 'spacingBtns' ? (
            <ButtonArea fixedSpacing>
              <Button type="warn">取消</Button>
              <Button type="primary">确定</Button>
            </ButtonArea>
          ) : null}

          {btnType === 'btns' ? (
            <ButtonArea fixed>
              <Button type="warn">取消</Button>
              <Button type="primary">确定</Button>
            </ButtonArea>
          ) : null}
          {btnType === 'sureBtn' ? (
            <ButtonArea fixedSpacing>
              <Button type="primary">确定</Button>
            </ButtonArea>
          ) : null}

          {btnType === 'deleteBtn' ? (
            <ButtonArea fixedSpacing>
              <Button type="warn">删除</Button>
            </ButtonArea>
          ) : null}
          <div>
            <Button>页面主操作 Normal</Button>

            <Button disabled>页面主操作 Disabled</Button>

            <Button type="warn">警告类操作 Normal</Button>

            <Button type="warn" disabled>
              警告类操作 Normal
            </Button>
          </div>

          <div className="page__bd page__bd_spacing button-sp-area__item">
            <Button type="primary" size="small" plain>
              四字按钮
            </Button>{' '}
            <Button type="default" size="small" plain>
              四字按钮
            </Button>
          </div>

          <div className="page__bd page__bd_spacing button-sp-area__item">
            <Button size="small">Mini</Button>
          </div>

          <div className="button-sp-area button-sp-area__item">
            <Button
              type="primary"
              size="small"
              plain
              icon={(
                <img
                  alt="加入会议"
                  src="data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz4KPHN2ZyB3aWR0aD0iMTZweCIgaGVpZ2h0PSIxNnB4IiB2aWV3Qm94PSIwIDAgMTYgMTYiIHZlcnNpb249IjEuMSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB4bWxuczp4bGluaz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94bGluayI+CiAgICA8IS0tIEdlbmVyYXRvcjogU2tldGNoIDUyLjYgKDY3NDkxKSAtIGh0dHA6Ly93d3cuYm9oZW1pYW5jb2RpbmcuY29tL3NrZXRjaCAtLT4KICAgIDx0aXRsZT7liIfniYc8L3RpdGxlPgogICAgPGRlc2M+Q3JlYXRlZCB3aXRoIFNrZXRjaC48L2Rlc2M+CiAgICA8ZyBpZD0iMTXmjInpkq4oYnV0dG9u77yJIiBzdHJva2U9Im5vbmUiIHN0cm9rZS13aWR0aD0iMSIgZmlsbD0ibm9uZSIgZmlsbC1ydWxlPSJldmVub2RkIj4KICAgICAgICA8ZyBpZD0i57uE5Lu2L+W3peS9nOWPsC/ml6XljobljaHniYcvaWNvbuinhumikSI+CiAgICAgICAgICAgIDxnIGlkPSJQYWdlLTEiPgogICAgICAgICAgICAgICAgPHJlY3QgaWQ9IlJlY3RhbmdsZS0yIiBvcGFjaXR5PSIwLjMwMDAwMDAxMiIgeD0iMCIgeT0iMCIgd2lkdGg9IjE2IiBoZWlnaHQ9IjE2Ij48L3JlY3Q+CiAgICAgICAgICAgICAgICA8cGF0aCBkPSJNMS41ODU4MTcwNywxMiBDMS4yNjMwNDEzLDEyIDEsMTEuNzMyNzY0NCAxLDExLjQwMzY1MzggTDEsNC41OTYzNDYxOCBDMSw0LjI2NzIzNTYzIDEuMjYzMDQxMyw0IDEuNTg1ODE3MDcsNCBMMTEuMjcwMjYzMSw0IEMxMS41OTMwMzg4LDQgMTEuODU2MDgwMSw0LjI2NzIzNTYzIDExLjg1NjA4MDEsNC41OTYzNDYxOCBMMTEuODU2MDgwMSw1Ljk3NDEyOTg4IEwxNC4xNDAxMzc5LDUuMDc5MjU1MDEgQzE0LjE5Nzc3NjQsNS4wMzg3MTYyNyAxNSw0LjU2MzgwODUxIDE1LDQuODkyMzg1NjUgTDE1LDExLjIzNDAzMTIgQzE1LDExLjU2MzY3NTIgMTQuMTk3Nzc2NCwxMS4wODgyMzQgMTQuMTAzOTgyOCwxMS4wMjg0OTI3IEwxMS44NTYwODAxLDEwLjAyMjY2OTcgTDExLjg1NjA4MDEsMTEuNDAzNjUzOCBDMTEuODU2MDgwMSwxMS43MzI3NjQ0IDExLjU5MzAzODgsMTIgMTEuMjcwMjYzMSwxMiBMMS41ODU4MTcwNywxMiBaIiBpZD0iRmlsbC0xIiBmaWxsPSIjMDM5QkU1Ij48L3BhdGg+CiAgICAgICAgICAgIDwvZz4KICAgICAgICA8L2c+CiAgICA8L2c+Cjwvc3ZnPg=="
                  style={imgStyle}
                />
              )}
            >
              加入会议
            </Button>
          </div>
          <div className="btn-tep-container">
            <Button type="warn" size="middle">
              中等按钮
            </Button>
            <Button type="primary" size="middle">
              中等按钮
            </Button>
          </div>
          <div className="page__bd page__bd_spacing button-sp-area__item">
            <Button
              type="primary"
              size="small"
              plain
              onClick={() => {
                this.clickBtns('spacingBtns');
              }}
            >
              有间距双按钮
            </Button>
            <Button
              type="primary"
              size="small"
              plain
              onClick={() => {
                this.clickBtns('btns');
              }}
            >
              无间距双按钮
            </Button>
            <Button
              type="primary"
              size="small"
              plain
              onClick={() => {
                this.clickBtns('sureBtn');
              }}
            >
              确定单按钮
            </Button>
            <Button
              type="primary"
              size="small"
              plain
              onClick={() => {
                this.clickBtns('deleteBtn');
              }}
            >
              删除单按钮
            </Button>
          </div>
          <br />
          <br />
          <br />
          <br />
          <br />
        </section>
      </div>
    );
  }
}


【版权声明】本文为华为云社区用户原创内容,未经允许不得转载,如需转载请自行联系原作者进行授权。如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱: cloudbbs@huaweicloud.com
  • 点赞
  • 收藏
  • 关注作者

评论(0

0/1000
抱歉,系统识别当前为高风险访问,暂不支持该操作

全部回复

上滑加载中

设置昵称

在此一键设置昵称,即可参与社区互动!

*长度不超过10个汉字或20个英文字符,设置后3个月内不可修改。

*长度不超过10个汉字或20个英文字符,设置后3个月内不可修改。