-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add drag and drop functionality to chart
- Loading branch information
Showing
13 changed files
with
664 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import React, { FC, useState } from 'react' | ||
import { TeliAutocomplete, TeliButton } from "@telicent-oss/ds" | ||
import { DialogBox } from '../../lib/DialogBox/DialogBox' | ||
|
||
interface EdgeDialogProps { | ||
onClose: () => void | ||
onSubmit: (name: string) => void | ||
options: Array<string> | ||
title: string | ||
} | ||
export const EdgeDialog: FC<EdgeDialogProps> = ({ options, onClose, title, onSubmit }) => { | ||
const [selectedEdgeType, setSelectedEdgeType] = useState<string | null>(null) | ||
|
||
const onChangePrefix = (event: React.SyntheticEvent<Element, Event>, value: string | null) => { | ||
event.preventDefault() | ||
if (!value) { | ||
console.warn("Invalid value", value) | ||
} | ||
setSelectedEdgeType(value) | ||
} | ||
|
||
const onHandleSubmit = () => { | ||
if (!selectedEdgeType) { | ||
console.warn("Edge must have valid inputs") | ||
return | ||
} | ||
onSubmit(selectedEdgeType) | ||
} | ||
|
||
return ( | ||
<DialogBox onClose={onClose} title={title}> | ||
<div className="dark:text-whiteSmoke flex flex-col gap-y-8 rounded"> | ||
<div className='flex gap-x-2'> | ||
<TeliAutocomplete options={options} width={150} label="Edge Type:" onChange={onChangePrefix} /> | ||
</div> | ||
<div className='flex justify-end w-full'> | ||
<TeliButton onClick={onHandleSubmit} variant="secondary" disabled={!selectedEdgeType}>Submit</TeliButton> | ||
</div> | ||
</div> | ||
</DialogBox> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import React, { FC, useState } from 'react' | ||
import { TeliAutocomplete, TeliButton, TeliTextField } from "@telicent-oss/ds" | ||
import { DialogBox } from '../../lib/DialogBox/DialogBox' | ||
|
||
interface NodeDialogProps { | ||
onClose: () => void | ||
onSubmit: (name: string) => void | ||
options: Array<string> | ||
title: string | ||
} | ||
export const NodeDialog: FC<NodeDialogProps> = ({ options, onClose, title, onSubmit }) => { | ||
const [selectedPrefix, setSelectedPrefix] = useState<string>(options[0]) | ||
const [name, setName] = useState<string>(crypto.randomUUID()) | ||
|
||
const onChangeName: React.ChangeEventHandler<HTMLInputElement> = (event) => { | ||
event.preventDefault() | ||
if (!event.target.value) { | ||
setName(crypto.randomUUID()) | ||
return | ||
} | ||
|
||
setName(event.target.value) | ||
} | ||
|
||
const onChangePrefix = (event: React.SyntheticEvent<Element, Event>, value: string | null) => { | ||
event.preventDefault() | ||
if (!value) { | ||
console.warn("Invalid value", value) | ||
return | ||
} | ||
setSelectedPrefix(value) | ||
} | ||
|
||
const onHandleSubmit = () => { | ||
if (!selectedPrefix || !name) { | ||
console.warn("Node must have valid inputs") | ||
return | ||
} | ||
onSubmit(`${selectedPrefix}${name}`) | ||
} | ||
|
||
return ( | ||
<DialogBox onClose={onClose} title={title}> | ||
<div className="dark:text-whiteSmoke flex flex-col gap-y-8 rounded"> | ||
<div className='flex gap-x-2'> | ||
<TeliAutocomplete options={options} width={150} label="Prefix" onChange={onChangePrefix} /> | ||
<TeliTextField id="node-name" label="Node name" onChange={onChangeName} value={name} required /> | ||
</div> | ||
<div className='flex justify-end w-full'> | ||
<TeliButton onClick={onHandleSubmit} variant="secondary" disabled={!name || !selectedPrefix}>Submit</TeliButton> | ||
</div> | ||
</div> | ||
</DialogBox> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import React, { FC } from 'react' | ||
|
||
interface DialogBoxProps { | ||
title: string | ||
onClose: () => void | ||
children: React.ReactNode | ||
} | ||
export const DialogBox: FC<DialogBoxProps> = ({ onClose, children, title }) => { | ||
return ( | ||
<> | ||
<div className="absolute top-0 left-0 h-full w-full z-40 bg-black-100 opacity-80" onClick={onClose}></div> | ||
<div className="bg-black-100 z-50 absolute top-24 left-1/2 transform -translate-x-1/2 py-3 px-6 rounded border-black-400 shadow-black-300 shadow-md border" > | ||
<h2 className='text-left pb-6'>{title}</h2> | ||
{children} | ||
</div> | ||
</> | ||
) | ||
} |
Oops, something went wrong.