Skip to content
This repository has been archived by the owner on Aug 28, 2024. It is now read-only.

Add link support to overflow menus #148

Merged
merged 3 commits into from
Nov 16, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion docs/components/overflow-menu.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
},
{
'id': 'report',
'action': () => {}
'link': 'https://example.com/report',
'external': true,
},
{
'id': 'remain',
Expand Down
3 changes: 1 addition & 2 deletions lib/assets/styles/classes.scss
Original file line number Diff line number Diff line change
Expand Up @@ -447,11 +447,10 @@ a,
height: 1.25rem;
}

:deep(.external-icon) {
.external-icon {
width: 0.75rem;
height: 0.75rem;
margin-bottom: auto;
margin-left: 0.25rem;
margin-right: 0;
}

Expand Down
31 changes: 30 additions & 1 deletion lib/components/base/Button.vue
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ const accentedButton = computed(() =>

<template>
<router-link
v-if="link"
v-if="link && link.startsWith('/')"
class="btn"
:class="{
'icon-only': iconOnly,
Expand Down Expand Up @@ -81,6 +81,35 @@ const accentedButton = computed(() =>
<ExternalIcon v-if="external && !iconOnly" class="external-icon" />
<UnknownIcon v-if="!$slots.default" />
</router-link>
<a
v-else-if="link"
class="btn"
:class="{
'icon-only': iconOnly,
'btn-large': large,
'btn-danger': color === 'danger',
'btn-primary': color === 'primary',
'btn-secondary': color === 'secondary',
'btn-highlight': color === 'highlight',
'btn-red': color === 'red',
'btn-orange': color === 'orange',
'btn-green': color === 'green',
'btn-blue': color === 'blue',
'btn-purple': color === 'purple',
'btn-gray': color === 'gray',
'btn-transparent': transparent,
'btn-hover-filled': hoverFilled,
'btn-hover-filled-only': hoverFilledOnly,
'btn-outline': outline,
'color-accent-contrast': accentedButton,
}"
:href="link"
:target="external ? '_blank' : '_self'"
>
<slot />
<ExternalIcon v-if="external && !iconOnly" class="external-icon" />
<UnknownIcon v-if="!$slots.default" />
</a>
<button
v-else
class="btn"
Expand Down
15 changes: 13 additions & 2 deletions lib/components/base/OverflowMenu.vue
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,20 @@
:hover-filled-only="option.hoverFilledOnly"
transparent
:action="
option.action
? () => {
option.action()
if (!option.remainOnClick) {
close()
}
}
: null
"
:link="option.link ? option.link : null"
:external="option.external ? option.external : false"
@click="
() => {
option.action()
if (!option.remainOnClick) {
if (option.link && !option.remainOnClick) {
close()
}
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "omorphia",
"type": "module",
"version": "0.6.8",
"version": "0.6.9",
"files": [
"dist",
"locales"
Expand Down