Anki/ts/routes/deck-options/SpinBoxFloatRow.svelte
Arthur Milchior 6c37d5fc70
Add percentage to FSRS spinner (#3679)
* Add percentage to FSRS spinner

This commit add a percentage option in SpinBox and SpinBoxFloatRow, set to False
by default.

If it's true, a percent symbol is added at the end of the line before
the increase/decrease button.

While the value is represented as a percentage without decimal places,
the internal representation is not changed. Which mean that a
multiplier must used to compute the string value, indicate to the
input field the min, max and step, and when updating the result.

* Remove unsightly percentage sign, and update historical retention too

https://github.com/ankitects/anki/pull/3679#issuecomment-2579636981

---------

Co-authored-by: Damien Elmes <gpg@ankiweb.net>
2025-01-25 18:17:02 +11:00

30 lines
971 B
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 Col from "$lib/components/Col.svelte";
import ConfigInput from "$lib/components/ConfigInput.svelte";
import RevertButton from "$lib/components/RevertButton.svelte";
import Row from "$lib/components/Row.svelte";
import SpinBox from "$lib/components/SpinBox.svelte";
export let value: number;
export let defaultValue: number;
export let min = 0;
export let max = 9999;
export let step = 0.01;
export let percentage = false;
</script>
<Row --cols={13}>
<Col --col-size={7} breakpoint="xs">
<slot />
</Col>
<Col --col-size={6} breakpoint="xs">
<ConfigInput>
<SpinBox bind:value {min} {max} {step} {percentage} />
<RevertButton slot="revert" bind:value {defaultValue} />
</ConfigInput>
</Col>
</Row>