anki/ts/graphs/GraphsPage.svelte

63 lines
1.6 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 type { I18n } from "anki/i18n";
2021-03-21 22:35:53 +01:00
import WithGraphData from "./WithGraphData.svelte";
import BrowserSearch from "./BrowserSearch.svelte";
2021-03-21 22:35:53 +01:00
2020-06-27 11:24:49 +02:00
export let i18n: 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
let query: string;
const activateBrowserSearch = (event: CustomEvent): void => {
query = 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
{initialSearch}
{initialDays}
let:search
let:days
2021-03-21 22:35:53 +01:00
let:loading
let:sourceData
let:preferences
let:revlogRange>
{#if controller}
<svelte:component this={controller} {i18n} {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}
{i18n}
{nightMode}
on:search={activateBrowserSearch} />
2021-03-21 22:35:53 +01:00
{/each}
{/if}
<BrowserSearch {search} {query} />
2021-03-21 22:35:53 +01:00
</WithGraphData>
</div>