Sha256: ff25501d3b42b433d2a560fd308fc6d3920b4ded796f4eb52d3572af4a6f2aae

Contents?: true

Size: 842 Bytes

Versions: 13

Compression:

Stored size: 842 Bytes

Contents

import config from "../config";

export default function createSidebarStore(Alpine) {
  const { defaultWidth, minWidth, maxWidth } = config.sidebar;
  return {
    openDesktop: Alpine.$persist(true).as("sidebar-open-desktop"),
    openMobile: Alpine.$persist(false).as("sidebar-open-mobile"),
    width: Alpine.$persist(defaultWidth).as("sidebar-width"),
    panelSplits: Alpine.$persist([1.0, 1.0]).as(`sidebar-panel-splits`),
    minWidth,
    maxWidth,
    get open() {
      return Alpine.store("sidebar")[
        Alpine.store("layout").desktop ? "openDesktop" : "openMobile"
      ];
    },
    toggle() {
      const sidebar = Alpine.store("sidebar");
      if (Alpine.store("layout").desktop) {
        sidebar.openDesktop = !sidebar.openDesktop;
      } else {
        sidebar.openMobile = !sidebar.openMobile;
      }
    },
  };
}

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
lookbook-0.9.8 app/assets/lookbook/js/stores/sidebar.js
lookbook-0.9.7 app/assets/lookbook/js/stores/sidebar.js
lookbook-0.9.6 app/assets/lookbook/js/stores/sidebar.js
lookbook-0.9.5 app/assets/lookbook/js/stores/sidebar.js
lookbook-0.9.4 app/assets/lookbook/js/stores/sidebar.js
lookbook-0.9.3 app/assets/lookbook/js/stores/sidebar.js
lookbook-0.9.2 app/assets/lookbook/js/stores/sidebar.js
lookbook-0.9.1 app/assets/lookbook/js/stores/sidebar.js
lookbook-0.9.0 app/assets/lookbook/js/stores/sidebar.js
lookbook-0.8.3 app/assets/lookbook/js/stores/sidebar.js
lookbook-0.8.2 app/assets/lookbook/js/stores/sidebar.js
lookbook-0.8.1 app/assets/lookbook/js/stores/sidebar.js
lookbook-0.8.0 app/assets/lookbook/js/stores/sidebar.js