Sha256: ee803503c18e2e12646bd15de2f090eda86f1017459b905d7b665c5152f65f87

Contents?: true

Size: 1.33 KB

Versions: 22

Compression:

Stored size: 1.33 KB

Contents

import type { Application } from "@hotwired/stimulus";
import { ModalPresenter } from "./modal";
import { PopoverPresenter } from "./popover";
import { Consent } from "./consent";
import RemoteNavigationController from "./controllers/remote-navigation";
import ConsentController from "./controllers/consent";
import AnalyticsController from "./controllers/analytics";
import "./touch";

export { registerServiceWorker } from "./serviceworker";
export { currentLocale } from "./locale";

declare global {
  interface Window {
    ui?: {
      modal: ModalPresenter;
      popover: PopoverPresenter;
      consent: Consent;
    };
  }
}

window.ui = {
  modal: new ModalPresenter(),
  popover: new PopoverPresenter(),
  consent: new Consent(),
};

function createRemoteDestination(): void {
  if (document.getElementById("shimmer")) {
    return;
  }
  const root = document.createElement("div");
  root.id = "shimmer";
  document.body.append(root);
}

export async function start({
  application,
}: {
  application: Application;
}): Promise<void> {
  window.addEventListener("turbo:load", createRemoteDestination);
  createRemoteDestination();
  application.register("remote-navigation", RemoteNavigationController);
  application.register("consent", ConsentController);
  application.register("analytics", AnalyticsController);
}

export const ui = window.ui;

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
shimmer-0.0.21 src/index.ts
shimmer-0.0.20 src/index.ts