|
| 1 | +<!-- |
| 2 | +Copyright: Ankitects Pty Ltd and contributors |
| 3 | +License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html |
| 4 | +--> |
| 5 | +<script lang="ts"> |
| 6 | + import { generate } from "./generate"; |
| 7 | + import StickyFooter from "./StickyFooter.svelte"; |
| 8 | + import Notes from "./Notes.svelte"; |
| 9 | + import type { Decks } from "../lib/proto"; |
| 10 | + import MasksEditor from "./MasksEditor.svelte"; |
| 11 | + import Container from "../components/Container.svelte"; |
| 12 | + import * as tr from "@tslib/ftl"; |
| 13 | +
|
| 14 | + export let path: string; |
| 15 | + export let data: string; |
| 16 | + export let deckNameIds: Decks.DeckNameId[]; |
| 17 | + export let deckId: number | null; |
| 18 | +
|
| 19 | + async function hideAllGuessOne(): Promise<void> { |
| 20 | + generate(path, "hidden", deckId!); |
| 21 | + } |
| 22 | +
|
| 23 | + async function hideOneGuessOne(): Promise<void> { |
| 24 | + generate(path, "shown", deckId!); |
| 25 | + } |
| 26 | +
|
| 27 | + let items = [ |
| 28 | + { label: tr.editingMasks(), value: 1 }, |
| 29 | + { label: tr.editingNotes(), value: 2 }, |
| 30 | + ]; |
| 31 | +
|
| 32 | + let activeTabValue = 1; |
| 33 | + const tabChange = (tabValue) => () => (activeTabValue = tabValue); |
| 34 | +</script> |
| 35 | + |
| 36 | +<Container class="image-occlusion"> |
| 37 | + <ul> |
| 38 | + {#each items as item} |
| 39 | + <li class={activeTabValue === item.value ? "active" : ""}> |
| 40 | + <span on:click={tabChange(item.value)}>{item.label}</span> |
| 41 | + </li> |
| 42 | + {/each} |
| 43 | + </ul> |
| 44 | + |
| 45 | + <div hidden={activeTabValue != 1}> |
| 46 | + <MasksEditor {path} {data} /> |
| 47 | + </div> |
| 48 | + |
| 49 | + <div hidden={activeTabValue != 2}> |
| 50 | + <Notes {deckNameIds} bind:deckId /> |
| 51 | + <StickyFooter {hideAllGuessOne} {hideOneGuessOne} /> |
| 52 | + </div> |
| 53 | +</Container> |
| 54 | + |
| 55 | +<style lang="scss"> |
| 56 | + :global(.image-occlusion) { |
| 57 | + --gutter-inline: 0.5rem; |
| 58 | +
|
| 59 | + :global(.row) { |
| 60 | + // rows have negative margins by default |
| 61 | + --bs-gutter-x: 0; |
| 62 | + // ensure equal spacing between tall rows like |
| 63 | + // dropdowns, and short rows like checkboxes |
| 64 | + min-height: 2.5em; |
| 65 | + align-items: center; |
| 66 | + } |
| 67 | +
|
| 68 | + :global(.col) { |
| 69 | + // cols have negative margins by default |
| 70 | + --bs-gutter-x: 0; |
| 71 | + padding: unset !important; |
| 72 | + } |
| 73 | + } |
| 74 | + ul { |
| 75 | + display: flex; |
| 76 | + flex-wrap: wrap; |
| 77 | + padding-left: 0; |
| 78 | + list-style: none; |
| 79 | + border-bottom: 1px solid #dee2e6; |
| 80 | + } |
| 81 | + li { |
| 82 | + margin-bottom: -1px; |
| 83 | + } |
| 84 | +
|
| 85 | + span { |
| 86 | + border: 1px solid transparent; |
| 87 | + border-top-left-radius: 0.25rem; |
| 88 | + border-top-right-radius: 0.25rem; |
| 89 | + display: block; |
| 90 | + padding: 0.5rem 1rem; |
| 91 | + cursor: pointer; |
| 92 | + } |
| 93 | +
|
| 94 | + span:hover { |
| 95 | + border-color: #e9ecef #e9ecef #dee2e6; |
| 96 | + } |
| 97 | +
|
| 98 | + li.active > span { |
| 99 | + color: #495057; |
| 100 | + background-color: #fff; |
| 101 | + border-color: #dee2e6 #dee2e6 #fff; |
| 102 | + } |
| 103 | +</style> |
0 commit comments