Implement CheckBoxRow and SpinBoxFloatRow

This commit is contained in:
Henrik Giesel 2021-05-29 13:30:10 +02:00
parent 5fa850703f
commit 1bb59198dd
7 changed files with 188 additions and 239 deletions

View file

@ -4,14 +4,9 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
--> -->
<script lang="ts"> <script lang="ts">
import * as tr from "lib/i18n"; import * as tr from "lib/i18n";
import marked from "marked";
import TitledContainer from "./TitledContainer.svelte"; import TitledContainer from "./TitledContainer.svelte";
import Row from "./Row.svelte"; import SpinBoxRow from "./SpinBoxRow.svelte";
import Col from "./Col.svelte"; import SpinBoxFloatRow from "./SpinBoxFloatRow.svelte";
import HelpPopup from "./HelpPopup.svelte";
import SpinBox from "./SpinBox.svelte";
import SpinBoxFloat from "./SpinBoxFloat.svelte";
import RevertButton from "./RevertButton.svelte";
import type { DeckOptionsState } from "./lib"; import type { DeckOptionsState } from "./lib";
export let state: DeckOptionsState; export let state: DeckOptionsState;
@ -20,91 +15,62 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
</script> </script>
<TitledContainer title={tr.deckConfigAdvancedTitle()}> <TitledContainer title={tr.deckConfigAdvancedTitle()}>
<Row> <SpinBoxRow
<Col size={7}> bind:value={$config.maximumReviewInterval}
{tr.schedulingMaximumInterval()} defaultValue={defaults.maximumReviewInterval}
<HelpPopup html={marked(tr.deckConfigMaximumIntervalTooltip())} /> min={1}
</Col> max={365 * 100}
<Col size={5}> markdownTooltip={tr.deckConfigMaximumIntervalTooltip()}
<SpinBox >
min={1} {tr.schedulingMaximumInterval()}
max={365 * 100} </SpinBoxRow>
bind:value={$config.maximumReviewInterval}
/>
<RevertButton
defaultValue={defaults.maximumReviewInterval}
bind:value={$config.maximumReviewInterval}
/>
</Col>
</Row>
<Row> <SpinBoxFloatRow
<Col size={7}> bind:value={$config.initialEase}
{tr.schedulingStartingEase()} defaultValue={defaults.initialEase}
<HelpPopup html={marked(tr.deckConfigStartingEaseTooltip())} /> min={1.31}
</Col> max={5}
<Col size={5}> markdownTooltip={tr.deckConfigStartingEaseTooltip()}
<SpinBoxFloat min={1.31} max={5} bind:value={$config.initialEase} /> >
<RevertButton {tr.schedulingStartingEase()}
defaultValue={defaults.initialEase} </SpinBoxFloatRow>
bind:value={$config.initialEase}
/>
</Col>
</Row>
<Row> <SpinBoxFloatRow
<Col size={7}> bind:value={$config.easyMultiplier}
{tr.schedulingEasyBonus()} defaultValue={defaults.easyMultiplier}
<HelpPopup html={marked(tr.deckConfigEasyBonusTooltip())} /> min={1}
</Col> max={3}
<Col size={5}> markdownTooltip={tr.deckConfigEasyBonusTooltip()}
<SpinBoxFloat min={1} max={3} bind:value={$config.easyMultiplier} /> >
<RevertButton {tr.schedulingEasyBonus()}
defaultValue={defaults.easyMultiplier} </SpinBoxFloatRow>
bind:value={$config.easyMultiplier}
/>
</Col>
</Row>
<Row> <SpinBoxFloatRow
<Col size={7}> bind:value={$config.intervalMultiplier}
{tr.schedulingIntervalModifier()} defaultValue={defaults.intervalMultiplier}
<HelpPopup html={marked(tr.deckConfigIntervalModifierTooltip())} /> min={0.5}
</Col> max={2}
<Col size={5}> markdownTooltip={tr.deckConfigIntervalModifierTooltip()}
<SpinBoxFloat min={0.5} max={2} bind:value={$config.intervalMultiplier} /> >
<RevertButton {tr.schedulingIntervalModifier()}
defaultValue={defaults.intervalMultiplier} </SpinBoxFloatRow>
bind:value={$config.intervalMultiplier}
/>
</Col>
</Row>
<Row> <SpinBoxFloatRow
<Col size={7}> bind:value={$config.hardMultiplier}
{tr.schedulingHardInterval()} defaultValue={defaults.hardMultiplier}
<HelpPopup html={marked(tr.deckConfigHardIntervalTooltip())} /> min={0.5}
</Col> max={1.3}
<Col size={5}> markdownTooltip={tr.deckConfigHardIntervalTooltip()}
<SpinBoxFloat min={0.5} max={1.3} bind:value={$config.hardMultiplier} /> >
<RevertButton {tr.schedulingHardInterval()}
defaultValue={defaults.hardMultiplier} </SpinBoxFloatRow>
bind:value={$config.hardMultiplier}
/>
</Col>
</Row>
<Row> <SpinBoxFloatRow
<Col size={7}> bind:value={$config.lapseMultiplier}
{tr.schedulingNewInterval()} defaultValue={defaults.lapseMultiplier}
<HelpPopup html={marked(tr.deckConfigNewIntervalTooltip())} /> max={1}
</Col> markdownTooltip={tr.deckConfigNewIntervalTooltip()}
<Col size={5}> >
<SpinBoxFloat min={0} max={1} bind:value={$config.lapseMultiplier} /> {tr.schedulingNewInterval()}
<RevertButton </SpinBoxFloatRow>
defaultValue={defaults.lapseMultiplier}
bind:value={$config.lapseMultiplier}
/>
</Col>
</Row>
</TitledContainer> </TitledContainer>

