Files
lucent-laravel/front/js/svelte/records/block/BlockButtons.svelte
T

63 lines
1.6 KiB
Svelte
Raw Normal View History

2023-10-02 23:10:49 +03:00
<script>
import Icon from "../../common/Icon.svelte";
2023-10-14 18:06:36 +03:00
import {insertBlock} from "./block";
2023-10-02 23:10:49 +03:00
export let blockId;
export let blockData;
2023-10-14 18:06:36 +03:00
export let blockSchema;
2023-10-02 23:10:49 +03:00
$: showOptions = false;
2023-10-14 18:06:36 +03:00
let validUis = ["heading", "textarea", "rich", "reference"];
2023-10-02 23:10:49 +03:00
2023-10-14 18:06:36 +03:00
function createBlock(e, ui) {
2023-10-02 23:10:49 +03:00
e.preventDefault();
2023-10-14 18:06:36 +03:00
blockData = insertBlock(blockData,ui);
2023-10-02 23:10:49 +03:00
showOptions = false;
}
2023-10-14 18:06:36 +03:00
</script>
<div class="d-flex justify-content-left mb-2 ">
<button
type="button"
class:is-first={!blockId}
class=" btn btn-lg btn-link text-decoration-none block-buttons"
on:click|preventDefault={(e) => (showOptions = !showOptions)}
>
<Icon width={24} height={24} icon="circle-plus"/>
</button>
{#if showOptions}
<div class="d-flex ">
{#each blockSchema.fields as validUi}
<div class="ms-2">
<button
class="btn btn-sm btn-primary"
on:click={(e) => createBlock(e, validUi)}
>{validUi.label}
</button>
</div>
{/each}
</div>
{/if}
</div>
2023-10-02 23:10:49 +03:00
<style>
:global(.block-field-wrapper) {
display: flex;
flex-direction: column;
}
:global(.block-field-wrapper .block-buttons) {
visibility: hidden;
}
:global(.block-field-wrapper:hover .block-buttons) {
visibility: visible;
}
.block-buttons {
2023-10-14 18:06:36 +03:00
padding: 0px;
2023-10-02 23:10:49 +03:00
z-index: 1;
2023-10-14 18:06:36 +03:00
margin: 0px ;
2023-10-02 23:10:49 +03:00
}
</style>