Skip to content

Commit

Permalink
refactor: simplify ButtonLink.vue
Browse files Browse the repository at this point in the history
Seems to cover what we want by default according to
https://nuxt.com/docs/api/components/nuxt-link#nuxtlink
  • Loading branch information
kelsos committed Nov 25, 2024
1 parent fd6484b commit 965ebf9
Showing 1 changed file with 15 additions and 23 deletions.
38 changes: 15 additions & 23 deletions components/common/ButtonLink.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,29 +6,23 @@ defineOptions({
inheritAttrs: false,
});
const props = withDefaults(
defineProps<{
to: RouteLocationRaw;
external?: boolean;
inline?: boolean;
highlightActive?: boolean;
highlightExactActive?: boolean;
}>(),
{
external: false,
inline: false,
highlightActive: false,
highlightExactActive: false,
},
);
const props = withDefaults(defineProps<{
to: RouteLocationRaw;
external?: boolean;
inline?: boolean;
highlightActive?: boolean;
highlightExactActive?: boolean;
}>(), {
external: false,
inline: false,
highlightActive: false,
highlightExactActive: false,
});
const { highlightActive, highlightExactActive } = toRefs(props);
function getColor(active: boolean, exact: boolean) {
if (
(get(highlightActive) && active)
|| (get(highlightExactActive) && exact)
) {
if ((get(highlightActive) && active) || (get(highlightExactActive) && exact)) {
return 'primary';
}
Expand All @@ -40,10 +34,8 @@ function getColor(active: boolean, exact: boolean) {
<NuxtLink
#default="link"
:class="{ 'inline-flex': inline }"
:href="external ? to : undefined"
:to="external ? undefined : to"
:target="external ? '_blank' : '_self'"
:rel="external ? 'noreferrer' : null"
:to="to"
:external="external"
>
<RuiButton
v-bind="{
Expand Down

0 comments on commit 965ebf9

Please sign in to comment.