anki/ts/graphs/GraphsPage.svelte

60 lines
1.5 KiB
Svelte
Raw Normal View History

<script lang="typescript">
import "../sass/core.css";
2020-12-27 02:04:45 +01:00
import type { SvelteComponent } from "svelte/internal";
import { writable } from "svelte/store";
import { bridgeCommand } from "anki/bridgecommand";
2021-03-21 22:35:53 +01:00
import WithGraphData from "./WithGraphData.svelte";
import * as tr from "anki/i18n";
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>
<style lang="scss">
div {
@media only screen and (max-width: 600px) {
font-size: 12px;
}
}
</style>
<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>
{#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>