2021-04-12 06:18:30 +02:00
|
|
|
<!--
|
|
|
|
Copyright: Ankitects Pty Ltd and contributors
|
|
|
|
License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
|
|
|
-->
|
|
|
|
<script lang="ts">
|
|
|
|
import { revertIcon } from "./icons";
|
|
|
|
import { createEventDispatcher } from "svelte";
|
|
|
|
|
|
|
|
export let value: any;
|
|
|
|
export let defaultValue: any;
|
|
|
|
|
|
|
|
const dispatch = createEventDispatcher();
|
|
|
|
|
|
|
|
let modified: boolean;
|
|
|
|
$: modified = JSON.stringify(value) !== JSON.stringify(defaultValue);
|
|
|
|
|
|
|
|
/// This component can be used either with bind:value, or by listening
|
|
|
|
/// to the revert event.
|
|
|
|
function revert(): void {
|
|
|
|
value = JSON.parse(JSON.stringify(defaultValue));
|
|
|
|
dispatch("revert", { value });
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
2021-04-22 10:11:27 +02:00
|
|
|
<style lang="scss">
|
2021-04-22 07:39:50 +02:00
|
|
|
.img-div {
|
|
|
|
display: flex;
|
2021-04-22 10:11:27 +02:00
|
|
|
|
|
|
|
:global(svg) {
|
|
|
|
align-self: center;
|
|
|
|
opacity: 0.3;
|
|
|
|
}
|
2021-04-12 06:18:30 +02:00
|
|
|
}
|
|
|
|
</style>
|
|
|
|
|
|
|
|
{#if modified}
|
2021-04-22 07:39:50 +02:00
|
|
|
<div class="img-div" on:click={revert}>
|
|
|
|
{@html revertIcon}
|
|
|
|
</div>
|
2021-04-12 06:18:30 +02:00
|
|
|
{/if}
|