IKHSAN
EN Read in EnglishID

opendesk

Publik
Branch
main
Commit terakhir
08d9f3328 Oktober 2026

sidebar.ts

Buka raw
import { useStorage } from "@vueuse/core";
import { defineStore } from "pinia";
import { computed, ref } from "vue";

export const useSidebarStore = defineStore("sidebar", () => {
  const isOpen = ref(true);
  const isExpanded = useStorage("sidebar_is_expanded", true);
  // Match frappe-ui Sidebar's width/collapsedWidth props (15rem/3rem),
  // since the notifications panel anchors against this value.
  const width = computed(() => {
    return isExpanded.value ? "15rem" : "3rem";
  });

  function toggle(state?: boolean) {
    isOpen.value = state ?? !isOpen.value;
  }

  function toggleExpanded(state?: boolean) {
    isExpanded.value = state ?? !isExpanded.value;
  }

  return {
    isExpanded,
    isOpen,
    toggle,
    toggleExpanded,
    width,
  };
});
byte
770
baris
30
Jenis
ts
Commit terakhir
28 Oktober 2026