anki/ts/graphs/GraphsPage.svelte

63 lines
1.6 KiB
Svelte
Raw Normal View History

<!--
Copyright: Ankitects Pty Ltd and contributors
License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
-->
<script lang="typescript">
2020-12-27 02:04:45 +01:00
import type { SvelteComponent } from "svelte/internal";
import { writable } from "svelte/store";
import { bridgeCommand } from "lib/bridgecommand";
2021-03-21 22:35:53 +01:00
import WithGraphData from "./WithGraphData.svelte";
2020-06-30 08:23:46 +02:00
export let nightMode: boolean;
export let graphs: SvelteComponent[];
2020-06-27 11:24:49 +02:00
export let initialSearch: string;
export let initialDays: number;
export let controller: SvelteComponent | null;
2020-12-22 22:25:47 +01:00
const search = writable(initialSearch);
const days = writable(initialDays);
function browserSearch(event: CustomEvent) {
bridgeCommand(`browserSearch: ${$search} ${event.detail.query}`);
}
</script>
<div>
2021-03-21 22:35:53 +01:00
<WithGraphData
{search}
{days}
2021-03-21 22:35:53 +01:00
let:loading
let:sourceData
let:preferences
let:revlogRange
>
2021-03-21 22:35:53 +01:00
{#if controller}
<svelte:component this={controller} {search} {days} {loading} />
2021-03-21 22:35:53 +01:00
{/if}
{#if sourceData && preferences && revlogRange}
2021-03-21 22:35:53 +01:00
{#each graphs as graph}
<svelte:component
this={graph}
{sourceData}
{preferences}
{revlogRange}
{nightMode}
on:search={browserSearch}
/>
2021-03-21 22:35:53 +01:00
{/each}
{/if}
</WithGraphData>
</div>
<style lang="scss">
div {
@media only screen and (max-width: 600px) {
font-size: 12px;
}
}
</style>