Anki/ts/routes/deck-options/EasyDays.svelte
Jarrett Ye a982720a42
Feat/Easy Days (#3442)
* Feat/Easy Days

* format

* add easy_days_percentages to deck_config

* configure Easy Days via table

* remove unused code

* add translatable strings & add default of easy days

* don't check easy_days_percentages when deserialize

* pass test::all_reserved_fields_are_removed

* consider next_day_at when interval_to_weekday

* remove y-axis-title created in last simulation

* EstimatedTotalKnowledge should be integer

* Reorder deck option sections (dae)

- Move FSRS to bottom left, to move it closer to the top, and so
the left and right columns appear roughly balanced when FSRS is
enabled.
- Move Easy Days above Advanced

* Don't crash if wrong number of days (dae)

* Use lower field number (dae)

Repeated fields are more compactly stored in the first 15 fields.
2024-10-11 19:47:44 +10:00

97 lines
3.6 KiB
Svelte

<!--
Copyright: Ankitects Pty Ltd and contributors
License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
-->
<script lang="ts">
import * as tr from "@generated/ftl";
import DynamicallySlottable from "$lib/components/DynamicallySlottable.svelte";
import Item from "$lib/components/Item.svelte";
import TitledContainer from "$lib/components/TitledContainer.svelte";
import type { DeckOptionsState } from "./lib";
export let state: DeckOptionsState;
export let api: Record<string, never>;
const config = state.currentConfig;
const defaults = state.defaults;
if ($config.easyDaysPercentages.length !== 7) {
$config.easyDaysPercentages = defaults.easyDaysPercentages;
}
const easyDays = [
tr.deckConfigEasyDaysMonday(),
tr.deckConfigEasyDaysTuesday(),
tr.deckConfigEasyDaysWednesday(),
tr.deckConfigEasyDaysThursday(),
tr.deckConfigEasyDaysFriday(),
tr.deckConfigEasyDaysSaturday(),
tr.deckConfigEasyDaysSunday(),
];
</script>
<TitledContainer title={tr.deckConfigEasyDaysTitle()}>
<DynamicallySlottable slotHost={Item} {api}>
<Item>
<div class="easy-days-settings">
<table>
<thead>
<tr>
<th></th>
<th>{tr.deckConfigEasyDaysNormal()}</th>
<th>{tr.deckConfigEasyDaysReduced()}</th>
<th>{tr.deckConfigEasyDaysMinimum()}</th>
</tr>
</thead>
<tbody>
{#each easyDays as day, index}
<tr>
<td>{day}</td>
<td>
<input
type="radio"
bind:group={$config.easyDaysPercentages[index]}
value={1.0}
checked={$config.easyDaysPercentages[index] ===
1.0}
/>
</td>
<td>
<input
type="radio"
bind:group={$config.easyDaysPercentages[index]}
value={0.5}
checked={$config.easyDaysPercentages[index] ===
0.5}
/>
</td>
<td>
<input
type="radio"
bind:group={$config.easyDaysPercentages[index]}
value={0.0}
checked={$config.easyDaysPercentages[index] ===
0.0}
/>
</td>
</tr>
{/each}
</tbody>
</table>
</div>
</Item>
</DynamicallySlottable>
</TitledContainer>
<style>
.easy-days-settings table {
width: 100%;
border-collapse: collapse;
}
.easy-days-settings th,
.easy-days-settings td {
padding: 8px;
text-align: center;
border: 1px solid #ddd;
}
</style>