working trigger editor

This commit is contained in:
ari committed 2021-12-21 22:46:16 -05:00
1 parent 3cfb8151eb
commit 24f7c3c3af
14 files changed
+250 -66

No files matched your search

+8 -1
View File
@@ -26,6 +26,10 @@ export type DAGCircleElm = {
{
icon: 'blank',
onRemove?: () => void;
} |
{
icon: 'color',
color: string,
}
)
export interface DAGNodeElm {
@@ -157,8 +161,10 @@ export function* mapDataToElements({
} else if (elm.icon === 'edit') {
clickProps.onEdit = elm.onEdit
clickProps.onRemove = elm.onRemove
} else {
} else if (elm.icon === 'blank') {
clickProps.onRemove = elm.onRemove
} else {
clickProps.backgroundColor = elm.color
}
yield <DAGCircle
key={`(${elm.loc})-o`}
@@ -187,5 +193,6 @@ export const DAGBoard: FC<Props & { zoomLevel: number }> = props => {
zoomLevel={props.zoomLevel}
>
{el}
{props.children}
</SVGBoard>
}
+15 -10
View File
@@ -11,6 +11,7 @@ export interface AddProps {
onRemove?: () => void;
loc: Point,
size: number,
backgroundColor?: string;
}
export const DAGCircle = ({
loc: [x, y],
@@ -18,27 +19,31 @@ export const DAGCircle = ({
onEdit,
onAdd,
onRemove,
backgroundColor,
}: AddProps) => {
const { classes } = useCircleStyles({
size: size * 0.9,
hasOnFunction: !!onEdit || !!onAdd,
hasRemoveFunction: !!onRemove,
backgroundColor,
});
return <>
<foreignObject x={x} y={y} width={size} height={size}>
<div className={classes.root}>
{onEdit ?
<PencilIcon
size={70} units="%"
className={classes.icon}
onClick={onEdit}
/> : onAdd ?
<AddIcon
{
onEdit ?
<PencilIcon
size={70} units="%"
className={classes.icon}
onClick={onAdd}
/>
: "else"}
onClick={onEdit}
/> : onAdd ?
<AddIcon
size={70} units="%"
className={classes.icon}
onClick={onAdd}
/>
: backgroundColor ? "" : "else"
}
{onRemove ? <TrashIcon className={classes.trashIcon} onClick={onRemove} /> : <></>}
</div>
</foreignObject>
+19 -16
View File
@@ -146,23 +146,26 @@ export const useCircleStyles = createAppUseStyles<{
size: number,
hasOnFunction: boolean,
hasRemoveFunction: boolean,
backgroundColor?: string,
}>(theme => ({
root: ({size, hasOnFunction, hasRemoveFunction}) => ({
backgroundColor: Color(theme.primary).set('rgb.g', 100).hex(),
borderRadius: hasRemoveFunction ? 10 : 500,
height: size,
width: size,
cursor: hasOnFunction ? "pointer" : 'default',
"&:hover": {
backgroundColor: (hasOnFunction && !hasRemoveFunction) ?
Color(theme.primary).set('rgb.g', 150).hex() :
Color(theme.primary).set('rgb.g', 100).hex(),
},
fontSize: `${size * 0.4}px`,
display: 'flex',
justifyContent: 'center',
alignItems: 'center',
}),
root: ({ size, hasOnFunction, hasRemoveFunction, backgroundColor }) => {
const baseColor = backgroundColor ? backgroundColor : Color(theme.primary).set('rgb.g', 100).hex();
const hoverColor = (hasOnFunction && !hasRemoveFunction) ? Color(theme.primary).set('rgb.g', 150).hex() : baseColor
return {
backgroundColor: baseColor,
borderRadius: hasRemoveFunction ? 10 : 500,
height: size,
width: size,
cursor: hasOnFunction ? "pointer" : 'default',
"&:hover": {
backgroundColor: hoverColor,
},
fontSize: `${size * 0.4}px`,
display: 'flex',
justifyContent: 'center',
alignItems: 'center',
}
},
icon: {
"&:hover": {
borderRadius: 500,