Skip to content

Commit

Permalink
refactor: move the optional to check to AppLink
Browse files Browse the repository at this point in the history
  • Loading branch information
wa0x6e committed Nov 3, 2024
1 parent af1c22b commit f32d009
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
9 changes: 7 additions & 2 deletions apps/ui/src/components/AppLink.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
<script lang="ts" setup>
import { RouteLocationRaw, RouterLinkProps } from 'vue-router';
const props = defineProps<RouterLinkProps>();
const props = defineProps<
Omit<RouterLinkProps, 'to'> & { to?: RouteLocationRaw }
>();
const { isWhiteLabel } = useWhiteLabel();
Expand Down Expand Up @@ -32,7 +34,10 @@ function normalize(to: RouteLocationRaw) {
</script>

<template>
<router-link :to="normalize(props.to)">
<router-link v-if="props.to" :to="normalize(props.to)">
<slot />
</router-link>
<div v-else>
<slot />
</div>
</template>
6 changes: 2 additions & 4 deletions apps/ui/src/components/Ui/ProposalLabel.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<script setup lang="ts">
import { RouteLocationNamedRaw } from 'vue-router';
import AppLink from '../AppLink.vue';
const props = defineProps<{
label: string;
Expand Down Expand Up @@ -50,8 +49,7 @@ function checkColorProximity(color: string): {
</script>

<template>
<component
:is="to ? AppLink : 'div'"
<AppLink
:to="to"
class="rounded-full w-fit max-w-[220px] shrink-0 flex"
:class="{
Expand All @@ -66,5 +64,5 @@ function checkColorProximity(color: string): {
class="truncate text-sm leading-[11px] whitespace-nowrap px-2 py-[6px]"
v-text="label"
/>
</component>
</AppLink>
</template>

0 comments on commit f32d009

Please sign in to comment.