theming, menu fixes

This commit is contained in:
Jan Prochazka
2022-02-12 09:29:36 +01:00
parent 0c1640a75a
commit f11d3e134b
4 changed files with 19 additions and 11 deletions

View File

@@ -6,6 +6,7 @@
export let items;
let isOpened;
let openedLabel;
function handleOpenMenu(element, item) {
const rect = element.getBoundingClientRect();
@@ -14,11 +15,13 @@
const items = item.submenu;
$currentDropDownMenu = { left, top, items };
isOpened = true;
openedLabel = item.text || item.label;
}
$: preparedItems = prepareMenuItems(items, {}, $commandsCustomized);
$: if (!$currentDropDownMenu) {
isOpened = false;
openedLabel = null;
}
</script>
@@ -26,6 +29,7 @@
{#each preparedItems as item}
<div
class="item"
class:opened={openedLabel == (item.text || item.label)}
on:click={e => handleOpenMenu(e.target, item)}
on:mousemove={e => {
if (isOpened) {
@@ -62,4 +66,8 @@
.item:hover {
background: var(--theme-bg-3);
}
.item.opened {
background: var(--theme-bg-3);
}
</style>