Add first GraphPreferences which are not hooked to backend yet
This commit is contained in:
parent
0c35d30979
commit
d27167ce86
@ -71,6 +71,7 @@ ts_library(
|
||||
"@npm//d3-transition",
|
||||
"@npm//lodash.debounce",
|
||||
"@npm//lodash.throttle",
|
||||
"@npm//svelte",
|
||||
],
|
||||
)
|
||||
|
||||
|
@ -5,11 +5,11 @@
|
||||
import type pb from "anki/backend_proto";
|
||||
import type { I18n } from "anki/i18n";
|
||||
import SeparateInactiveCheckbox from "./SeparateInactiveCheckbox.svelte";
|
||||
import { cardCountsSeparateInactive } from "./preferences";
|
||||
|
||||
export let sourceData: pb.BackendProto.GraphsOut;
|
||||
export let i18n: I18n;
|
||||
|
||||
let separateInactive = true;
|
||||
let svg = null as HTMLElement | SVGElement | null;
|
||||
|
||||
let bounds = defaultGraphBounds();
|
||||
@ -20,7 +20,7 @@
|
||||
let tableData = (null as unknown) as TableDatum[];
|
||||
|
||||
$: {
|
||||
graphData = gatherData(sourceData, separateInactive, i18n);
|
||||
graphData = gatherData(sourceData, $cardCountsSeparateInactive, i18n);
|
||||
tableData = renderCards(svg as any, bounds, graphData);
|
||||
}
|
||||
|
||||
@ -56,7 +56,7 @@
|
||||
<h1>{graphData.title}</h1>
|
||||
|
||||
<div class="range-box-inner">
|
||||
<SeparateInactiveCheckbox bind:separateInactive {i18n} />
|
||||
<SeparateInactiveCheckbox {i18n} />
|
||||
</div>
|
||||
|
||||
<div class="counts-outer">
|
||||
|
@ -1,10 +1,13 @@
|
||||
<script lang="typescript">
|
||||
import type { I18n } from "anki/i18n";
|
||||
import { cardCountsSeparateInactive } from "./preferences";
|
||||
|
||||
export let i18n: I18n;
|
||||
export let separateInactive: boolean = true;
|
||||
|
||||
const label = i18n.tr(i18n.TR.STATISTICS_COUNTS_SEPARATE_SUSPENDED_BURIED_CARDS);
|
||||
</script>
|
||||
|
||||
<label> <input type="checkbox" bind:checked={separateInactive} /> {label} </label>
|
||||
<label>
|
||||
<input type="checkbox" bind:checked={$cardCountsSeparateInactive} />
|
||||
{label}
|
||||
</label>
|
||||
|
15
ts/graphs/preferences.ts
Normal file
15
ts/graphs/preferences.ts
Normal file
@ -0,0 +1,15 @@
|
||||
import { writable } from "svelte/store";
|
||||
|
||||
function createPreference(initialValue: unknown) {
|
||||
const { subscribe, set } = writable(initialValue);
|
||||
|
||||
return {
|
||||
subscribe,
|
||||
set: (v: unknown) => {
|
||||
set(v);
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
export const calendarFirstDayOfWeek = createPreference(0);
|
||||
export const cardCountsSeparateInactive = createPreference(false);
|
Loading…
Reference in New Issue
Block a user