2021-04-12 06:18:30 +02:00
|
|
|
<!--
|
|
|
|
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 "anki/i18n";
|
2021-04-16 15:29:21 +02:00
|
|
|
import type { DeckConfigState, ConfigListEntry } from "./lib";
|
2021-04-12 06:18:30 +02:00
|
|
|
import OptionsDropdown from "./OptionsDropdown.svelte";
|
|
|
|
|
2021-04-16 15:29:21 +02:00
|
|
|
export let state: DeckConfigState;
|
|
|
|
let configList = state.configList;
|
2021-04-12 06:18:30 +02:00
|
|
|
|
2021-04-16 15:29:21 +02:00
|
|
|
function configLabel(entry: ConfigListEntry): string {
|
|
|
|
const count = tr.deckConfigUsedByDecks({ decks: entry.useCount });
|
|
|
|
return `${entry.name} (${count})`;
|
|
|
|
}
|
|
|
|
|
|
|
|
function myblur(this: HTMLSelectElement) {
|
|
|
|
state.setCurrentIndex(parseInt(this.value));
|
2021-04-12 06:18:30 +02:00
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss">
|
|
|
|
.form-select {
|
|
|
|
display: inline-block;
|
2021-04-17 16:01:53 +02:00
|
|
|
width: 70%;
|
2021-04-12 06:18:30 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
.outer {
|
|
|
|
position: fixed;
|
|
|
|
z-index: 1;
|
|
|
|
top: 0;
|
|
|
|
left: 0;
|
|
|
|
width: 100%;
|
|
|
|
color: var(--text-fg);
|
|
|
|
background: var(--window-bg);
|
|
|
|
padding: 0.5em;
|
2021-04-17 16:01:53 +02:00
|
|
|
display: flex;
|
|
|
|
justify-content: center;
|
2021-04-12 06:18:30 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
.inner {
|
|
|
|
display: flex;
|
2021-04-17 16:01:53 +02:00
|
|
|
flex-wrap: wrap;
|
|
|
|
width: 35em;
|
2021-04-12 06:18:30 +02:00
|
|
|
|
|
|
|
& > :global(*) {
|
|
|
|
padding-left: 0.5em;
|
|
|
|
padding-right: 0.5em;
|
|
|
|
}
|
|
|
|
}
|
2021-04-17 04:53:59 +02:00
|
|
|
|
|
|
|
.padding {
|
2021-04-17 16:01:53 +02:00
|
|
|
height: 3em;
|
2021-04-17 04:53:59 +02:00
|
|
|
}
|
2021-04-12 06:18:30 +02:00
|
|
|
</style>
|
|
|
|
|
|
|
|
<div class="outer">
|
|
|
|
<div class="inner">
|
2021-04-17 16:01:53 +02:00
|
|
|
<div>{tr.actionsOptionsFor({ val: state.currentDeck.name })}</div>
|
2021-04-17 04:53:59 +02:00
|
|
|
|
2021-04-17 16:01:53 +02:00
|
|
|
<!-- svelte-ignore a11y-no-onchange -->
|
|
|
|
<select class="form-select" on:change={myblur}>
|
|
|
|
{#each $configList as entry}
|
|
|
|
<option value={entry.idx} selected={entry.current}>
|
|
|
|
{configLabel(entry)}
|
|
|
|
</option>
|
|
|
|
{/each}
|
|
|
|
</select>
|
2021-04-12 06:18:30 +02:00
|
|
|
|
2021-04-17 16:01:53 +02:00
|
|
|
<OptionsDropdown {state} />
|
2021-04-12 06:18:30 +02:00
|
|
|
</div>
|
|
|
|
</div>
|
2021-04-17 04:53:59 +02:00
|
|
|
|
|
|
|
<div class="padding">
|
|
|
|
<!-- make sure subsequent content doesn't flow under us -->
|
|
|
|
</div>
|