anki/ts/src/stats/CardCounts.svelte

38 lines
922 B
Svelte
Raw Normal View History

<script lang="typescript">
import { gatherData, CardCounts } from "./card-counts";
import pb from "../backend/proto";
2020-06-27 13:10:17 +02:00
import { I18n } from "../i18n";
export let sourceData: pb.BackendProto.GraphsOut | null = null;
2020-06-27 13:10:17 +02:00
export let i18n: I18n;
let cardCounts: CardCounts | null = null;
$: if (sourceData) {
2020-06-27 13:10:17 +02:00
cardCounts = gatherData(sourceData, i18n);
}
</script>
2020-06-27 13:10:17 +02:00
<style>
.counts-outer {
display: flex;
flex-wrap: wrap;
2020-06-29 05:46:13 +02:00
justify-content: space-around;
2020-06-27 13:10:17 +02:00
}
</style>
{#if cardCounts}
<div class="graph">
<h1>{cardCounts.title}</h1>
<div class="counts-outer">
{#each cardCounts.counts as count}
<div>
<div>
<b>{count[0]}</b>
</div>
<div>{count[1]}</div>
</div>
{/each}
</div>
</div>
{/if}