Welink React-ui基础组件HeadIcon

举报
云会议运营喵大人 发表于 2020/02/21 17:43:10 2020/02/21
【摘要】 HeadIcon头像图标。HeadIcon UI提供与WeLink规范一致的视图。参数说明名称类型默认值说明sizestring'lg'头像大小srcstring/array头像路径,当src为数组是,必须为ArrayObject,例如:[{ type: 'text', bgColor: '2', text: 'MN' }]import React from 'react';import {...

HeadIcon


头像图标。HeadIcon UI提供与WeLink规范一致的视图。

参数说明

名称类型默认值说明
sizestring'lg'头像大小
srcstring/array
头像路径,当src为数组是,必须为ArrayObject,例如:[{ type: 'text', bgColor: '2', text: 'MN' }]

import React from 'react';
import { HeadIcon } from '@wecode/react-weui';
import Head1 from './image/head1.jpg';
import Head2 from './image/head2.jpg';
import Head3 from './image/head3.jpg';

export default class HeadIconDemo extends React.Component {
  mockData(size) {
    const exampleDataSingleImage = {
      size,
      src: Head2,
      refAttr1: `exampleData<span class="hljs-subst">${size}_singleImage`,
      className: 'testClassName1'
    };
    const exampleDataSingleText = {
      size,
      src: [{ type: 'text', bgColor: '1', text: '哈哈' }],
      refAttr1: `exampleData<span class="hljs-subst">${size}_singleText`,
      className: 'testClassName1'
    };
    const exampleDataGroup1 = {
      size,
      src: [{ type: 'image', url: Head3 }],
      refAttr1: `exampleData<span class="hljs-subst">${size}_group1`,
      className: 'testClassName1'
    };
    const exampleDataGroup2 = {
      size,
      src: [
        { type: 'image', url: Head3 },
        { type: 'text', bgColor: '6', text: 'MN' }
      ],
      refAttr1: `exampleData<span class="hljs-subst">${size}_group2`,
      className: 'testClassName1'
    };
    const exampleDataGroup3 = {
      size,
      src: [
        { type: 'image', url: Head3 },
        { type: 'text', bgColor: '5', text: 'LF' },
        { type: 'image', url: Head2 }
      ],
      refAttr1: `exampleData<span class="hljs-subst">${size}_group3`,
      className: 'testClassName1'
    };
    const exampleDataGroup4 = {
      size,
      src: [
        { type: 'image', url: Head1 },
        { type: 'text', bgColor: '4', text: '码码' },
        { type: 'image', url: Head2 },
        { type: 'text', bgColor: '3', text: '微微' }
      ],
      refAttr1: `exampleData<span class="hljs-subst">${size}_group4`,
      className: 'testClassName1'
    };
    const abc = {};
    abc[`sImg<span class="hljs-subst">${size}`] = exampleDataSingleImage;
    abc[`sTxt<span class="hljs-subst">${size}`] = exampleDataSingleText;
    abc[`gp1<span class="hljs-subst">${size}`] = exampleDataGroup1;
    abc[`gp2<span class="hljs-subst">${size}`] = exampleDataGroup2;
    abc[`gp3<span class="hljs-subst">${size}`] = exampleDataGroup3;
    abc[`gp4<span class="hljs-subst">${size}`] = exampleDataGroup4;
    return abc;
  }

  mockData2(size) {
    const exampleDataSingleImage = {
      size,
      src: Head2,
      refAttr1: `exampleData<span class="hljs-subst">${size}_singleImage`,
      className: 'testClassName1'
    };

    const exampleDataSingleTextMn1 = {
      size,
      src: [{ type: 'text', bgColor: '1', text: '美娜' }],
      refAttr1: `exampleData<span class="hljs-subst">${size}_singleText`,
      className: 'testClassName1'
    };
    const exampleDataSingleTextMn2 = {
      size,
      src: [{ type: 'text', bgColor: '2', text: 'MN' }],
      refAttr1: `exampleData<span class="hljs-subst">${size}_singleText`,
      className: 'testClassName1'
    };
    const exampleDataSingleTextMn3 = {
      size,
      src: [{ type: 'text', bgColor: '3', text: 'MN' }],
      refAttr1: `exampleData<span class="hljs-subst">${size}_singleText`,
      className: 'testClassName1'
    };
    const exampleDataSingleTextLf1 = {
      size,
      src: [{ type: 'text', bgColor: '4', text: '刘丰' }],
      refAttr1: `exampleData<span class="hljs-subst">${size}_singleText`,
      className: 'testClassName1'
    };
    const exampleDataSingleTextLf2 = {
      size,
      src: [{ type: 'text', bgColor: '5', text: 'LF' }],
      refAttr1: `exampleData<span class="hljs-subst">${size}_singleText`,
      className: 'testClassName1'
    };
    const exampleDataSingleTextLf3 = {
      size,
      src: [{ type: 'text', bgColor: '6', text: 'LF' }],
      refAttr1: `exampleData<span class="hljs-subst">${size}_singleText`,
      className: 'testClassName1'
    };
    const abc = {};
    abc[`sImg<span class="hljs-subst">${size}`] = exampleDataSingleImage;
    abc[`sTxt<span class="hljs-subst">${size}mn1`] = exampleDataSingleTextMn1;
    abc[`sTxt<span class="hljs-subst">${size}mn2`] = exampleDataSingleTextMn2;
    abc[`sTxt<span class="hljs-subst">${size}mn3`] = exampleDataSingleTextMn3;
    abc[`sTxt<span class="hljs-subst">${size}lf1`] = exampleDataSingleTextLf1;
    abc[`sTxt<span class="hljs-subst">${size}lf2`] = exampleDataSingleTextLf2;
    abc[`sTxt<span class="hljs-subst">${size}lf3`] = exampleDataSingleTextLf3;

    return abc;
  }

  render() {
    const {
      sImg80
    } = this.mockData2('80');
    const {
      sImg56
    } = this.mockData('56');
    const {
      sImg48
    } = this.mockData2('48');
    const {
      sImg40, gp140
    } = this.mockData('40');
    const {
      sImg36, gp136
    } = this.mockData('36');
    const {
      sImg32
    } = this.mockData2('32');
    const {
      sImg30
    } = this.mockData2('30');
    const {
      sImg20
    } = this.mockData2('20');

    return (
      <section>
        <div className="page__bd page__bd_spacing">
          <HeadIcon size="320" src={Head3} />
          <span className="page__desc">320*320</span>
        </div>
        <br />
        <div className="page__bd page__bd_spacing">
          <HeadIcon {...sImg80} />
          <HeadIcon size="80" src={Head3} />
          <span className="page__desc">80x80</span>
        </div>
        <br />
        <div className="page__bd page__bd_spacing">
          <HeadIcon {...sImg56} />
          <HeadIcon size="56" src={Head3} />
          <span className="page__desc">56x56</span>
        </div>
        <br />
        <div className="page__bd page__bd_spacing">
          <HeadIcon {...sImg48} />
          <HeadIcon size="48" src={Head3} />
          <span className="page__desc">48x48</span>
        </div>
        <br />
        <div className="page__bd page__bd_spacing">
          <HeadIcon {...sImg40} />
          <HeadIcon {...gp140} />
          <span className="page__desc">40×40</span>
        </div>
        <br />
        <div className="page__bd page__bd_spacing">
          <HeadIcon {...sImg36} />
          <HeadIcon {...gp136} />
          <span className="page__desc">36x36</span>
        </div>
        <br />
        <div className="page__bd page__bd_spacing">
          <HeadIcon {...sImg32} />
          <HeadIcon size="32" src={Head3} />
          <span className="page__desc">32x32</span>
        </div>
        <br />
        <div className="page__bd page__bd_spacing">
          <HeadIcon {...sImg30} />
          <HeadIcon size="30" src={Head3} />
          <span className="page__desc">30x30</span>
        </div>
        <br />
        <div className="page__bd page__bd_spacing">
          <HeadIcon {...sImg20} />
          <HeadIcon size="20" src={Head3} />
          <span className="page__desc">20x20</span>
        </div>
        <br />
        {/* // old example: */}
        <div className="page__bd page__bd_spacing">
          <HeadIcon size="md" src={Head2} />
          <HeadIcon size="md" src={Head3} />
          <span className="page__desc">32×32</span>
        </div>
        <br />
        <div className="page__bd page__bd_spacing">
          <HeadIcon size="sm" src={Head2} />
          <HeadIcon size="sm" src={Head3} />
          <span className="page__desc">20×20</span>
        </div>
      </section>
    );
  }
}


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

评论(0

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

全部回复

上滑加载中

设置昵称

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

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

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