BlockCheckbox.tsx 834 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';

何乐's avatar
何乐 committed
5
export interface BlockChecboxProps {
6 7 8 9
  value: string;
  onChange: (key: string) => void;
  list: any[];
}
何乐's avatar
何乐 committed
10 11

const BlockChecbox: React.FC<BlockChecboxProps> = ({ value, onChange, list }) => (
12 13
  <div className={style.blockChecbox} key={value}>
    {list.map(item => (
afc163's avatar
afc163 committed
14 15 16 17 18 19 20 21 22 23 24
      <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>
25
        </div>
afc163's avatar
afc163 committed
26
      </Tooltip>
27 28 29
    ))}
  </div>
);
jim's avatar
jim committed
30 31

export default BlockChecbox;