From c72e9e53292d50218bda84d3f592f0c23edfb922 Mon Sep 17 00:00:00 2001 From: Henrik Giesel Date: Sat, 26 Dec 2020 14:40:55 +0100 Subject: [PATCH] Pass in RangeBox as an argument, decoupling it from GraphsPage --- ts/graphs/GraphsPage.svelte | 15 +++++++-------- ts/graphs/bootstrap.ts | 11 +++++++---- ts/graphs/graphs.html | 4 +++- 3 files changed, 17 insertions(+), 13 deletions(-) diff --git a/ts/graphs/GraphsPage.svelte b/ts/graphs/GraphsPage.svelte index 5ff471b72..d4f6058c4 100644 --- a/ts/graphs/GraphsPage.svelte +++ b/ts/graphs/GraphsPage.svelte @@ -3,19 +3,18 @@ -{#if withRangeBox} - +{#if controller} + {/if} {#if sourceData}
- {#each graphs as Graph} - + {#each graphs as graph} + {/each}
{/if} diff --git a/ts/graphs/bootstrap.ts b/ts/graphs/bootstrap.ts index fba7bc183..98bd84616 100644 --- a/ts/graphs/bootstrap.ts +++ b/ts/graphs/bootstrap.ts @@ -1,10 +1,13 @@ // Copyright: Ankitects Pty Ltd and contributors // License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html +import type { SvelteComponent } from 'svelte/internal'; + import { setupI18n } from "anki/i18n"; import GraphsPage from "./GraphsPage.svelte"; import { checkNightMode } from "anki/nightmode"; -import { RevlogRange } from "./graph-helpers"; + +export { default as RangeBox } from './RangeBox.svelte'; export { default as IntervalsGraph } from "./IntervalsGraph.svelte"; export { default as EaseGraph } from "./EaseGraph.svelte"; @@ -20,10 +23,10 @@ export { RevlogRange } from "./graph-helpers"; export function graphs( target: HTMLDivElement, - graphs: any[], { + graphs: SvelteComponent[], { search = "deck:current", days = 365, - withRangeBox = true, + controller = null, } = {}, ): void { const nightMode = checkNightMode(); @@ -37,7 +40,7 @@ export function graphs( nightMode, search, days, - withRangeBox, + controller, }, }); }); diff --git a/ts/graphs/graphs.html b/ts/graphs/graphs.html index 403df40bc..49027af7b 100644 --- a/ts/graphs/graphs.html +++ b/ts/graphs/graphs.html @@ -23,7 +23,9 @@ anki.HourGraph, anki.ButtonsGraph, anki.AddedGraph, - ], + ], { + controller: anki.RangeBox, + } );