From 88ca2d2ac44b200772b49df27aa7205f07318878 Mon Sep 17 00:00:00 2001 From: cv <34649812+cpvalente@users.noreply.github.com> Date: Wed, 31 Mar 2021 14:06:49 +0200 Subject: [PATCH] event menu is component --- src/features/editors/list/EventList.jsx | 79 ++++------------------ src/features/editors/list/List.module.css | 17 ++--- src/features/menu/EventListMenu.jsx | 54 +++++++++++++++ src/features/menu/EventListMenu.module.css | 6 ++ 4 files changed, 81 insertions(+), 75 deletions(-) create mode 100644 src/features/menu/EventListMenu.jsx create mode 100644 src/features/menu/EventListMenu.module.css diff --git a/src/features/editors/list/EventList.jsx b/src/features/editors/list/EventList.jsx index 334490540..0b0426b9e 100644 --- a/src/features/editors/list/EventList.jsx +++ b/src/features/editors/list/EventList.jsx @@ -1,31 +1,22 @@ -import { - AddIcon, - AttachmentIcon, - ChevronDownIcon, - DownloadIcon, -} from '@chakra-ui/icons'; -import { - Button, - ButtonGroup, - IconButton, - Menu, - MenuButton, - MenuItem, - MenuList, -} from '@chakra-ui/react'; -import { useContext } from 'react'; +import { useContext, useEffect } from 'react'; import { EventContext } from '../../../app/context/eventContext'; import { EventListContext } from '../../../app/context/eventListContext'; import EventListItem from './EventListItem'; import style from './List.module.css'; import DelayBlock from './DelayBlock'; import BlockBlock from './BlockBlock'; +import EventListMenu from '../../menu/EventListMenu'; -export default function EventList() { + +export default function EventList(props) { const [events, setEvents] = useContext(EventListContext); const [event] = useContext(EventContext); - const selected = event?.id || -1; + // update number of events + useEffect(() => { + const f = events.filter((e) => e.type === 'event'); + props.updatePlayback({ numEvents: f.length }); + }, [events]); const insertItemAt = (item, index) => { // handle insert at beggining of array @@ -116,63 +107,21 @@ export default function EventList() { console.log('events in event list', events); let cumulativeDelay = 0; + let eventCount = -1; + return ( <> -
- - - - } - size='sm' - variant='outline' - > - - - - - Upload Excel - Upload CSV - - - - - - } - size='sm' - variant='outline' - > - - - - - Download Excel - Download CSV - - - } - colorScheme='blue' - onClick={() => createEvent()} - /> -
+
{events.map((e, index) => { if (e.type === 'event') { + eventCount = eventCount + 1; return ( + + + + + + + + + Upload Excel + Upload CSV + + + + + + + + + + + Download Excel + Download CSV + + + } + colorScheme='blue' + onClick={() => props.createEvent()} + /> +
+ ); +} diff --git a/src/features/menu/EventListMenu.module.css b/src/features/menu/EventListMenu.module.css new file mode 100644 index 000000000..608188698 --- /dev/null +++ b/src/features/menu/EventListMenu.module.css @@ -0,0 +1,6 @@ +.headerButtons { + display: flex; + gap: 0.5em; + align-content: center; + justify-content: flex-end; +} \ No newline at end of file