diff --git a/plugins/soundboardHotkeys/components/addModal.jsx b/plugins/soundboardHotkeys/components/addModal.jsx index 07874c5..3e92198 100644 --- a/plugins/soundboardHotkeys/components/addModal.jsx +++ b/plugins/soundboardHotkeys/components/addModal.jsx @@ -4,9 +4,10 @@ const { plugin: { store }, } = shelter; -import { registerKeybind, unregisterKeybind } from "../utils"; +import { registerKeybind } from "../utils"; import { KeybindCapture } from "./keybinds"; import { SoundPicker } from "./soundPicker"; + import classes from "./style.scss"; export function AddKeybindModal(closeModal, initialState) { @@ -22,7 +23,7 @@ export function AddKeybindModal(closeModal, initialState) { } return ( - + Adding keybind
{isCapturing() ? "Click again to stop" : "Click to capture keybind"}
- + -
-
Keybinds
- -
-
{(keybind) => }
diff --git a/plugins/soundboardHotkeys/components/soundPicker.jsx b/plugins/soundboardHotkeys/components/soundPicker.jsx index f257b38..b39d7f2 100644 --- a/plugins/soundboardHotkeys/components/soundPicker.jsx +++ b/plugins/soundboardHotkeys/components/soundPicker.jsx @@ -1,14 +1,19 @@ const { - ui: { Header, HeaderTags, Text }, + ui: { Header, HeaderTags, TextBox, Text, focusring }, flux: { stores: { SoundboardStore }, }, - solid: { For }, + solid: { For, createSignal }, } = shelter; import { SoundWithEmoji } from "./soundPreview"; import classes from "./style.scss"; +export function search(sounds, query) { + if (!query) return sounds; + return sounds.filter((sound) => sound.name.toLowerCase().includes(query.toLowerCase())); +} + export function SoundPicker(props) { const sounds = () => { return [...SoundboardStore.getSounds()] @@ -17,27 +22,35 @@ export function SoundPicker(props) { .sort((a, b) => SoundboardStore.isFavoriteSound(b.soundId) - SoundboardStore.isFavoriteSound(a.soundId)); }; + const [query, setQuery] = createSignal(""); + + const filteredSounds = () => search(sounds(), query()); + return (
Sound
+ setQuery(e)} />
- + + ❌ No sounds found + + {(sound) => ( -
e.key === "Enter" && props.setSoundId(sound.soundId)} - onClick={() => props.setSoundId(sound.soundId)} + onKeyPress={(e) => + e.key === "Enter" && e.target.name !== "preview" && props.setSoundId(sound.soundId) + } + onClick={(e) => e.target.name !== "preview" && props.setSoundId(sound.soundId)} + use:focusring > sound.soundId === props.soundId()} /> -
+ )}
- - Can't find the sound you want? Open the soundboard manually to sort favorites before others. -
); } diff --git a/plugins/soundboardHotkeys/components/soundPreview.jsx b/plugins/soundboardHotkeys/components/soundPreview.jsx index 11c4d9c..8c9717b 100644 --- a/plugins/soundboardHotkeys/components/soundPreview.jsx +++ b/plugins/soundboardHotkeys/components/soundPreview.jsx @@ -1,5 +1,5 @@ const { - ui: { Text }, + ui: { Text, focusring }, flux: { stores: { SoundboardStore, EmojiStore }, }, @@ -15,11 +15,13 @@ export function Preview({ soundId }) {