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">
|
2021-04-22 19:55:26 +02:00
|
|
|
import * as tr from "lib/i18n";
|
2021-04-25 10:40:02 +02:00
|
|
|
import type { DeckOptionsState, ConfigListEntry } from "./lib";
|
2021-04-12 06:18:30 +02:00
|
|
|
import OptionsDropdown from "./OptionsDropdown.svelte";
|
|
|
|
|
2021-04-25 10:40:02 +02:00
|
|
|
export let state: DeckOptionsState;
|
2021-04-16 15:29:21 +02:00
|
|
|
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})`;
|
|
|
|
}
|
|
|
|
|
2021-04-18 03:56:41 +02:00
|
|
|
function blur(this: HTMLSelectElement) {
|
2021-04-16 15:29:21 +02:00
|
|
|
state.setCurrentIndex(parseInt(this.value));
|
2021-04-12 06:18:30 +02:00
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss">
|
2021-04-22 07:39:50 +02:00
|
|
|
.sticky-bar {
|
|
|
|
position: sticky;
|
2021-04-12 06:18:30 +02:00
|
|
|
z-index: 1;
|
|
|
|
top: 0;
|
|
|
|
color: var(--text-fg);
|
|
|
|
background: var(--window-bg);
|
2021-04-22 07:39:50 +02:00
|
|
|
padding-bottom: 0.5em;
|
2021-04-22 11:53:07 +02:00
|
|
|
padding-top: 0.5em;
|
2021-04-12 06:18:30 +02:00
|
|
|
}
|
|
|
|
|
2021-04-22 07:39:50 +02:00
|
|
|
.selector-grid {
|
2021-04-18 05:02:33 +02:00
|
|
|
display: grid;
|
2021-04-22 07:39:50 +02:00
|
|
|
grid-template-columns: 6fr 1fr;
|
2021-04-22 03:33:27 +02:00
|
|
|
grid-column-gap: 0.5em;
|
2021-04-22 07:39:50 +02:00
|
|
|
padding-right: 0.5em;
|
2021-04-17 04:53:59 +02:00
|
|
|
}
|
2021-04-12 06:18:30 +02:00
|
|
|
</style>
|
|
|
|
|
2021-04-22 07:39:50 +02:00
|
|
|
<div class="sticky-bar">
|
|
|
|
<div>{tr.actionsOptionsFor({ val: state.currentDeck.name })}</div>
|
2021-04-17 04:53:59 +02:00
|
|
|
|
2021-04-22 07:39:50 +02:00
|
|
|
<div class="selector-grid">
|
|
|
|
<!-- svelte-ignore a11y-no-onchange -->
|
|
|
|
<select class="form-select" on:change={blur}>
|
|
|
|
{#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-22 07:39:50 +02:00
|
|
|
<OptionsDropdown {state} />
|
2021-04-12 06:18:30 +02:00
|
|
|
</div>
|
|
|
|
</div>
|