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">
|
2021-04-26 15:34:33 +02:00
|
|
|
import * as tr from "lib/i18n";
|
2021-04-12 06:18:30 +02:00
|
|
|
import { revertIcon } from "./icons";
|
|
|
|
import { createEventDispatcher } from "svelte";
|
2021-04-25 11:05:19 +02:00
|
|
|
import { isEqual, cloneDeep } from "lodash-es";
|
2021-04-26 15:34:33 +02:00
|
|
|
// import { onMount } from "svelte";
|
|
|
|
// import Tooltip from "bootstrap/js/dist/tooltip";
|
|
|
|
|
|
|
|
let ref: HTMLDivElement;
|
|
|
|
|
|
|
|
// fixme: figure out why this breaks halfway down the page
|
|
|
|
// onMount(() => {
|
|
|
|
// new Tooltip(ref, {
|
|
|
|
// placement: "bottom",
|
|
|
|
// html: true,
|
|
|
|
// offset: [0, 20],
|
|
|
|
// });
|
|
|
|
// });
|
2021-04-12 06:18:30 +02:00
|
|
|
|
|
|
|
export let value: any;
|
|
|
|
export let defaultValue: any;
|
|
|
|
|
|
|
|
const dispatch = createEventDispatcher();
|
|
|
|
|
|
|
|
let modified: boolean;
|
2021-04-25 11:05:19 +02:00
|
|
|
$: modified = !isEqual(value, defaultValue);
|
2021-04-12 06:18:30 +02:00
|
|
|
|
|
|
|
/// This component can be used either with bind:value, or by listening
|
|
|
|
/// to the revert event.
|
|
|
|
function revert(): void {
|
2021-04-25 11:05:19 +02:00
|
|
|
value = cloneDeep(defaultValue);
|
2021-04-12 06:18:30 +02:00
|
|
|
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-26 15:34:33 +02:00
|
|
|
<div
|
|
|
|
class="img-div"
|
|
|
|
on:click={revert}
|
|
|
|
bind:this={ref}
|
|
|
|
title={tr.deckConfigRevertButtonTooltip()}>
|
2021-04-22 07:39:50 +02:00
|
|
|
{@html revertIcon}
|
|
|
|
</div>
|
2021-04-12 06:18:30 +02:00
|
|
|
{/if}
|