| | |
| | | import React from 'react' |
| | | import { useDrag, useDrop } from 'react-dnd' |
| | | import { Icon } from 'antd' |
| | | import { Popover } from 'antd' |
| | | import { EditOutlined, CloseOutlined } from '@ant-design/icons' |
| | | import './index.scss' |
| | | |
| | | const Card = ({ id, card, moveCard, findCard, editCard, delCard }) => { |
| | |
| | | }), |
| | | }) |
| | | |
| | | const opacity = isDragging ? 0 : 1 |
| | | const opacity = isDragging ? 0.5 : 1 |
| | | |
| | | const [, drop] = useDrop({ |
| | | accept: 'detail', |
| | |
| | | } |
| | | }) |
| | | |
| | | let _class = '' |
| | | if (card.bold === 'true') { |
| | | _class = 'ant-card-meta-title' |
| | | } else { |
| | | _class = 'ant-card-meta-description' |
| | | } |
| | | |
| | | if (card.width) { |
| | | _class += ' ' + card.width |
| | | } |
| | | if (card.align) { |
| | | _class += ' ' + card.align |
| | | } |
| | | |
| | | return ( |
| | | <div ref={node => drag(drop(node))} className={_class} style={{ opacity: opacity}}> |
| | | <div className="content" title={card.content}>{card.content}</div> |
| | | <Icon className="edit" title="编辑" type="edit" onClick={() => editCard(card)} /> |
| | | <Icon className="edit close" title="删除" type="close" onClick={() => delCard(card)} /> |
| | | </div> |
| | | <Popover overlayClassName="mk-popover-control-wrap" mouseLeaveDelay={0.2} mouseEnterDelay={0.2} content={ |
| | | <div className="mk-popover-control"> |
| | | <EditOutlined className="edit" title="编辑" onClick={() => editCard(card)} /> |
| | | <CloseOutlined className="edit close" title="删除" onClick={() => delCard(card)} /> |
| | | </div> |
| | | } trigger="hover"> |
| | | <div ref={node => drag(drop(node))} className={'mk-card-meta-item ' + card.align} style={{opacity: opacity, width: card.width + '%'}}> |
| | | <div className={'content line' + card.height} style={{fontWeight: card.fontWeight, fontSize: card.fontSize + 'px', height: card.height * card.fontSize * 1.5}} title={card.content}>{card.content}</div> |
| | | </div> |
| | | </Popover> |
| | | ) |
| | | } |
| | | export default Card |