Hide SM2-specific items in help pages when FSRS enabled

This commit is contained in:
Damien Elmes 2023-10-13 11:00:51 +10:00
parent f4b760153f
commit 8b4c57fbce
5 changed files with 32 additions and 6 deletions

View file

@ -15,12 +15,13 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
import HelpSection from "./HelpSection.svelte";
import { infoCircle, manualIcon } from "./icons";
import Row from "./Row.svelte";
import type { HelpItem } from "./types";
import { type HelpItem, HelpItemScheduler } from "./types";
export let title: string;
export let url: string;
export let startIndex = 0;
export let helpSections: HelpItem[];
export let fsrs = false;
export const modalKey: string = Math.random().toString(36).substring(2);
@ -93,7 +94,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
<nav>
<div id="nav">
<ul>
{#each helpSections as section, i}
{#each helpSections as item, i}
<li>
<button
on:click={() => {
@ -101,8 +102,13 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
carousel.to(activeIndex);
}}
class:active={i == activeIndex}
class:d-none={fsrs
? item.sched ===
HelpItemScheduler.SM2
: item.sched ==
HelpItemScheduler.FSRS}
>
{section.title}
{item.title}
</button>
</li>
{/each}
@ -121,6 +127,9 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
<div
class="carousel-item"
class:active={i == startIndex}
class:d-none={fsrs
? item.sched === HelpItemScheduler.SM2
: item.sched == HelpItemScheduler.FSRS}
>
<HelpSection {item} />
</div>

View file

@ -8,4 +8,10 @@ export type HelpItem = {
title: string;
help?: string;
url?: string;
sched?: HelpItemScheduler;
};
export enum HelpItemScheduler {
SM2 = 0,
FSRS = 1,
}

View file

@ -14,7 +14,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
import SettingTitle from "../components/SettingTitle.svelte";
import SwitchRow from "../components/SwitchRow.svelte";
import TitledContainer from "../components/TitledContainer.svelte";
import type { HelpItem } from "../components/types";
import { type HelpItem, HelpItemScheduler } from "../components/types";
import CardStateCustomizer from "./CardStateCustomizer.svelte";
import FsrsOptions from "./FsrsOptions.svelte";
import type { DeckOptionsState } from "./lib";
@ -40,26 +40,31 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
title: tr.schedulingStartingEase(),
help: tr.deckConfigStartingEaseTooltip(),
url: HelpPage.DeckOptions.startingEase,
sched: HelpItemScheduler.SM2,
},
easyBonus: {
title: tr.schedulingEasyBonus(),
help: tr.deckConfigEasyBonusTooltip(),
url: HelpPage.DeckOptions.easyBonus,
sched: HelpItemScheduler.SM2,
},
intervalModifier: {
title: tr.schedulingIntervalModifier(),
help: tr.deckConfigIntervalModifierTooltip(),
url: HelpPage.DeckOptions.intervalModifier,
sched: HelpItemScheduler.SM2,
},
hardInterval: {
title: tr.schedulingHardInterval(),
help: tr.deckConfigHardIntervalTooltip(),
url: HelpPage.DeckOptions.hardInterval,
sched: HelpItemScheduler.SM2,
},
newInterval: {
title: tr.schedulingNewInterval(),
help: tr.deckConfigNewIntervalTooltip(),
url: HelpPage.DeckOptions.newInterval,
sched: HelpItemScheduler.SM2,
},
customScheduling: {
title: tr.deckConfigCustomScheduling(),
@ -85,6 +90,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
title={tr.deckConfigAdvancedTitle()}
url={HelpPage.DeckOptions.advanced}
slot="tooltip"
fsrs={$fsrs}
{helpSections}
on:mount={(e) => {
modal = e.detail.modal;

View file

@ -14,7 +14,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
import Item from "../components/Item.svelte";
import SettingTitle from "../components/SettingTitle.svelte";
import TitledContainer from "../components/TitledContainer.svelte";
import type { HelpItem } from "../components/types";
import { type HelpItem, HelpItemScheduler } from "../components/types";
import { leechChoices } from "./choices";
import type { DeckOptionsState } from "./lib";
import SpinBoxRow from "./SpinBoxRow.svelte";
@ -54,6 +54,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
title: tr.schedulingMinimumInterval(),
help: tr.deckConfigMinimumIntervalTooltip(),
url: HelpPage.DeckOptions.minimumInterval,
sched: HelpItemScheduler.SM2,
},
leechThreshold: {
title: tr.schedulingLeechThreshold(),
@ -82,6 +83,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
title={tr.schedulingLapses()}
url={HelpPage.DeckOptions.lapses}
slot="tooltip"
fsrs={$fsrs}
{helpSections}
on:mount={(e) => {
modal = e.detail.modal;

View file

@ -15,7 +15,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
import Item from "../components/Item.svelte";
import SettingTitle from "../components/SettingTitle.svelte";
import TitledContainer from "../components/TitledContainer.svelte";
import type { HelpItem } from "../components/types";
import { type HelpItem, HelpItemScheduler } from "../components/types";
import { newInsertOrderChoices } from "./choices";
import type { DeckOptionsState } from "./lib";
import SpinBoxRow from "./SpinBoxRow.svelte";
@ -66,11 +66,13 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
title: tr.schedulingGraduatingInterval(),
help: tr.deckConfigGraduatingIntervalTooltip(),
url: HelpPage.DeckOptions.graduatingInterval,
sched: HelpItemScheduler.SM2,
},
easyInterval: {
title: tr.schedulingEasyInterval(),
help: tr.deckConfigEasyIntervalTooltip(),
url: HelpPage.DeckOptions.easyInterval,
sched: HelpItemScheduler.SM2,
},
insertionOrder: {
title: tr.deckConfigNewInsertionOrder(),
@ -95,6 +97,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
url={HelpPage.DeckOptions.newCards}
slot="tooltip"
{helpSections}
fsrs={$fsrs}
on:mount={(e) => {
modal = e.detail.modal;
carousel = e.detail.carousel;