mirror of
https://github.com/projectstorm/react-diagrams.git
synced 2025-08-15 09:19:05 +08:00
39 lines
779 B
TypeScript
39 lines
779 B
TypeScript
import * as React from 'react';
|
|
import styled from '@emotion/styled';
|
|
|
|
export interface TrayItemWidgetProps {
|
|
model: any;
|
|
color?: string;
|
|
name: string;
|
|
}
|
|
|
|
namespace S {
|
|
export const Tray = styled.div<{ color: string }>`
|
|
color: white;
|
|
font-family: Helvetica, Arial;
|
|
padding: 5px;
|
|
margin: 0px 10px;
|
|
border: solid 1px ${(p) => p.color};
|
|
border-radius: 5px;
|
|
margin-bottom: 2px;
|
|
cursor: pointer;
|
|
`;
|
|
}
|
|
|
|
export class TrayItemWidget extends React.Component<TrayItemWidgetProps> {
|
|
render() {
|
|
return (
|
|
<S.Tray
|
|
color={this.props.color}
|
|
draggable={true}
|
|
onDragStart={(event) => {
|
|
event.dataTransfer.setData('storm-diagram-node', JSON.stringify(this.props.model));
|
|
}}
|
|
className="tray-item"
|
|
>
|
|
{this.props.name}
|
|
</S.Tray>
|
|
);
|
|
}
|
|
}
|