All files / src/stores drawer.store.ts

100% Statements 9/9
100% Branches 4/4
100% Functions 4/4
100% Lines 9/9

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24      6x   6x 7x   7x   7x     2x       7x 5x     7x    
import { computed, ref } from 'vue';
import { defineStore } from 'pinia';
 
const DEFAULT_NAV_ITEM = 'home';
 
export const useDrawerStore = defineStore('drawer', () => {
  const _activeDrawer = ref<string>(DEFAULT_NAV_ITEM);
 
  const activeDrawer = computed<string>({
    get(): string {
      return _activeDrawer.value;
    },
    set(value: string): void {
      _activeDrawer.value = value || DEFAULT_NAV_ITEM;
    },
  });
 
  const isOpen = computed(() => {
    return !!activeDrawer.value && activeDrawer.value !== DEFAULT_NAV_ITEM;
  });
 
  return { activeDrawer, isOpen };
});