diff --git a/src/components/landing/ControlPiezoMusicEditor.tsx b/src/components/landing/ControlPiezoMusicEditor.tsx index be88883..7a36e47 100644 --- a/src/components/landing/ControlPiezoMusicEditor.tsx +++ b/src/components/landing/ControlPiezoMusicEditor.tsx @@ -7,6 +7,7 @@ import EvoDropDown from "../forms/EvoDropDown"; import Button from "../forms/Button"; import { pitch } from "../../data/melodies"; import { PatchPiezoMusic } from "../../controllers/BoardController"; +import SearchItemModal from "../modals/SearchItemModal"; function getNoteItems () { const pitches = Object.keys(pitch); @@ -45,6 +46,7 @@ function NoteItem ({note, index, parentIndex}: { note: string, index: number, pa } return ( + <> @@ -65,13 +67,22 @@ function NoteItem ({note, index, parentIndex}: { note: string, index: number, pa {note} - + /> */} + + {dropAppear == true && } + > ) } @@ -84,23 +95,32 @@ function NotePlus ({ parentIndex }: { parentIndex: number }) { const handleAddNote = (item: { name: string, value: any }) => { addNote(parentIndex, item.value); + setApper(false); } return ( - - - + + + {/* */} + + {dropAppear == true && - + onClose={toggleDropdown} + />} + > ) } function PiezoEditor ({ piezo, index }: { piezo: PiezoMusic, index: number }) { - const { setName, setPin, setBeat, setTempo } = usePiezoMusic(); + const { setName, setPin, setBeat, setTempo, removePiezo } = usePiezoMusic(); const beatsItem = [ { @@ -123,6 +143,9 @@ function PiezoEditor ({ piezo, index }: { piezo: PiezoMusic, index: number }) { const initBeatItem = beatsItem.find((item) => item.value == piezo.beats); + const exportJson = () => { + } + const handle = { changeName: (e: ChangeEvent) => { setName(index, e.target.value); @@ -137,13 +160,20 @@ function PiezoEditor ({ piezo, index }: { piezo: PiezoMusic, index: number }) { const tempo = Number.parseInt(e.target.value); setTempo(index, tempo); }, + remove: () => { + removePiezo(index); + }, play: () => { PatchPiezoMusic(piezo); - } + }, + export: exportJson } return ( - + + + + - + Export diff --git a/src/components/modals/SearchItemModal.tsx b/src/components/modals/SearchItemModal.tsx new file mode 100644 index 0000000..040ab6e --- /dev/null +++ b/src/components/modals/SearchItemModal.tsx @@ -0,0 +1,74 @@ +import { ChangeEvent, useEffect, useState } from "react"; +import EvoInput from "../forms/EvoInput"; +import Input from "../forms/Input"; + +type EvoDropDownItem = { + name: string, + value: any +} + +interface SearchItemModalProps { + className?: string; + name?: string; + items: EvoDropDownItem[]; + initItem?: EvoDropDownItem; + onValueChange?: (item: EvoDropDownItem) => void; + onClose?: () => void +} + +export default function SearchItemModal ({ className, items, name, initItem, onClose, onValueChange }: SearchItemModalProps) { + const [filteredItems, setItems] = useState(items); + const [currentItem, setItem] = useState(initItem || items[0]); + + const [searchVal, setSearch] = useState(""); + + const handleSearch = (e: ChangeEvent) => { + setSearch(e.target.value); + } + + useEffect(() => { + if (searchVal.length > 0) { + const filter = items.filter(item => item.name.toLocaleLowerCase().includes(searchVal.toLowerCase())); + setItems(filter); + } + else { + setItems(items); + } + }, [searchVal]) + + return ( + + + + + + + {name} + + + + {filteredItems.map((item) => ( + { + setItem(item); + if (onValueChange) onValueChange(item)} + } + > + + {item.name} + + {currentItem.value == item.value && } + + ))} + + + + ) +} \ No newline at end of file