Sha256: 854e2b0be1fcf23e5bd803521ded2080c7b7e17229a2087bbcb265b732a0bf4f

Contents?: true

Size: 1.9 KB

Versions: 2

Compression:

Stored size: 1.9 KB

Contents

import Alpine from "alpinejs";

import Morph from "@alpinejs/morph";
import Persist from "@alpinejs/persist";
import Collapse from "@alpinejs/morph";
import Tooltip from "@ryangjchandler/alpine-tooltip";

import Logger, { log } from "./plugins/logger";

import initLayoutStore from "./stores/layout";
import initNavStore from "./stores/nav";
import initInspectorStore from "./stores/inspector";
import initPagesStore from "./stores/pages";
import initSettingsStore from "./stores/settings";
import initWorkbenchStore from "./stores/workbench";

import app from "./app";

// Note: A ParcelJS issue prevents loading all depths of component JS files in one glob,
// so need to split it up. Path aliases also do not work with the glob imports.
import { getComponents } from "./helpers/build";
import * as components from "../../../components/lookbook/*/*component.js";
import * as subComponents from "../../../components/lookbook/*/*/component.js";
import * as jsComponents from "./components/*.js";

// Plugins

Alpine.plugin(Morph);
Alpine.plugin(Persist);
Alpine.plugin(Collapse);
Alpine.plugin(Tooltip);
Alpine.plugin(Logger);

// Stores
const prefix = window.APP_NAME;
Alpine.store("layout", initLayoutStore(Alpine, { prefix }));
Alpine.store("nav", initNavStore(Alpine, { prefix }));
Alpine.store("inspector", initInspectorStore(Alpine, { prefix }));
Alpine.store("pages", initPagesStore(Alpine, { prefix }));
Alpine.store("settings", initSettingsStore(Alpine, { prefix }));

if (process.env.NODE_ENV !== "production") {
  Alpine.store("workbench", initWorkbenchStore(Alpine, { prefix }));
}

// Components

Alpine.data("app", app);

[components, subComponents, jsComponents].forEach((scripts) => {
  const components = getComponents(scripts);
  Object.keys(components).forEach((name) => {
    console.log(name);
    Alpine.data(`${name}Component`, components[name]);
  });
});

// Init

window.log = log;
window.Alpine = Alpine;
Alpine.start();

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
lookbook-1.1.1 app/assets/lookbook/js/lookbook.js
lookbook-1.1.0 app/assets/lookbook/js/lookbook.js