BlockCheckbox.tsx 827 Bytes
Newer Older
jim's avatar
jim committed
1
import React from 'react';
afc163's avatar
afc163 committed
2
import { Tooltip, Icon } from 'antd';
jim's avatar
jim committed
3 4
import style from './index.less';

5 6 7 8 9 10
interface BlockChecboxProps {
  value: string;
  onChange: (key: string) => void;
  list: any[];
}
const BlockChecbox: React.SFC<BlockChecboxProps> = ({ value, onChange, list }) => (
11 12
  <div className={style.blockChecbox} key={value}>
    {list.map(item => (
afc163's avatar
afc163 committed
13 14 15 16 17 18 19 20 21 22 23
      <Tooltip title={item.title} key={item.key}>
        <div className={style.item} onClick={() => onChange(item.key)}>
          <img src={item.url} alt={item.key} />
          <div
            className={style.selectIcon}
            style={{
              display: value === item.key ? 'block' : 'none',
            }}
          >
            <Icon type="check" />
          </div>
24
        </div>
afc163's avatar
afc163 committed
25
      </Tooltip>
26 27 28
    ))}
  </div>
);
jim's avatar
jim committed
29 30

export default BlockChecbox;