diff options
author | jakob.stendahl <jakob.stendahl@infomedia.dk> | 2022-12-04 13:33:45 +0100 |
---|---|---|
committer | Jakob Stendahl <jakob.stendahl@outlook.com> | 2022-12-04 13:34:22 +0100 |
commit | c3b4742eeceee9250f8059972dd150f38e2eb021 (patch) | |
tree | edde9ea65b554ff345788a916f238aed4a772b35 /src_frontend/ComponentLib/Button | |
parent | c5dc2dfb92e4a6584d1e727bc39b8c9578f85b57 (diff) | |
download | Luxcena-Neo-c3b4742eeceee9250f8059972dd150f38e2eb021.tar.gz Luxcena-Neo-c3b4742eeceee9250f8059972dd150f38e2eb021.zip |
Fix simulation stuttering (still resource intensive) and some oter QOL upgrades
Diffstat (limited to 'src_frontend/ComponentLib/Button')
-rw-r--r-- | src_frontend/ComponentLib/Button/EditorActionButton.svelte | 82 |
1 files changed, 82 insertions, 0 deletions
diff --git a/src_frontend/ComponentLib/Button/EditorActionButton.svelte b/src_frontend/ComponentLib/Button/EditorActionButton.svelte new file mode 100644 index 0000000..148720c --- /dev/null +++ b/src_frontend/ComponentLib/Button/EditorActionButton.svelte @@ -0,0 +1,82 @@ +<script> + export let faIcon = false; + export let fullWidth = false; + export let backgroundColor = "#444242"; + export let color = "white"; + + export let loadingPromise = null; + $: listen(loadingPromise); + function listen(promise) { + if (promise != null) { + loading = true; + promise.then(res => { + loading = false; + success = true; + }).catch(err => { + loading = false; + success = false; + }); + } else { + loading = false; + } + } + let loading; + let success; +</script> + +<style> + button { + background: #444242; + color: var(--color); + border: none; + text-decoration: none; + /*padding: 5px 15px;*/ + /*font-size: 15px;*/ + + transition: background-color, color 0.1s ease; + border-radius: 15px; + } + button:hover { + filter: brightness(0.95); + } + button:active { + filter: brightness(0.90); + } + .fullWidth { + width: 100%; + } + .iconButton { + display: flex; + } + .iconButton .text { + margin: auto; + } + .active { + background-color: var(--active-bg-color); + color: var(--active-color); + } + i { + } +</style> + +<button + on:click + class:fullWidth={fullWidth} + class:iconButton={faIcon != false} + style="--bg-color: {backgroundColor}; + --color: {color};"> + + {#if faIcon} + <div class="icon"> + <i class={faIcon}></i> + </div> + {/if} + + {#if loading} + <i class="fas fa-spinner fa-pulse"></i> + {:else} + <div class="text"> + <slot></slot> + </div> + {/if} +</button> |