diff --git a/ts/graphs/BUILD.bazel b/ts/graphs/BUILD.bazel index 91bc5ae21..73cd33659 100644 --- a/ts/graphs/BUILD.bazel +++ b/ts/graphs/BUILD.bazel @@ -30,6 +30,7 @@ ts_library( "GraphsPage", "lib", "//ts/lib", + "@npm//svelte", "@npm//svelte2tsx", ], ) diff --git a/ts/graphs/GraphsPage.svelte b/ts/graphs/GraphsPage.svelte index 643d42a8c..1eaa9cac4 100644 --- a/ts/graphs/GraphsPage.svelte +++ b/ts/graphs/GraphsPage.svelte @@ -3,156 +3,61 @@ - +{#if controller} + +{/if} -
-
- -
- - - - { - searchRange = SearchRange.Custom; - }} - placeholder={searchLabel} /> +{#if sourceData} +
+ {#each graphs as graph} + + {/each}
- -
- - -
-
-
- -
- {#if sourceData} - - - - - - - - - - - {/if} -
+{/if} diff --git a/ts/graphs/RangeBox.svelte b/ts/graphs/RangeBox.svelte new file mode 100644 index 000000000..a38807a98 --- /dev/null +++ b/ts/graphs/RangeBox.svelte @@ -0,0 +1,120 @@ + + +
+
+ +
+ + + + { + searchRange = SearchRange.Custom; + }} + placeholder={searchLabel} /> +
+ +
+ + +
+
+ +
diff --git a/ts/graphs/bootstrap.ts b/ts/graphs/bootstrap.ts index ccc63403e..d27eb0448 100644 --- a/ts/graphs/bootstrap.ts +++ b/ts/graphs/bootstrap.ts @@ -1,15 +1,44 @@ // 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"; -export function graphs(target: HTMLDivElement): void { +export { default as RangeBox } from "./RangeBox.svelte"; + +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 { RevlogRange } from "./graph-helpers"; + +export function graphs( + target: HTMLDivElement, + graphs: SvelteComponent[], + { search = "deck:current", days = 365, controller = null } = {} +): void { + const nightMode = checkNightMode(); + setupI18n().then((i18n) => { new GraphsPage({ target, - props: { i18n, nightMode: checkNightMode() }, + props: { + i18n, + graphs, + nightMode, + search, + days, + controller, + }, }); }); } diff --git a/ts/graphs/graphs.html b/ts/graphs/graphs.html index 43e8cb85d..bf8a9bdf9 100644 --- a/ts/graphs/graphs.html +++ b/ts/graphs/graphs.html @@ -11,6 +11,23 @@ diff --git a/ts/graphs/graphs.scss b/ts/graphs/graphs.scss index 713fa8e7a..75c4eddf7 100644 --- a/ts/graphs/graphs.scss +++ b/ts/graphs/graphs.scss @@ -193,3 +193,7 @@ .align-start { text-align: start; } + +.no-focus-outline:focus { + outline: 0; +}