View file

@ -4,13 +4,8 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
--> -->
<script lang="ts"> <script lang="ts">
import * as tr from "lib/i18n"; import * as tr from "lib/i18n";
import marked from "marked";
import TitledContainer from "./TitledContainer.svelte"; import TitledContainer from "./TitledContainer.svelte";
import Row from "./Row.svelte"; import CheckBoxRow from "./CheckBoxRow.svelte";
import Col from "./Col.svelte";
import HelpPopup from "./HelpPopup.svelte";
import CheckBox from "./CheckBox.svelte";
import RevertButton from "./RevertButton.svelte";
import type { DeckOptionsState } from "./lib"; import type { DeckOptionsState } from "./lib";
export let state: DeckOptionsState; export let state: DeckOptionsState;
@ -19,34 +14,18 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
</script> </script>
<TitledContainer title={tr.deckConfigAudioTitle()}> <TitledContainer title={tr.deckConfigAudioTitle()}>
<Row> <CheckBoxRow
<Col> bind:value={$config.disableAutoplay}
<CheckBox bind:value={$config.disableAutoplay}> defaultValue={defaults.disableAutoplay}
{tr.deckConfigDisableAutoplay()} >
</CheckBox> {tr.deckConfigDisableAutoplay()}
</Col> </CheckBoxRow>
<Col grow={false}>
<RevertButton
defaultValue={defaults.disableAutoplay}
bind:value={$config.disableAutoplay}
/>
</Col>
</Row>
<Row> <CheckBoxRow
<Col> bind:value={$config.skipQuestionWhenReplayingAnswer}
<CheckBox bind:value={$config.skipQuestionWhenReplayingAnswer}> defaultValue={defaults.skipQuestionWhenReplayingAnswer}
{tr.schedulingAlwaysIncludeQuestionSideWhenReplaying()} markdownTooltip={tr.deckConfigAlwaysIncludeQuestionAudioTooltip()}
<HelpPopup >
html={marked(tr.deckConfigAlwaysIncludeQuestionAudioTooltip())} {tr.schedulingAlwaysIncludeQuestionSideWhenReplaying()}
/> </CheckBoxRow>
</CheckBox>
</Col>
<Col grow={false}>
<RevertButton
defaultValue={defaults.skipQuestionWhenReplayingAnswer}
bind:value={$config.skipQuestionWhenReplayingAnswer}
/>
</Col>
</Row>
</TitledContainer> </TitledContainer>

View file

