anki/ts/components/DropdownItem.svelte
Matthias Metelka 23e6b2123e
Redesign deck options inputs (#2082)
* Create _input-mixins.scss

* Use button-mixins on more elements

* Replace <select> tag with custom Select component

* Fix RevertButton causing cursor: pointer when hidden

* Increase SaveButton chevron width

* Hide floating component box-shadow when inactive

* Rework SpinBox and move it into components

* Run eslint and prettier

* Remove leftover options prop

* Pass disabled array to EnumSelector again

* Update MapperRow.svelte

* Darken QHeaderView border color

Slipping this in without an extra PR.

* Adjust disabled color, border and cursor

* Remove redundant icon definition from stylesheets

* Fix deck options initial config

* Fix z-index issues in change notetype screen

It might be best to handle z-index locally in each user component instead of hard-coded component values.

* Give web SpinBox a horizontal design

* Give QRadioButton the same treatment as QCheckBox in #2079

* Fix unused CSS selector warning with base button-mixin

* Remove redundant import

* Fix deck options save button

* Delete input-mixins and remove unused down-arrow

* Run eslint on change-notetype

* Run eslint on components
2022-09-27 12:16:45 +10:00

66 lines
1.5 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">
export let id: string | undefined = undefined;
let className = "";
export { className as class };
export let buttonRef: HTMLButtonElement | undefined = undefined;
export let tooltip: string | undefined = undefined;
export let active = false;
export let disabled = false;
$: if (buttonRef && active) {
/* buttonRef.scrollIntoView({ behavior: "smooth", block: "start" }); */
/* TODO will not work on Gecko */
(buttonRef as any).scrollIntoViewIfNeeded({
behavior: "smooth",
block: "start",
});
}
export let tabbable = false;
</script>
<button
bind:this={buttonRef}
{id}
tabindex={tabbable ? 0 : -1}
class="dropdown-item {className}"
class:active
class:disabled
title={tooltip}
on:mouseenter
on:focus
on:keydown
on:click
on:mousedown|preventDefault
>
<slot />
</button>
<style lang="scss">
button {
display: flex;
justify-content: start;
width: 100%;
font-size: var(--dropdown-font-size, calc(0.8 * var(--base-font-size)));
background: none;
box-shadow: none !important;
border: none;
border-radius: 0;
color: var(--fg);
&:hover {
background: var(--highlight-bg);
color: var(--highlight-fg);
}
}
</style>