mirror of
https://github.com/ankitects/anki.git
synced 2025-09-25 01:06:35 -04:00
Implement Switch and SwitchRow
This commit is contained in:
parent
9a00ef5a81
commit
728e2e682b
5 changed files with 66 additions and 13 deletions
|
@ -6,7 +6,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
||||||
import * as tr from "lib/i18n";
|
import * as tr from "lib/i18n";
|
||||||
import TitledContainer from "./TitledContainer.svelte";
|
import TitledContainer from "./TitledContainer.svelte";
|
||||||
import Item from "components/Item.svelte";
|
import Item from "components/Item.svelte";
|
||||||
import CheckBoxRow from "./CheckBoxRow.svelte";
|
import SwitchRow from "./SwitchRow.svelte";
|
||||||
import type { DeckOptionsState } from "./lib";
|
import type { DeckOptionsState } from "./lib";
|
||||||
|
|
||||||
export let state: DeckOptionsState;
|
export let state: DeckOptionsState;
|
||||||
|
@ -18,21 +18,21 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
||||||
|
|
||||||
<TitledContainer title={tr.deckConfigAudioTitle()} {api}>
|
<TitledContainer title={tr.deckConfigAudioTitle()} {api}>
|
||||||
<Item>
|
<Item>
|
||||||
<CheckBoxRow
|
<SwitchRow
|
||||||
bind:value={$config.disableAutoplay}
|
bind:value={$config.disableAutoplay}
|
||||||
defaultValue={defaults.disableAutoplay}
|
defaultValue={defaults.disableAutoplay}
|
||||||
>
|
>
|
||||||
{tr.deckConfigDisableAutoplay()}
|
{tr.deckConfigDisableAutoplay()}
|
||||||
</CheckBoxRow>
|
</SwitchRow>
|
||||||
</Item>
|
</Item>
|
||||||
|
|
||||||
<Item>
|
<Item>
|
||||||
<CheckBoxRow
|
<SwitchRow
|
||||||
bind:value={$config.skipQuestionWhenReplayingAnswer}
|
bind:value={$config.skipQuestionWhenReplayingAnswer}
|
||||||
defaultValue={defaults.skipQuestionWhenReplayingAnswer}
|
defaultValue={defaults.skipQuestionWhenReplayingAnswer}
|
||||||
markdownTooltip={tr.deckConfigAlwaysIncludeQuestionAudioTooltip()}
|
markdownTooltip={tr.deckConfigAlwaysIncludeQuestionAudioTooltip()}
|
||||||
>
|
>
|
||||||
{tr.schedulingAlwaysIncludeQuestionSideWhenReplaying()}
|
{tr.schedulingAlwaysIncludeQuestionSideWhenReplaying()}
|
||||||
</CheckBoxRow>
|
</SwitchRow>
|
||||||
</Item>
|
</Item>
|
||||||
</TitledContainer>
|
</TitledContainer>
|
||||||
|
|
|
@ -6,7 +6,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
||||||
import * as tr from "lib/i18n";
|
import * as tr from "lib/i18n";
|
||||||
import TitledContainer from "./TitledContainer.svelte";
|
import TitledContainer from "./TitledContainer.svelte";
|
||||||
import Item from "components/Item.svelte";
|
import Item from "components/Item.svelte";
|
||||||
import CheckBoxRow from "./CheckBoxRow.svelte";
|
import SwitchRow from "./SwitchRow.svelte";
|
||||||
import type { DeckOptionsState } from "./lib";
|
import type { DeckOptionsState } from "./lib";
|
||||||
|
|
||||||
export let state: DeckOptionsState;
|
export let state: DeckOptionsState;
|
||||||
|
@ -18,22 +18,22 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
||||||
|
|
||||||
<TitledContainer title={tr.deckConfigBuryTitle()} {api}>
|
<TitledContainer title={tr.deckConfigBuryTitle()} {api}>
|
||||||
<Item>
|
<Item>
|
||||||
<CheckBoxRow
|
<SwitchRow
|
||||||
bind:value={$config.buryNew}
|
bind:value={$config.buryNew}
|
||||||
defaultValue={defaults.buryNew}
|
defaultValue={defaults.buryNew}
|
||||||
markdownTooltip={tr.deckConfigBuryTooltip()}
|
markdownTooltip={tr.deckConfigBuryTooltip()}
|
||||||
>
|
>
|
||||||
{tr.deckConfigBuryNewSiblings()}
|
{tr.deckConfigBuryNewSiblings()}
|
||||||
</CheckBoxRow>
|
</SwitchRow>
|
||||||
</Item>
|
</Item>
|
||||||
|
|
||||||
<Item>
|
<Item>
|
||||||
<CheckBoxRow
|
<SwitchRow
|
||||||
bind:value={$config.buryReviews}
|
bind:value={$config.buryReviews}
|
||||||
defaultValue={defaults.buryReviews}
|
defaultValue={defaults.buryReviews}
|
||||||
markdownTooltip={tr.deckConfigBuryTooltip()}
|
markdownTooltip={tr.deckConfigBuryTooltip()}
|
||||||
>
|
>
|
||||||
{tr.deckConfigBuryReviewSiblings()}
|
{tr.deckConfigBuryReviewSiblings()}
|
||||||
</CheckBoxRow>
|
</SwitchRow>
|
||||||
</Item>
|
</Item>
|
||||||
</TitledContainer>
|
</TitledContainer>
|
||||||
|
|
26
ts/deckoptions/Switch.svelte
Normal file
26
ts/deckoptions/Switch.svelte
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
<!--
|
||||||
|
Copyright: Ankitects Pty Ltd and contributors
|
||||||
|
License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
||||||
|
-->
|
||||||
|
<script lang="ts">
|
||||||
|
export let value: boolean;
|
||||||
|
export let disabled = false;
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<div class="form-check form-switch">
|
||||||
|
<input class="form-check-input" type="checkbox" bind:checked={value} {disabled} />
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<style lang="scss">
|
||||||
|
.form-check-input {
|
||||||
|
-webkit-appearance: none;
|
||||||
|
height: 1.6em;
|
||||||
|
/* otherwise the switch circle shows slightly off-centered */
|
||||||
|
margin-top: 0;
|
||||||
|
|
||||||
|
.form-switch & {
|
||||||
|
width: 3em;
|
||||||
|
margin-left: 1.5em;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
27
ts/deckoptions/SwitchRow.svelte
Normal file
27
ts/deckoptions/SwitchRow.svelte
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
<!--
|
||||||
|
Copyright: Ankitects Pty Ltd and contributors
|
||||||
|
License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
||||||
|
-->
|
||||||
|
<script lang="ts">
|
||||||
|
import Row from "./Row.svelte";
|
||||||
|
import Col from "./Col.svelte";
|
||||||
|
import Label from "./Label.svelte";
|
||||||
|
import TooltipLabel from "./TooltipLabel.svelte";
|
||||||
|
import Switch from "./Switch.svelte";
|
||||||
|
import RevertButton from "./RevertButton.svelte";
|
||||||
|
|
||||||
|
export let value: boolean;
|
||||||
|
export let defaultValue: boolean;
|
||||||
|
export let markdownTooltip: string | undefined = undefined;
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<Row>
|
||||||
|
<Col>
|
||||||
|
{#if markdownTooltip}<TooltipLabel {markdownTooltip}><slot /></TooltipLabel
|
||||||
|
>{:else}<Label><slot /></Label>{/if}
|
||||||
|
</Col>
|
||||||
|
<Col grow={false}>
|
||||||
|
<Switch bind:value />
|
||||||
|
<RevertButton bind:value {defaultValue} />
|
||||||
|
</Col>
|
||||||
|
</Row>
|
|
@ -7,7 +7,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
||||||
import TitledContainer from "./TitledContainer.svelte";
|
import TitledContainer from "./TitledContainer.svelte";
|
||||||
import Item from "components/Item.svelte";
|
import Item from "components/Item.svelte";
|
||||||
import SpinBoxRow from "./SpinBoxRow.svelte";
|
import SpinBoxRow from "./SpinBoxRow.svelte";
|
||||||
import CheckBoxRow from "./CheckBoxRow.svelte";
|
import SwitchRow from "./SwitchRow.svelte";
|
||||||
import type { DeckOptionsState } from "./lib";
|
import type { DeckOptionsState } from "./lib";
|
||||||
|
|
||||||
export let state: DeckOptionsState;
|
export let state: DeckOptionsState;
|
||||||
|
@ -31,12 +31,12 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
||||||
</Item>
|
</Item>
|
||||||
|
|
||||||
<Item>
|
<Item>
|
||||||
<CheckBoxRow
|
<SwitchRow
|
||||||
bind:value={$config.showTimer}
|
bind:value={$config.showTimer}
|
||||||
defaultValue={defaults.showTimer}
|
defaultValue={defaults.showTimer}
|
||||||
markdownTooltip={tr.deckConfigShowAnswerTimerTooltip()}
|
markdownTooltip={tr.deckConfigShowAnswerTimerTooltip()}
|
||||||
>
|
>
|
||||||
{tr.schedulingShowAnswerTimer()}
|
{tr.schedulingShowAnswerTimer()}
|
||||||
</CheckBoxRow>
|
</SwitchRow>
|
||||||
</Item>
|
</Item>
|
||||||
</TitledContainer>
|
</TitledContainer>
|
||||||
|
|
Loading…
Reference in a new issue