|
4 | 4 | import semver from "semver"; |
5 | 5 | import MarkdownRenderer from "$lib/components/MarkdownRenderer.svelte"; |
6 | 6 | import type { GitHubRelease } from "$lib/server/github-cache"; |
| 7 | + import type { Entries } from "$lib/types"; |
7 | 8 | import { Badge } from "$lib/components/ui/badge"; |
8 | 9 | import { Button } from "$lib/components/ui/button"; |
9 | 10 | import * as Accordion from "$lib/components/ui/accordion"; |
|
87 | 88 | } |
88 | 89 | return formatter.format(0 - diff, "second"); |
89 | 90 | } |
| 91 | +
|
| 92 | + type Reaction = Exclude<keyof NonNullable<(typeof release)["reactions"]>, "url" | "total_count">; |
| 93 | + const reactionsEmojis: Record<Reaction, string> = { |
| 94 | + "+1": "👍", |
| 95 | + "-1": "👎", |
| 96 | + laugh: "😄", |
| 97 | + confused: "😕", |
| 98 | + heart: "❤️", |
| 99 | + hooray: "🎉", |
| 100 | + rocket: "🚀", |
| 101 | + eyes: "👀" |
| 102 | + }; |
| 103 | + const sortedEmojis: Reaction[] = [ |
| 104 | + "+1", |
| 105 | + "-1", |
| 106 | + "laugh", |
| 107 | + "hooray", |
| 108 | + "confused", |
| 109 | + "heart", |
| 110 | + "rocket", |
| 111 | + "eyes" |
| 112 | + ]; |
90 | 113 | </script> |
91 | 114 |
|
92 | 115 | {#snippet badges()} |
|
216 | 239 | </div> |
217 | 240 | </Accordion.Trigger> |
218 | 241 | <Accordion.Content class="rounded-b-xl bg-accent/30 px-6"> |
219 | | - <div class="relative mt-4 flex flex-col gap-4 sm:flex-row sm:justify-between sm:gap-0"> |
| 242 | + <div class="relative mt-4 flex flex-col gap-2"> |
220 | 243 | <MarkdownRenderer |
221 | 244 | markdown={releaseBody} |
222 | 245 | additionalPlugins={[{ renderer: { li: ListElementRenderer } }]} |
223 | 246 | class="prose-sm max-w-full prose-p:my-0" |
224 | 247 | /> |
225 | | - <!-- Open the release on GitHub in a new tab --> |
226 | | - <Button variant="outline" size="sm" class="invisible mr-6">this is a long long text</Button> |
227 | | - <Button |
228 | | - href={release.html_url} |
229 | | - variant="outline" |
230 | | - size="sm" |
231 | | - target="_blank" |
232 | | - class="group absolute right-0 bottom-1 shrink-0 gap-0 transition-colors duration-500" |
233 | | - > |
234 | | - <span class="-mr-6 hidden group-hover:block">Open on GitHub</span> |
235 | | - <img |
236 | | - src="/github.svg" |
237 | | - alt="GitHub" |
238 | | - class="size-5 transition-opacity duration-300 group-hover:opacity-0 dark:invert" |
239 | | - /> |
240 | | - <ArrowUpRight |
241 | | - class="ml-2 size-4 transition-transform duration-300 group-hover:translate-x-1 group-hover:-translate-y-1" |
242 | | - /> |
243 | | - </Button> |
| 248 | + <div class="flex items-end-safe justify-between gap-8"> |
| 249 | + <!-- Reactions --> |
| 250 | + {#if release.reactions} |
| 251 | + {@const reactionEntries = Object.entries(release.reactions) |
| 252 | + .filter(([k, v]) => !["url", "total_count"].includes(k) && !!v) |
| 253 | + .toSorted(([a], [b]) => sortedEmojis.indexOf(a) - sortedEmojis.indexOf(b)) as Entries< |
| 254 | + Record<Reaction, number> |
| 255 | + >} |
| 256 | + <div class="flex flex-wrap gap-1.5"> |
| 257 | + {#each reactionEntries as [key, value] (key)} |
| 258 | + <Badge variant="outline" class="text-sm">{reactionsEmojis[key]} {value}</Badge> |
| 259 | + {/each} |
| 260 | + </div> |
| 261 | + {/if} |
| 262 | + <!-- Open the release on GitHub in a new tab --> |
| 263 | + <Button variant="outline" size="sm" class="invisible w-16 sm:w-36" /> |
| 264 | + <Button |
| 265 | + href={release.html_url} |
| 266 | + variant="outline" |
| 267 | + size="sm" |
| 268 | + target="_blank" |
| 269 | + class="group absolute right-0 bottom-0 shrink-0 gap-0 transition-colors duration-500" |
| 270 | + > |
| 271 | + <span class="-mr-6 hidden sm:group-hover:block">Open on GitHub</span> |
| 272 | + <img |
| 273 | + src="/github.svg" |
| 274 | + alt="GitHub" |
| 275 | + class="size-5 transition-opacity duration-300 sm:group-hover:opacity-0 dark:invert" |
| 276 | + /> |
| 277 | + <ArrowUpRight |
| 278 | + class="ml-2 size-4 transition-transform duration-300 sm:group-hover:translate-x-1 sm:group-hover:-translate-y-1" |
| 279 | + /> |
| 280 | + </Button> |
| 281 | + </div> |
244 | 282 | </div> |
245 | 283 | </Accordion.Content> |
246 | 284 | </Accordion.Item> |
0 commit comments