anki/ts/change-notetype/ChangeNotetypePage.svelte
Matthias Metelka 68092082f2
Change Notetype UI Rework (#1499)
* 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
2021-11-24 12:09:55 +10:00

58 lines
1.8 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 marked from "marked";
import { ChangeNotetypeState, MapContext } from "./lib";
import Container from "../components/Container.svelte";
import Row from "../components/Row.svelte";
import Col from "../components/Col.svelte";
import NotetypeSelector from "./NotetypeSelector.svelte";
import StickyNav from "./StickyNav.svelte";
import Mapper from "./Mapper.svelte";
import Spacer from "../components/Spacer.svelte";
export let state: ChangeNotetypeState;
$: info = state.info;
let offset: number;
</script>
<div bind:offsetHeight={offset}>
<NotetypeSelector {state} />
<Spacer --height="1em" />
</div>
<div id="scrollArea" style="--offset: {offset}px; --gutter-inline: 0.25rem;">
<Row class="gx-0" --cols={2}>
<Col --col-size={1} breakpoint="md">
<Container>
<StickyNav {state} ctx={MapContext.Field} />
<Mapper {state} ctx={MapContext.Field} />
</Container>
</Col>
<Col --col-size={1} breakpoint="md">
<Container>
<StickyNav {state} ctx={MapContext.Template} />
{#if $info.templates}
<Mapper {state} ctx={MapContext.Template} />
{:else}
<div>{@html marked(tr.changeNotetypeToFromCloze())}</div>
{/if}
</Container>
</Col>
</Row>
</div>
<style>
#scrollArea {
padding: 0;
overflow: hidden auto;
background: var(--pane-bg);
height: calc(100% - var(--offset));
border: 1px solid var(--medium-border);
border-radius: 0.25rem;
}
</style>