Skip to content

Commit 35dc6c6

Browse files
committed
feat: add similarity view
1 parent 1f62550 commit 35dc6c6

File tree

4 files changed

+87
-16
lines changed

4 files changed

+87
-16
lines changed

app/components/GitHubIssue.vue

+15-3
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ defineProps({
1515
type: Number,
1616
required: true,
1717
},
18-
labels: Array as () => Array<string | { name: string, color: string }>,
18+
labels: Array as () => Array<string | { name: string, color?: string }>,
1919
// eslint-disable-next-line vue/prop-name-casing
2020
updated_at: {
2121
type: String,
@@ -47,7 +47,7 @@ function labelColors(color: string) {
4747
:href="url"
4848
target="_blank"
4949
>
50-
{{ title }}
50+
{{ title?.trim() }}
5151
</NuxtLink>
5252
<div
5353
class="text-xs relative md:absolute md:mt-6 text-gray-400 mb-1"
@@ -72,7 +72,19 @@ function labelColors(color: string) {
7272
relative
7373
/>
7474
&middot;
75-
{{ Math.floor(avgSimilarity * 100) }}% similar
75+
<NuxtLink
76+
class="no-underline hover:underline color-current"
77+
:to="owner && repository ? {
78+
name: 'owner-repo-issue',
79+
params: {
80+
owner: owner,
81+
repo: repository,
82+
issue: number,
83+
},
84+
} : ''"
85+
>
86+
{{ Math.floor(avgSimilarity * 100) }}% similar
87+
</NuxtLink>
7688
</div>
7789
<div class="flex flex-row gap-1 items-baseline flex-wrap md:flex-nowrap">
7890
<span

app/components/GitHubIssueLoading.vue

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<template>
2+
<article>
3+
<div class="flex flex-row gap-2 leading-tightest no-underline color-current">
4+
<div class="flex-shrink-0 text-gray-500 i-tabler-circle-dot inline-block w-5 h-5" />
5+
<div class="rounded-full h-4 bg-gray-500 w-70" />
6+
</div>
7+
</article>
8+
</template>

app/pages/[owner]/[repo]/[issue].vue

+55
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
<script setup lang="ts">
2+
const route = useRoute('owner-repo-issue')
3+
const { data: issues, status } = useFetch(`/api/similarity/${route.params.owner}/${route.params.repo}/${route.params.issue}`, {
4+
baseURL: useRuntimeConfig().public.remote,
5+
default: () => [],
6+
transform: data => data.filter((i): i is NonNullable<typeof i> => !!(i && i.url)),
7+
})
8+
</script>
9+
10+
<template>
11+
<div>
12+
<section
13+
v-if="status === 'pending' || status === 'idle'"
14+
class="flex flex-col gap-4 md:rounded-md md:border-solid border border-gray-700 md:px-4 pb-8 mt-6 columns-1 lg:columns-2 border-b-solid animate-pulse"
15+
:style="{ '--section-index': 1 }"
16+
>
17+
<h2 class="flex items-center">
18+
<span class="text-gray-500 inline-block mr-1 font-normal">#</span>
19+
<span class="inline-block rounded-md h-5 bg-gray-500 w-5" />
20+
</h2>
21+
<GitHubIssueLoading
22+
v-for="s in Math.round(Math.random() * 4) + 1"
23+
:key="s"
24+
/>
25+
</section>
26+
<section
27+
v-else
28+
class="flex flex-col gap-4 md:rounded-md md:border-solid border border-gray-700 md:px-4 pb-8 mt-6 columns-1 lg:columns-2 border-b-solid"
29+
:style="{ '--section-index': 1 }"
30+
>
31+
<h2 class="flex items-center">
32+
<span class="text-gray-500 inline-block mr-1 font-normal">#</span>
33+
{{ issues[0]?.title }}
34+
</h2>
35+
<GitHubIssue
36+
v-for="issue in issues"
37+
:key="issue.url"
38+
:url="issue.url"
39+
:title="issue.title"
40+
:owner="issue.owner"
41+
:repository="issue.repository"
42+
:number="issue.number"
43+
:avg-similarity="1 - issue.score"
44+
:labels="issue.labels"
45+
:updated_at="issue.updated_at"
46+
/>
47+
</section>
48+
</div>
49+
</template>
50+
51+
<style scoped>
52+
section:first-of-type {
53+
view-transition-name: var(--section-index);
54+
}
55+
</style>

app/pages/[owner]/[repo]/index.vue

+9-13
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,10 @@ const openState = reactive<Record<string, boolean>>({})
3434
<template>
3535
<div>
3636
<form @submit.prevent="() => refresh()">
37-
<p class="flex gap-2 items-center">
38-
{{ selectedRepo }}
37+
<div class="flex gap-2 items-center">
38+
<h2 class="text-base font-normal">
39+
{{ selectedRepo }}
40+
</h2>
3941
<button
4042
class="rounded-full w-7 h-7 flex items-center justify-center border-solid border border-gray-700 bg-transparent color-gray-400 hover:color-gray-200 active:color-white focus:color-gray-200 hover:border-gray-400 active:border-white focus:border-gray-400 transition-colors flex-shrink-0"
4143
:class="{ 'animate-spin opacity-50 pointer-events-none': status === 'pending' || status === 'idle' }"
@@ -47,7 +49,7 @@ const openState = reactive<Record<string, boolean>>({})
4749
/>
4850
<span class="sr-only">refresh data</span>
4951
</button>
50-
</p>
52+
</div>
5153
<label class="w-full border-solid border border-gray-600 rounded-md flex flex-row items-center relative">
5254
<span class="sr-only">pick a repository to cluster issues</span>
5355
<select
@@ -79,16 +81,10 @@ const openState = reactive<Record<string, boolean>>({})
7981
<span class="text-gray-500 inline-block mr-1 font-normal">#</span>
8082
<span class="inline-block rounded-md h-5 bg-gray-500 w-5" />
8183
</h2>
82-
<article>
83-
<div
84-
class="flex flex-row gap-2 leading-tightest no-underline color-current"
85-
>
86-
<span
87-
class="flex-shrink-0 text-gray-500 i-tabler-circle-dot inline-block w-5 h-5"
88-
/>
89-
<div class="rounded-full h-4 bg-gray-500 w-70" />
90-
</div>
91-
</article>
84+
<GitHubIssueLoading
85+
v-for="s in Math.round(Math.random() * 3) + 1"
86+
:key="s"
87+
/>
9288
</section>
9389
</template>
9490
<template v-else-if="!clusters.length">

0 commit comments

Comments
 (0)