Sha256: 8377f89381a54619ee18e60393bb78692e1421a0e51cbe4a764f4c756622be74

Contents?: true

Size: 1.59 KB

Versions: 7

Compression:

Stored size: 1.59 KB

Contents

import UIDialog from "controllers/ui/dialog_controller";
import "https://ga.jspm.io/npm:@kanety/stimulus-static-actions@1.0.1/dist/index.modern.js";

export default class extends UIDialog {
  // Handles a button triggering the sheet in a different
  // controller instance
  // REFACTOR: This is the toggle method in dialog_controller with dom elements
  // instead of targets. Update the method there to receive dom elements and this
  // can be refactored to use those methods instead of reimplementing.
  toggleOutlet() {
    const sheetTarget = document.querySelector(this.element.dataset.UiSheetOutlet);
    const dialogTarget = sheetTarget.querySelector("[data-ui--sheet-target='dialog']");
    const modalTarget = sheetTarget.querySelector("[data-ui--sheet-target='modal']");
    const contentTarget = sheetTarget.querySelector("[data-ui--sheet-target='content']");
    const visible = dialogTarget.dataset.state == "closed" ? false : true;
    const mainTarget = document.body;
    if (!visible) {
      document.body.classList.add("overflow-hidden");
      contentTarget.classList.add("overflow-y-scroll", "h-full");
      dialogTarget.classList.remove("hidden");
      dialogTarget.dataset.state = "open";
      modalTarget.classList.remove("hidden");
      modalTarget.dataset.state = "open";
    } else {
      document.body.classList.remove("overflow-hidden");
      contentTarget.classList.remove("overflow-y-scroll", "h-full");
      dialogTarget.classList.add("hidden");
      dialogTarget.dataset.state = "closed";
      modalTarget.classList.add("hidden");
      modalTarget.dataset.state = "closed";
    }
  }
}

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
shadcn-ui-0.0.15 app/javascript/controllers/ui/sheet_controller.js
shadcn-ui-0.0.14 app/javascript/controllers/ui/sheet_controller.js
shadcn-ui-0.0.13 app/javascript/controllers/ui/sheet_controller.js
shadcn-ui-0.0.12 app/javascript/controllers/ui/sheet_controller.js
shadcn-ui-0.0.10 app/javascript/controllers/ui/sheet_controller.js
shadcn-ui-0.0.8 app/javascript/controllers/ui/sheet_controller.js
shadcn-ui-0.0.5 app/javascript/controllers/ui/sheet_controller.js