From 008940026eb1592a983b41ce32e6d99f5063d6fd Mon Sep 17 00:00:00 2001 From: Henrik Giesel Date: Tue, 22 Dec 2020 22:06:12 +0100 Subject: [PATCH] Pass in graphs as arguments into graphs() --- ts/graphs/GraphsPage.svelte | 24 ++++-------------------- ts/graphs/bootstrap.ts | 21 +++++++++++++++++++-- ts/graphs/graphs.html | 15 ++++++++++++++- 3 files changed, 37 insertions(+), 23 deletions(-) diff --git a/ts/graphs/GraphsPage.svelte b/ts/graphs/GraphsPage.svelte index 643d42a8c..c150b297a 100644 --- a/ts/graphs/GraphsPage.svelte +++ b/ts/graphs/GraphsPage.svelte @@ -6,19 +6,10 @@ import type { I18n } from "anki/i18n"; import type pb from "anki/backend_proto"; import { getGraphData, RevlogRange } from "./graph-helpers"; - import IntervalsGraph from "./IntervalsGraph.svelte"; - import EaseGraph from "./EaseGraph.svelte"; - import AddedGraph from "./AddedGraph.svelte"; - import TodayStats from "./TodayStats.svelte"; - import ButtonsGraph from "./ButtonsGraph.svelte"; - import CardCounts from "./CardCounts.svelte"; - import HourGraph from "./HourGraph.svelte"; - import FutureDue from "./FutureDue.svelte"; - import ReviewsGraph from "./ReviewsGraph.svelte"; - import CalendarGraph from "./CalendarGraph.svelte"; export let i18n: I18n; export let nightMode: boolean; + export let graphs: any[]; let sourceData: pb.BackendProto.GraphsOut | null = null; @@ -144,15 +135,8 @@
{#if sourceData} - - - - - - - - - - + {#each graphs as Graph} + + {/each} {/if}
diff --git a/ts/graphs/bootstrap.ts b/ts/graphs/bootstrap.ts index ccc63403e..12a5b6b31 100644 --- a/ts/graphs/bootstrap.ts +++ b/ts/graphs/bootstrap.ts @@ -5,11 +5,28 @@ import { setupI18n } from "anki/i18n"; import GraphsPage from "./GraphsPage.svelte"; import { checkNightMode } from "anki/nightmode"; -export function graphs(target: HTMLDivElement): void { +export { default as IntervalsGraph } from "./IntervalsGraph.svelte"; +export { default as EaseGraph } from "./EaseGraph.svelte"; +export { default as AddedGraph } from "./AddedGraph.svelte"; +export { default as TodayStats } from "./TodayStats.svelte"; +export { default as ButtonsGraph } from "./ButtonsGraph.svelte"; +export { default as CardCounts } from "./CardCounts.svelte"; +export { default as HourGraph } from "./HourGraph.svelte"; +export { default as FutureDue } from "./FutureDue.svelte"; +export { default as ReviewsGraph } from "./ReviewsGraph.svelte"; +export { default as CalendarGraph } from "./CalendarGraph.svelte"; + +export function graphs(target: HTMLDivElement, graphs: any[]): void { + const nightMode = checkNightMode(); + setupI18n().then((i18n) => { new GraphsPage({ target, - props: { i18n, nightMode: checkNightMode() }, + props: { + i18n, + graphs, + nightMode, + }, }); }); } diff --git a/ts/graphs/graphs.html b/ts/graphs/graphs.html index 43e8cb85d..403df40bc 100644 --- a/ts/graphs/graphs.html +++ b/ts/graphs/graphs.html @@ -11,6 +11,19 @@