From c064f08d557052dc36a03ec6c761d2e993413e7b Mon Sep 17 00:00:00 2001 From: Martin McKeaveney Date: Wed, 29 Jan 2020 22:59:10 +0000 Subject: [PATCH] started implementing state management designs --- .../builder/src/common/Icons/Events.svelte | 3 +- packages/builder/src/common/Select.svelte | 54 +++++++++ .../EventsEditor/EventEditorModal.svelte | 104 +++++++++++++----- .../EventsEditor/EventsEditor.svelte | 91 ++------------- .../EventsEditor/HandlerSelector.svelte | 41 ++++--- 5 files changed, 165 insertions(+), 128 deletions(-) create mode 100644 packages/builder/src/common/Select.svelte diff --git a/packages/builder/src/common/Icons/Events.svelte b/packages/builder/src/common/Icons/Events.svelte index d3728b9901..b7d92481e3 100644 --- a/packages/builder/src/common/Icons/Events.svelte +++ b/packages/builder/src/common/Icons/Events.svelte @@ -4,5 +4,6 @@ width="24" height="24"> - + diff --git a/packages/builder/src/common/Select.svelte b/packages/builder/src/common/Select.svelte new file mode 100644 index 0000000000..9053803ca7 --- /dev/null +++ b/packages/builder/src/common/Select.svelte @@ -0,0 +1,54 @@ + + + + +
+ + + {@html getIcon('chevron-down', '24')} + +
diff --git a/packages/builder/src/userInterface/EventsEditor/EventEditorModal.svelte b/packages/builder/src/userInterface/EventsEditor/EventEditorModal.svelte index 6cb72f6310..3fa7ab44f9 100644 --- a/packages/builder/src/userInterface/EventsEditor/EventEditorModal.svelte +++ b/packages/builder/src/userInterface/EventsEditor/EventEditorModal.svelte @@ -1,49 +1,95 @@ - -

{action} Event

- -
- - .prop-container { - flex: 1 1 auto; - min-width: 250px; - } - - .edit-icon:hover { - cursor: pointer; - } - \ No newline at end of file + + {#if event} +

{event.name}

+ {:else} +

Create a New Component Event

+ {/if} + Click here to learn more about component events + +
+
+
Event Name
+ +
+ +
+
Event Type
+ +
+
+ +
Event Action(s)
+ {#if event.handlers} + {#each event.handlers as handler, index} + removeEventHandler(index)} + {handler} /> +
+ {/each} + {/if} +
addEventHandler(newEventType)}> + + Add Handler +
+
diff --git a/packages/builder/src/userInterface/EventsEditor/EventsEditor.svelte b/packages/builder/src/userInterface/EventsEditor/EventsEditor.svelte index fa21f2c56a..2947ca1b42 100644 --- a/packages/builder/src/userInterface/EventsEditor/EventsEditor.svelte +++ b/packages/builder/src/userInterface/EventsEditor/EventsEditor.svelte @@ -17,6 +17,7 @@ import PlusButton from "../../common/PlusButton.svelte"; import IconButton from "../../common/IconButton.svelte"; import Modal from "../../common/Modal.svelte"; + import EventEditorModal from "./EventEditorModal.svelte"; import HandlerSelector from "./HandlerSelector.svelte"; import { PencilIcon } from "../../common/Icons"; @@ -28,12 +29,6 @@ export let onPropChanged = () => {}; export let components; - // Structure - // { - // [eventName]: [{eventHandler}, {eventHandler1}], - // [eventName1]: [{eventHandler}, {eventHandler1}], - // } - let modalOpen = false; let events = []; let selectedEvent = {}; @@ -41,15 +36,6 @@ // TODO: only show events that have handlers - // $: { - // let componentEvents = {}; - // for (let propName in componentInfo) { - // const isEventProp = findType(propName) === EVENT_TYPE; - // if (isEventProp) componentEvents[propName] = componentInfo[propName]; - // } - // events = componentEvents; - // } - $: events = componentInfo && Object.entries(componentInfo).filter( @@ -64,8 +50,6 @@ .props[propName]; } - console.log({ componentInfo, events, components }); - const openModal = event => { selectedEvent = event; modalOpen = true; @@ -111,8 +95,6 @@ handlers.splice(index, 1); onPropChanged(newEventType, handlers); }; - - console.log("DA HANDLERS", selectedEvent.handlers);
@@ -210,7 +165,7 @@ {#each events as [name, handlers], index} {#if handlers.length > 0}
openModal({ name, handlers, index })}> {name} EDIT @@ -220,37 +175,11 @@ {/each}
- -

Create a New Component Event

- Click here to learn more about component events - -

Event Name

- - -

Event Type

- - -

Event Action(s)

- {#if selectedEvent.handlers} - {#each selectedEvent.handlers as handler, index} - -
- {/each} - {/if} -
addEventHandler(newEventType)}> - - Add Handler -
-
+ diff --git a/packages/builder/src/userInterface/EventsEditor/HandlerSelector.svelte b/packages/builder/src/userInterface/EventsEditor/HandlerSelector.svelte index dffcb06278..9c30efb266 100644 --- a/packages/builder/src/userInterface/EventsEditor/HandlerSelector.svelte +++ b/packages/builder/src/userInterface/EventsEditor/HandlerSelector.svelte @@ -1,5 +1,6 @@