Skip to content

Instantly share code, notes, and snippets.

@cap340
cap340 / Popover.html.twig
Last active October 8, 2025 03:31
Symfony UX Live Component Popover
<div
{{ attributes.defaults(stimulus_controller('popover')) }}
data-live-name="{{ this.key }}"
>
<button
data-popover-target="trigger"
type="button"
aria-haspopup="dialog"
aria-expanded="{{ this.open ? 'true' : 'false' }}"
aria-controls="{{ this.key }}"
@cap340
cap340 / debounce.ts
Last active October 15, 2025 03:47
A typescript simple debounce function
/**
* @example
* ```ts
* const textInput = document.querySelector<HTMLInputElement>('input[type="text"]');
* textInput.addEventListener('keydown', debounce(fetchSuggestions, 300));
* ```
*
* @param {T} callback - The callback function to be debounced.
* @param number delay - the delay in milliseconds
*/