Skip to content

Instantly share code, notes, and snippets.

View clmrb's full-sized avatar
🏠
Doing things

clmrb

🏠
Doing things
View GitHub Profile
@clmrb
clmrb / tabActive.js
Created February 4, 2026 13:52
Vue3/Vuetify3 Javascript composable to detect when current component is inside an active vuetify tab
import { getCurrentInstance, watch } from 'vue';
function findComponentInstanceByName(instance, name) {
if (!instance?.parent) {
console.warn(`No parent component found with name "${name}"`);
return null;
}
if (instance.parent.type.name !== name) {
return findComponentInstanceByName(instance.parent, name);
@clmrb
clmrb / enum.js
Last active February 3, 2026 21:37
JavaScript enum function with working JSDoc autocompletion
/**
* @description
* Creates a frozen enumeration object where each key maps to its own string value.
* This is useful for defining a set of constant string values that can be referenced by name.
* This also avoids defining an object with duplicated string values manually.
* @template {string} T
* @param {...T} values
* @returns {{ [K in T]: K }}
* @example
* const Colors = Enum('Red', 'Green', 'Blue');