From 48b7ae3cd0365a9e318199cb058eaebc94a4e60a Mon Sep 17 00:00:00 2001 From: Henrik Giesel Date: Mon, 21 Jun 2021 19:11:10 +0200 Subject: [PATCH] Revert button with gear icon, that shows revert dropdown item --- ts/components/WithDropdownMenu.svelte | 10 +++---- ts/deckoptions/BUILD.bazel | 1 + ts/deckoptions/Badge.svelte | 1 - ts/deckoptions/RevertButton.svelte | 39 +++++++++++---------------- ts/deckoptions/SaveButton.svelte | 5 +++- ts/deckoptions/TooltipLabel.svelte | 4 ++- ts/deckoptions/icons.ts | 7 +++-- ts/sass/base.scss | 13 +++++++++ 8 files changed, 44 insertions(+), 36 deletions(-) diff --git a/ts/components/WithDropdownMenu.svelte b/ts/components/WithDropdownMenu.svelte index 068942b2b..c4b977fdc 100644 --- a/ts/components/WithDropdownMenu.svelte +++ b/ts/components/WithDropdownMenu.svelte @@ -23,20 +23,18 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html /* Normally dropdown and trigger are associated with a /* common ancestor with .dropdown class */ - function createDropdown(event: CustomEvent): void { - const button: HTMLButtonElement = event.detail.button; - + function createDropdown(element: HTMLElement): void { /* Prevent focus on menu activation */ const noop = () => {}; - Object.defineProperty(button, "focus", { value: noop }); + Object.defineProperty(element, "focus", { value: noop }); - const menu = (button.getRootNode() as Document) /* or shadow root */ + const menu = (element.getRootNode() as Document) /* or shadow root */ .getElementById(menuId); if (!menu) { console.log(`Could not find menu "${menuId}" for dropdown menu.`); } else { - dropdown = new Dropdown(button); + dropdown = new Dropdown(element); /* Set custom menu without using common element with .dropdown */ (dropdown as any)._menu = menu; diff --git a/ts/deckoptions/BUILD.bazel b/ts/deckoptions/BUILD.bazel index cb6d275fb..d88bd91a3 100644 --- a/ts/deckoptions/BUILD.bazel +++ b/ts/deckoptions/BUILD.bazel @@ -38,6 +38,7 @@ copy_bootstrap_icons( icons = [ "arrow-counterclockwise.svg", "info-circle.svg", + "gear.svg", ], ) diff --git a/ts/deckoptions/Badge.svelte b/ts/deckoptions/Badge.svelte index 720a4d880..2cc765bdd 100644 --- a/ts/deckoptions/Badge.svelte +++ b/ts/deckoptions/Badge.svelte @@ -28,6 +28,5 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html span :global(svg) { vertical-align: -0.125rem; - opacity: 0.3; } diff --git a/ts/deckoptions/RevertButton.svelte b/ts/deckoptions/RevertButton.svelte index 66b50df6f..aabfe2518 100644 --- a/ts/deckoptions/RevertButton.svelte +++ b/ts/deckoptions/RevertButton.svelte @@ -4,11 +4,11 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html --> - - {#if touchDevice} - {@html revertIcon} - {:else} - - createTooltip(event.detail.span)} - on:click={revert}>{@html revertIcon} - - {/if} - + + createDropdown(event.detail.span)}> + {@html gearIcon} + + + + + {tr.deckConfigRevertButtonTooltip()}{@html revertIcon} + + + diff --git a/ts/deckoptions/SaveButton.svelte b/ts/deckoptions/SaveButton.svelte index 945043dbc..52cda318b 100644 --- a/ts/deckoptions/SaveButton.svelte +++ b/ts/deckoptions/SaveButton.svelte @@ -69,7 +69,10 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html - + createDropdown(event.detail.button)} + on:click={activateDropdown} + /> dispatch("add")} >{tr.deckConfigAddGroup()} createTooltip(event.detail.span)} + > createTooltip(event.detail.span)} >{@html infoCircle}