anki/ts/components/ButtonDropdown.svelte

47 lines
1.0 KiB
Svelte
Raw Normal View History

2021-04-15 15:59:52 +02:00
<!--
Copyright: Ankitects Pty Ltd and contributors
License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
-->
<script lang="typescript">
2021-04-28 22:15:24 +02:00
import { setContext } from "svelte";
import { dropdownKey } from "./contextKeys";
2021-05-06 23:04:38 +02:00
import ButtonToolbar from "./ButtonToolbar.svelte";
export let id: string;
2021-04-28 22:15:24 +02:00
let className = "";
export { className as class };
2021-05-06 23:04:38 +02:00
export let api: Record<string, unknown> | undefined = undefined;
2021-04-28 22:15:24 +02:00
setContext(dropdownKey, null);
</script>
<ButtonToolbar
{id}
class={`dropdown-menu btn-dropdown-menu ${className}`}
wrap={false}
{api}
>
<slot />
</ButtonToolbar>
2021-05-06 23:04:38 +02:00
<style lang="scss">
:global(.dropdown-menu.btn-dropdown-menu) {
display: none;
2021-05-06 23:04:38 +02:00
min-width: 0;
padding: calc(var(--buttons-size) / 10) 0;
2021-05-06 23:04:38 +02:00
2021-04-16 17:14:47 +02:00
background-color: var(--window-bg);
border-color: var(--medium-border);
2021-05-06 23:04:38 +02:00
:global(.btn-group) {
position: static;
}
2021-04-16 17:14:47 +02:00
}
:global(.dropdown-menu.btn-dropdown-menu.show) {
display: flex;
}
2021-04-16 17:14:47 +02:00
</style>