@ -0,0 +1,30 @@
<!--
Copyright: Ankitects Pty Ltd and contributors
License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
-->
<script lang="ts">
import marked from "marked";
import Row from "./Row.svelte";
import Col from "./Col.svelte";
import HelpPopup from "./HelpPopup.svelte";
import CheckBox from "./CheckBox.svelte";
import RevertButton from "./RevertButton.svelte";
export let value: boolean;
export let defaultValue: boolean;
export let markdownTooltip: string | undefined = undefined;
</script>
<Row>
<Col>
<CheckBox bind:value
><slot />
{#if markdownTooltip}<HelpPopup
html={marked(markdownTooltip)}
/>{/if}</CheckBox
>
</Col>
<Col grow={false}>
<RevertButton bind:value {defaultValue} />
</Col>
</Row>

View file

@ -4,13 +4,8 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
--> -->
<script lang="ts"> <script lang="ts">
import * as tr from "lib/i18n"; import * as tr from "lib/i18n";
import marked from "marked";
import TitledContainer from "./TitledContainer.svelte"; import TitledContainer from "./TitledContainer.svelte";
import Row from "./Row.svelte"; import EnumSelectorRow from "./EnumSelectorRow.svelte";
import Col from "./Col.svelte";
import HelpPopup from "./HelpPopup.svelte";
import EnumSelector from "./EnumSelector.svelte";
import RevertButton from "./RevertButton.svelte";
import type { DeckOptionsState } from "./lib"; import type { DeckOptionsState } from "./lib";
import { reviewMixChoices } from "./strings"; import { reviewMixChoices } from "./strings";
@ -42,82 +37,48 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
</script> </script>
<TitledContainer title={tr.deckConfigOrderingTitle()}> <TitledContainer title={tr.deckConfigOrderingTitle()}>
<Row> <EnumSelectorRow
<Col size={7}> bind:value={$config.newCardGatherPriority}
{tr.deckConfigNewGatherPriority()} defaultValue={defaults.newCardGatherPriority}
<HelpPopup html={marked(tr.deckConfigNewGatherPriorityTooltip())} /> choices={newGatherPriorityChoices}
</Col> markdownTooltip={tr.deckConfigNewGatherPriorityTooltip()}
<Col size={5}> >
<EnumSelector {tr.deckConfigNewGatherPriority()}
choices={newGatherPriorityChoices} </EnumSelectorRow>
bind:value={$config.newCardGatherPriority}
/>
<RevertButton
defaultValue={defaults.newCardGatherPriority}
bind:value={$config.newCardGatherPriority}
/>
</Col>
</Row>
<Row> <EnumSelectorRow
<Col size={7}> bind:value={$config.newCardSortOrder}
{tr.deckConfigNewCardSortOrder()} defaultValue={defaults.newCardSortOrder}
<HelpPopup html={marked(tr.deckConfigNewCardSortOrderTooltip())} /> choices={newSortOrderChoices}
</Col> markdownTooltip={tr.deckConfigNewCardSortOrderTooltip()}
<Col size={5}> >
<EnumSelector {tr.deckConfigNewCardSortOrder()}
choices={newSortOrderChoices} </EnumSelectorRow>
bind:value={$config.newCardSortOrder}
/>
<RevertButton
defaultValue={defaults.newCardSortOrder}
bind:value={$config.newCardSortOrder}
/>
</Col>
</Row>
<Row> <EnumSelectorRow
<Col size={7}> bind:value={$config.newMix}
{tr.deckConfigNewReviewPriority()} defaultValue={defaults.newMix}
<HelpPopup html={marked(tr.deckConfigNewReviewPriorityTooltip())} /> choices={reviewMixChoices()}
</Col> markdownTooltip={tr.deckConfigNewReviewPriorityTooltip()}
<Col size={5}> >
<EnumSelector choices={reviewMixChoices()} bind:value={$config.newMix} /> {tr.deckConfigNewReviewPriority()}
<RevertButton defaultValue={defaults.newMix} bind:value={$config.newMix} /> </EnumSelectorRow>
</Col>
</Row>
<Row> <EnumSelectorRow
<Col size={7}> bind:value={$config.interdayLearningMix}
{tr.deckConfigInterdayStepPriority()} defaultValue={defaults.interdayLearningMix}
<HelpPopup html={marked(tr.deckConfigInterdayStepPriorityTooltip())} /> choices={reviewMixChoices()}
</Col> markdownTooltip={tr.deckConfigInterdayStepPriorityTooltip()}
<Col size={5}> >
<EnumSelector {tr.deckConfigInterdayStepPriority()}
choices={reviewMixChoices()} </EnumSelectorRow>
bind:value={$config.interdayLearningMix}
/>
<RevertButton
defaultValue={defaults.interdayLearningMix}
bind:value={$config.interdayLearningMix}
/>
</Col>
</Row>
<Row> <EnumSelectorRow
<Col size={7}> bind:value={$config.reviewOrder}
{tr.deckConfigReviewSortOrder()} defaultValue={defaults.reviewOrder}
<HelpPopup html={marked(tr.deckConfigReviewSortOrderTooltip())} /> choices={reviewOrderChoices}
</Col> markdownTooltip={tr.deckConfigReviewSortOrderTooltip()}
<Col size={5}> >
<EnumSelector {tr.deckConfigReviewSortOrder()}
choices={reviewOrderChoices} </EnumSelectorRow>
bind:value={$config.reviewOrder}
/>
<RevertButton
defaultValue={defaults.reviewOrder}
bind:value={$config.reviewOrder}
/>
</Col>
</Row>
</TitledContainer>> </TitledContainer>>

View file

@ -0,0 +1,28 @@
<!--
Copyright: Ankitects Pty Ltd and contributors
License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
-->
<script lang="ts">
import marked from "marked";
import Row from "./Row.svelte";
import Col from "./Col.svelte";
import HelpPopup from "./HelpPopup.svelte";
import SpinBoxFloat from "./SpinBoxFloat.svelte";
import RevertButton from "./RevertButton.svelte";
export let value: any;
export let defaultValue: any;
export let min = 0;
export let max: number | undefined = undefined;
export let markdownTooltip: string;
</script>
<Row>
<Col size={7}>
<slot /><HelpPopup html={marked(markdownTooltip)} />
</Col>
<Col size={5}>
<SpinBoxFloat bind:value {min} {max} />
<RevertButton bind:value {defaultValue} />
</Col>
</Row>

View file

@ -13,6 +13,7 @@
export let value: any; export let value: any;
export let defaultValue: any; export let defaultValue: any;
export let min = 0; export let min = 0;
export let max: number | undefined = undefined;
export let markdownTooltip: string; export let markdownTooltip: string;
</script> </script>
@ -21,7 +22,7 @@
<slot /><HelpPopup html={marked(markdownTooltip)} /> <slot /><HelpPopup html={marked(markdownTooltip)} />
</Col> </Col>
<Col size={5}> <Col size={5}>
<SpinBox bind:value {min} /> <SpinBox bind:value {min} {max} />
<RevertButton bind:value {defaultValue} /> <RevertButton bind:value {defaultValue} />
</Col> </Col>
</Row> </Row>

View file

@ -4,14 +4,9 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
--> -->
<script lang="ts"> <script lang="ts">
import * as tr from "lib/i18n"; import * as tr from "lib/i18n";
import marked from "marked";
import TitledContainer from "./TitledContainer.svelte"; import TitledContainer from "./TitledContainer.svelte";
import Row from "./Row.svelte"; import SpinBoxRow from "./SpinBoxRow.svelte";
import Col from "./Col.svelte"; import CheckBoxRow from "./CheckBoxRow.svelte";
import HelpPopup from "./HelpPopup.svelte";
import SpinBox from "./SpinBox.svelte";
import CheckBox from "./CheckBox.svelte";
import RevertButton from "./RevertButton.svelte";
import type { DeckOptionsState } from "./lib"; import type { DeckOptionsState } from "./lib";
export let state: DeckOptionsState; export let state: DeckOptionsState;
@ -20,32 +15,21 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
</script> </script>
<TitledContainer title={tr.deckConfigTimerTitle()}> <TitledContainer title={tr.deckConfigTimerTitle()}>
<Row> <SpinBoxRow
<Col size={7}> bind:value={$config.capAnswerTimeToSecs}
{tr.deckConfigMaximumAnswerSecs()} defaultValue={defaults.capAnswerTimeToSecs}
<HelpPopup html={marked(tr.deckConfigMaximumAnswerSecsTooltip())} /> min={30}
</Col> max={600}
<Col size={5}> markdownTooltip={tr.deckConfigMaximumAnswerSecsTooltip()}
<SpinBox min={30} max={600} bind:value={$config.capAnswerTimeToSecs} /> >
<RevertButton {tr.deckConfigMaximumAnswerSecs()}
defaultValue={defaults.capAnswerTimeToSecs} </SpinBoxRow>
bind:value={$config.capAnswerTimeToSecs}
/>
</Col>
</Row>
<Row> <CheckBoxRow
<Col> bind:value={$config.showTimer}
<CheckBox bind:value={$config.showTimer}> defaultValue={defaults.showTimer}
{tr.schedulingShowAnswerTimer()} markdownTooltip={tr.deckConfigShowAnswerTimerTooltip()}
<HelpPopup html={marked(tr.deckConfigShowAnswerTimerTooltip())} /> >
</CheckBox> {tr.schedulingShowAnswerTimer()}
</Col> </CheckBoxRow>
<Col grow={false}>
<RevertButton
defaultValue={defaults.showTimer}
bind:value={$config.showTimer}
/>
</Col>
</Row>
</TitledContainer> </TitledContainer>