diff --git a/src/components/forms/EvoDropDown.tsx b/src/components/forms/EvoDropDown.tsx index fef0182..e4c9207 100644 --- a/src/components/forms/EvoDropDown.tsx +++ b/src/components/forms/EvoDropDown.tsx @@ -1,4 +1,4 @@ -import { useState } from "react"; +import { FocusEvent, useState } from "react"; type EvoDropDownItem = { name: string, @@ -11,17 +11,18 @@ interface EvoDropDownProps { items: EvoDropDownItem[]; initItem?: EvoDropDownItem; onValueChange?: (item: EvoDropDownItem) => void; + onBlur?: (e: FocusEvent) => void } interface MenuProps extends EvoDropDownProps { appear: boolean; } -function Menu ({ className, items, initItem, appear, onValueChange }: MenuProps) { +function Menu ({ className, items, initItem, appear, onValueChange, onBlur }: MenuProps) { const [currentItem, setItem] = useState(initItem || items[0]); return ( -
+
{items.map((item) => (
diff --git a/src/components/landing/ControlPiezoMusicEditor.tsx b/src/components/landing/ControlPiezoMusicEditor.tsx index c51c366..be88883 100644 --- a/src/components/landing/ControlPiezoMusicEditor.tsx +++ b/src/components/landing/ControlPiezoMusicEditor.tsx @@ -1,4 +1,4 @@ -import { ChangeEvent, MouseEventHandler, useState } from "react"; +import { ChangeEvent, MouseEventHandler, useEffect, useState } from "react"; import { usePiezoMusic } from "../../hooks"; import { PiezoMusic } from "../../types/board"; import EvoInput from "../forms/EvoInput"; @@ -28,23 +28,45 @@ function getNoteItems () { } function NoteItem ({note, index, parentIndex}: { note: string, index: number, parentIndex: number }) { - const { changeNote } = usePiezoMusic(); + const { changeNote, removeNote } = usePiezoMusic(); const [dropAppear, setApper] = useState(false); const noteItems = getNoteItems(); const toggleDropdown = () => { setApper(!dropAppear) }; + const handleChange = (item: { name: string, value: any }) => { + toggleDropdown(); changeNote(parentIndex, index, item.value); } + const handleRemove = () => { + removeNote(parentIndex, index); + } + return ( - + +
{note}
-
+
{piezo.notes.map((note, i) => ( {!isListen ? ( - Start Listening + Start ) : ( - Stop Listening + Stop )}
{servo.state+"°"}