final touches for design

This commit is contained in:
Martin McKeaveney 2020-01-31 09:45:02 +00:00
parent 96c61a5a7d
commit 8d656596c7
4 changed files with 97 additions and 62 deletions

View File

@ -1,12 +1,23 @@
<script> <script>
export let visible = true;
export let disabled = false; export let disabled = false;
export let hidden = false;
export let primary = true;
export let alert = false;
export let warning = false;
</script> </script>
<style> <style>
.action-button { .primary {
color: #0055ff; color: #0055ff;
background: rgb(54, 133, 249, 0.1); background: rgb(54, 133, 249, 0.1);
}
.alert {
color: rgba(255, 0, 31, 1);
background: rgba(255, 0, 31, 0.1);;
}
.button {
font-size: 18px; font-size: 18px;
font-weight: bold; font-weight: bold;
border-radius: 5px; border-radius: 5px;
@ -15,11 +26,11 @@
height: 64px; height: 64px;
} }
.action-button:hover { .button:hover {
cursor: pointer; cursor: pointer;
} }
.action-button:disabled { .button:disabled {
color: rgba(22, 48, 87, 0.2); color: rgba(22, 48, 87, 0.2);
cursor: default; cursor: default;
background: transparent; background: transparent;
@ -30,6 +41,13 @@
} }
</style> </style>
<button on:click class="action-button {!visible && 'hidden'}" {disabled}> <button
on:click
class="button"
class:hidden
class:primary
class:alert
class:warning
{disabled}>
<slot /> <slot />
</button> </button>

View File

@ -22,22 +22,23 @@ $: {
} }
} }
} }
</script> </script>
<style>
.uk-modal-dialog {
border-radius: 0.3rem;
width: 60%;
height: 80vh;
display: flex;
flex-direction: column;
}
</style>
<div bind:this={ukModal} uk-modal {id}> <div bind:this={ukModal} uk-modal {id}>
<div class="uk-modal-dialog uk-modal-body" uk-overflow-auto> <div class="uk-modal-dialog uk-modal-body" uk-overflow-auto>
{#if onClosed}
<button class="uk-modal-close-default" type="button" uk-close />
{/if}
<slot /> <slot />
</div> </div>
</div> </div>
<style>
.uk-modal-dialog {
border-radius: .3rem;
width: 60%;
height: 80vh;
}
</style>

View File

@ -17,21 +17,22 @@
export let onPropChanged; export let onPropChanged;
let eventType = "onClick"; let eventType = "onClick";
let newEventHandler = { parameters: [] }; let draftEventHandler = { parameters: [] };
$: eventData = event || { handlers: [] }; $: eventData = event || { handlers: [] };
const resetModalState = () => { const closeModal = () => {
newEventHandler = { parameters: [] }; onClose();
draftEventHandler = { parameters: [] };
eventData = { handlers: [] }; eventData = { handlers: [] };
}; };
const changeEventHandler = (updatedHandler, index) => { const updateEventHandler = (updatedHandler, index) => {
eventData.handlers[index] = updatedHandler; eventData.handlers[index] = updatedHandler;
}; };
const changeNewEventHandler = updatedHandler => { const updateDraftEventHandler = updatedHandler => {
newEventHandler = updatedHandler; draftEventHandler = updatedHandler;
}; };
const deleteEventHandler = index => { const deleteEventHandler = index => {
@ -50,14 +51,12 @@
const deleteEvent = () => { const deleteEvent = () => {
onPropChanged(eventType, []); onPropChanged(eventType, []);
resetModalState(); closeModal();
onClose();
}; };
const saveEventData = () => { const saveEventData = () => {
onPropChanged(eventType, eventData.handlers); onPropChanged(eventType, eventData.handlers);
resetModalState(); closeModal();
onClose();
}; };
</script> </script>
@ -72,8 +71,7 @@
h5 { h5 {
color: rgba(22, 48, 87, 0.6); color: rgba(22, 48, 87, 0.6);
font-size: 15px; font-size: 15px;
margin-bottom: 5px; margin: 0;
margin-top: 20px;
} }
.event-options { .event-options {
@ -82,12 +80,22 @@
grid-gap: 10px; grid-gap: 10px;
} }
.actions, header { .actions,
header {
display: flex; display: flex;
justify-content: space-between; justify-content: space-between;
align-items: center; align-items: center;
} }
.actions {
margin-top: auto;
}
header {
margin-top: 30px;
margin-bottom: 10px;
}
a { a {
color: rgba(22, 48, 87, 0.6); color: rgba(22, 48, 87, 0.6);
font-size: 12px; font-size: 12px;
@ -95,15 +103,19 @@
} }
</style> </style>
<Modal bind:isOpen={open} onClosed={onClose}> <Modal bind:isOpen={open} onClosed={closeModal}>
<h2>{eventData.name ? `${eventData.name} Event` : 'Create a New Component Event'}</h2> <h2>
<a href="https://docs.budibase.com/" target="_blank" >Click here to learn more about component events</a> {eventData.name ? `${eventData.name} Event` : 'Create a New Component Event'}
</h2>
<a href="https://docs.budibase.com/" target="_blank">
Click here to learn more about component events
</a>
<div class="event-options"> <div class="event-options">
<div> <div>
<header> <header>
<h5>Event Type</h5> <h5>Event Type</h5>
{@html getIcon('info')} {@html getIcon('info', 20)}
</header> </header>
<Select :value={eventType}> <Select :value={eventType}>
{#each eventOptions as option} {#each eventOptions as option}
@ -113,20 +125,23 @@
</div> </div>
</div> </div>
<header>
<h5>Event Action(s)</h5> <h5>Event Action(s)</h5>
{@html getIcon('info', 20)}
</header>
<HandlerSelector <HandlerSelector
newHandler newHandler
onChanged={changeNewEventHandler} onChanged={updateDraftEventHandler}
onCreate={() => { onCreate={() => {
createNewEventHandler(newEventHandler); createNewEventHandler(draftEventHandler);
newEventHandler = { parameters: [] }; draftEventHandler = { parameters: [] };
}} }}
handler={newEventHandler} /> handler={draftEventHandler} />
{#if eventData} {#if eventData}
{#each eventData.handlers as handler, index} {#each eventData.handlers as handler, index}
<HandlerSelector <HandlerSelector
{index} {index}
onChanged={changeEventHandler} onChanged={updateEventHandler}
onRemoved={() => deleteEventHandler(index)} onRemoved={() => deleteEventHandler(index)}
{handler} /> {handler} />
{/each} {/each}
@ -134,8 +149,9 @@
<div class="actions"> <div class="actions">
<ActionButton <ActionButton
alert
disabled={eventData.handlers.length === 0} disabled={eventData.handlers.length === 0}
visible={eventData.name} hidden={!eventData.name}
on:click={deleteEvent}> on:click={deleteEvent}>
Delete Delete
</ActionButton> </ActionButton>

View File

@ -75,7 +75,7 @@
flex-wrap: wrap; flex-wrap: wrap;
} }
.heading { header {
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: space-between; justify-content: space-between;
@ -124,10 +124,10 @@
} }
</style> </style>
<div class="heading"> <header>
<h3>Events</h3> <h3>Events</h3>
<PlusButton on:click={() => openModal()} /> <PlusButton on:click={() => openModal()} />
</div> </header>
<div class="root"> <div class="root">
<form class="uk-form-stacked form-root"> <form class="uk-form-stacked form-root">