Skip to content

Commit

Permalink
refactor: move click listener to button in ContextMenu
Browse files Browse the repository at this point in the history
  • Loading branch information
simonwep committed May 3, 2024
1 parent 224f6bc commit b53eb29
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 11 deletions.
5 changes: 2 additions & 3 deletions src/app/components/base/context-menu/ContextMenu.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<template>
<!-- TODO: Forward click to slot -->
<div ref="reference" v-tooltip="{ text: tooltip, position: tooltipPosition }" :class="classes" @click="toggle">
<slot />
<div ref="reference" v-tooltip="{ text: tooltip, position: tooltipPosition }" :class="classes">
<slot :toggle="toggle" />
</div>
<div ref="popper" :class="[$style.popper, { [$style.visible]: visible }]">
<ul :class="listClasses">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@
<EChart ref="chart" :class="[$style.sankeyChart, classes]" :options="options" />

<ContextMenu v-if="chart" position="top-end" :class="$style.downloadMenu">
<button type="button" :class="$style.downloadBtn">
<RiDownloadCloud2Line size="18" />
</button>
<template #default="{ toggle }">
<button type="button" :class="$style.downloadBtn" @click="toggle">
<RiDownloadCloud2Line size="18" />
</button>
</template>

<template #options>
<ContextMenuButton :icon="RiLandscapeLine" :text="t('page.dashboard.downloadAsPNG')" @click="downloadPNG" />
Expand Down
4 changes: 3 additions & 1 deletion src/app/pages/navigation/admin/AdminButton.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
tooltip-position="right"
:class="classes"
>
<Button :icon="RiShieldFlashLine" textual color="dimmed" />
<template #default="{ toggle }">
<Button :icon="RiShieldFlashLine" textual color="dimmed" @click="toggle" />
</template>

<template #options>
<CreateUserButton />
Expand Down
4 changes: 3 additions & 1 deletion src/app/pages/navigation/currency/ChangeCurrencyButton.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
:options="currencies"
@select="changeCurrency($event.id as AvailableCurrency)"
>
<Button :class="classes" :icon="RiCurrencyLine" textual color="dimmed" />
<template #default="{ toggle }">
<Button :class="classes" :icon="RiCurrencyLine" textual color="dimmed" @click="toggle" />
</template>
</ContextMenu>
</template>

Expand Down
4 changes: 3 additions & 1 deletion src/app/pages/navigation/language/ChangeLanguageButton.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
:options="locales"
@select="changeLocale($event.id as AvailableLocale)"
>
<Button :class="classes" :icon="RiGlobalLine" textual color="dimmed" />
<template #default="{ toggle }">
<Button :class="classes" :icon="RiGlobalLine" textual color="dimmed" @click="toggle" />
</template>
</ContextMenu>
</template>

Expand Down
4 changes: 3 additions & 1 deletion src/app/pages/navigation/tools/ToolsButton.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
:position="media === 'mobile' ? 'top' : 'right-end'"
tooltip-position="right"
>
<Button :class="classes" :icon="RiToolsLine" textual color="dimmed"></Button>
<template #default="{ toggle }">
<Button :class="classes" :icon="RiToolsLine" textual color="dimmed" @click="toggle"></Button>
</template>

<template #options>
<LoadDemoDataButton v-if="status === 'idle'" />
Expand Down
4 changes: 3 additions & 1 deletion src/app/pages/navigation/year/ChangeYearButton.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
:highlight="state.activeYear"
@select="changeYear($event.id as number)"
>
<Button :class="classes" :icon="RiCalendarLine" textual color="dimmed" />
<template #default="{ toggle }">
<Button :class="classes" :icon="RiCalendarLine" textual color="dimmed" @click="toggle" />
</template>
</ContextMenu>
</template>

Expand Down

0 comments on commit b53eb29

Please sign in to comment.