anki/ts/components/ConfigInput.svelte
Damien Elmes 97f43fbd45 Further speed up deck options load
Profiling revealed that binding to clientWidth for each component in
the deck options was taking up a sizable amount of time, due to the
inefficient way it's implemented: https://github.com/sveltejs/svelte/issues/7583

In one case, we can instead defer checking clientWidth until we go to
display the popover. In the other case, we can achieve the revert button
positioning a different way.

The last change dropped the speed index in Chrome from 1.4s to 1s; this
change brings it down to 0.7s.

Also fixed the hovered select element from jiggling due to a different
border width when hovering.
2023-12-08 15:10:35 +10:00

44 lines
938 B
Svelte

<!--
Copyright: Ankitects Pty Ltd and contributors
License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
-->
<script lang="ts">
const rtl: boolean = window.getComputedStyle(document.body).direction == "rtl";
export let grow = true;
</script>
<div
class="config-input position-relative justify-content-end"
class:flex-grow-1={grow}
>
<div class="revert" class:rtl>
<slot name="revert" />
</div>
<slot />
</div>
<style lang="scss">
.revert {
position: absolute;
right: -1.7em;
bottom: -1px;
color: var(--fg-faint);
&.rtl {
right: unset;
left: var(--offset);
}
}
.config-input {
&:hover,
&:focus-within {
.revert {
color: var(--fg-subtle);
}
}
.revert:hover {
color: var(--fg);
}
}
</style>