Commit ef9369ba authored by Christophe Benz's avatar Christophe Benz
Browse files

Add more count types

parent 2d40ffe3
......@@ -6,7 +6,7 @@
<div class="cards px-2">
<div class="flex flex-wrap -mx-2">
{#each data as { id, html, title, text, url, count, countIcon, imageUrl } (id)}
{#each data as { id, html, title, text, url, counts, imageUrl } (id)}
<div class="w-full mb-4 sm:w-1/3 sm:px-2 lg:w-1/4">
<Card.Card class="bg-white w-full sm:h-full">
<div slot="title">
......@@ -27,14 +27,16 @@
{/if}
</div>
<div slot="actions" class="mt-auto">
{#if count || url}
{#if (counts && counts.length) || url}
<div class="px-2 py-3 flex items-center">
{#if count}
<div class="px-3 inline-flex">
{count}
<Icon>{countIcon}</Icon>
</div>
{/if}
{#each counts as { count, icon, title } (icon)}
{#if count}
<div class="mx-3 inline-flex" {title}>
{count}
<Icon>{icon}</Icon>
</div>
{/if}
{/each}
<a class="ml-auto" href={url} target="_blank">
<Button text>View</Button>
</a>
......
......@@ -15,8 +15,18 @@ export class FetchError extends OError {
export function discourseTopicToCardData(source, topic) {
return {
...topic,
count: topic.posts_count,
countIcon: "reply", // Cf https://material.io/resources/icons
counts: [
{
count: topic.like_count,
icon: "favorite", // Cf https://material.io/resources/icons
title: "Likes"
},
{
count: topic.posts_count,
icon: "reply", // Cf https://material.io/resources/icons
title: "Replies"
},
],
imageUrl: topic.image_url,
html: topic.excerpt,
// title already exist in `topic`
......@@ -27,8 +37,18 @@ export function discourseTopicToCardData(source, topic) {
export function gitlabProjectToCardData(project) {
return {
...project,
count: project.star_count,
countIcon: "star", // Cf https://material.io/resources/icons
counts: [
{
count: project.star_count,
icon: "star", // Cf https://material.io/resources/icons
title: "Stars"
},
{
count: project.forks_count,
icon: "call_split", // Cf https://material.io/resources/icons
title: "Forks"
}
],
imageUrl: project.avatar_url,
text: project.description,
title: project.name,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment