mirror of https://github.com/VERT-sh/VERT.git
feat: highlight current format in dropdown
This commit is contained in:
parent
c336d7d7a7
commit
608b7e7e70
|
@ -8,6 +8,7 @@
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
categories: Categories;
|
categories: Categories;
|
||||||
|
from?: string;
|
||||||
selected?: string;
|
selected?: string;
|
||||||
onselect?: (option: string) => void;
|
onselect?: (option: string) => void;
|
||||||
disabled?: boolean;
|
disabled?: boolean;
|
||||||
|
@ -15,6 +16,7 @@
|
||||||
|
|
||||||
let {
|
let {
|
||||||
categories,
|
categories,
|
||||||
|
from,
|
||||||
selected = $bindable(""),
|
selected = $bindable(""),
|
||||||
onselect,
|
onselect,
|
||||||
disabled,
|
disabled,
|
||||||
|
@ -109,19 +111,17 @@
|
||||||
|
|
||||||
const clickDropdown = () => {
|
const clickDropdown = () => {
|
||||||
open = !open;
|
open = !open;
|
||||||
if (open) {
|
if (!open) return;
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
if (dropdownMenu) {
|
if (!dropdownMenu) return;
|
||||||
const searchInput = dropdownMenu.querySelector(
|
const searchInput = dropdownMenu.querySelector(
|
||||||
"#format-search",
|
"#format-search",
|
||||||
) as HTMLInputElement;
|
) as HTMLInputElement;
|
||||||
if (searchInput) {
|
if (searchInput) {
|
||||||
searchInput.focus();
|
searchInput.focus();
|
||||||
searchInput.select();
|
searchInput.select();
|
||||||
}
|
}
|
||||||
}
|
}, 0); // let dropdown open first
|
||||||
}, 0); // let dropdown open first
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
onMount(() => {
|
onMount(() => {
|
||||||
|
@ -156,7 +156,7 @@
|
||||||
bind:this={dropdown}
|
bind:this={dropdown}
|
||||||
>
|
>
|
||||||
<button
|
<button
|
||||||
class="relative flex items-center justify-center w-full font-display px-3 py-3.5 bg-button rounded-full overflow-hidden cursor-pointer focus:!outline-none
|
class="relative flex items-center justify-center w-full font-display px-3 py-3.5 bg-button rounded-full overflow-hidden cursor-pointer focus:!outline-none
|
||||||
{disabled ? 'opacity-50 cursor-auto' : 'cursor-pointer'}"
|
{disabled ? 'opacity-50 cursor-auto' : 'cursor-pointer'}"
|
||||||
onclick={() => clickDropdown()}
|
onclick={() => clickDropdown()}
|
||||||
onmouseenter={() => (hover = true)}
|
onmouseenter={() => (hover = true)}
|
||||||
|
@ -252,7 +252,8 @@
|
||||||
class="w-full p-2 text-center rounded-xl
|
class="w-full p-2 text-center rounded-xl
|
||||||
{format === selected
|
{format === selected
|
||||||
? 'bg-accent text-black'
|
? 'bg-accent text-black'
|
||||||
: 'hover:bg-panel'}"
|
: 'hover:bg-panel'}
|
||||||
|
{format === from ? 'bg-separator' : ''}"
|
||||||
onclick={() => selectOption(format)}
|
onclick={() => selectOption(format)}
|
||||||
>
|
>
|
||||||
{format}
|
{format}
|
||||||
|
|
|
@ -13,7 +13,6 @@
|
||||||
showGradient,
|
showGradient,
|
||||||
vertdLoaded,
|
vertdLoaded,
|
||||||
} from "$lib/store/index.svelte";
|
} from "$lib/store/index.svelte";
|
||||||
import { addToast } from "$lib/store/ToastProvider";
|
|
||||||
import { VertFile } from "$lib/types";
|
import { VertFile } from "$lib/types";
|
||||||
import {
|
import {
|
||||||
AudioLines,
|
AudioLines,
|
||||||
|
@ -247,6 +246,7 @@
|
||||||
>
|
>
|
||||||
<FormatDropdown
|
<FormatDropdown
|
||||||
{categories}
|
{categories}
|
||||||
|
from={file.from}
|
||||||
bind:selected={file.to}
|
bind:selected={file.to}
|
||||||
onselect={(option) => handleSelect(option, file)}
|
onselect={(option) => handleSelect(option, file)}
|
||||||
/>
|
/>
|
||||||
|
|
Loading…
Reference in New Issue