68092082f2
* Enable access to old notetype name * Set minimum height for ChangeNotetypeDialog * Add bootstrap icons to change-notetype * Move alert up and make it collapsible * Tweak some CSS - Add variables --sticky-bg and --sticky-border to StickyContainer - Tweak base.css * Add translatable string "(Nothing)" * Rework ChangeNotetype screen * Initially load option at newIndex and remaining options on focus Optimization for big notetypes: Should increase efficiency from O(n²) to O(n). Test on notetype with 500 templates shows significant improvement in load time (~10s down to ~1s). * Try to satisfy rust test * Change arrow direction depending on reading direction + add 0.5em top padding to main * Create Alert.svelte * Introduce CSS variable --pane-bg * Revert "Initially load option at newIndex and remaining options on focus" This reverts commit f42beee45c27dba9433d76217fb583b117fb5231. * Final cleanup * Refine padding/gutter
61 lines
1.6 KiB
Svelte
61 lines
1.6 KiB
Svelte
<!--
|
|
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 "../lib/ftl";
|
|
import Badge from "../components/Badge.svelte";
|
|
import { MapContext } from "./lib";
|
|
import { plusIcon, minusIcon } from "./icons";
|
|
import { slide } from "svelte/transition";
|
|
|
|
export let unused: string[];
|
|
export let ctx: MapContext;
|
|
|
|
let unusedMsg: string;
|
|
$: unusedMsg =
|
|
ctx === MapContext.Field
|
|
? tr.changeNotetypeWillDiscardContent()
|
|
: tr.changeNotetypeWillDiscardCards();
|
|
|
|
let maxItems: number = 3;
|
|
let collapsed: boolean = true;
|
|
$: collapseMsg = collapsed
|
|
? tr.changeNotetypeExpand()
|
|
: tr.changeNotetypeCollapse();
|
|
$: icon = collapsed ? plusIcon : minusIcon;
|
|
</script>
|
|
|
|
<div class="alert alert-warning" in:slide out:slide>
|
|
{#if unused.length > maxItems}
|
|
<div class="clickable" on:click={() => (collapsed = !collapsed)}>
|
|
<Badge iconSize={80}>
|
|
{@html icon}
|
|
</Badge>
|
|
{collapseMsg}
|
|
</div>
|
|
{/if}
|
|
{unusedMsg}
|
|
{#if collapsed}
|
|
<div>
|
|
{unused.slice(0, maxItems).join(", ")}
|
|
{#if unused.length > maxItems}
|
|
... (+{unused.length - maxItems})
|
|
{/if}
|
|
</div>
|
|
{:else}
|
|
<ul>
|
|
{#each unused as entry}
|
|
<li>{entry}</li>
|
|
{/each}
|
|
</ul>
|
|
{/if}
|
|
</div>
|
|
|
|
<style lang="scss">
|
|
.clickable {
|
|
cursor: pointer;
|
|
font-weight: bold;
|
|
}
|
|
</style>
|