Sha256: 7865672b5267331ab6a11b84184db18f7fb3260a3b06c6653ed688a340fb7eaa

Contents?: true

Size: 839 Bytes

Versions: 153

Compression:

Stored size: 839 Bytes

Contents

import { Controller } from "@hotwired/stimulus"
import { enter, leave } from "el-transition"

export default class extends Controller {
  static targets = [ "wrapper", "revealable"]
  static classes = [ "hidden" ] // necessary because we're always hiding the mobile menu on larger screens and this is the class used for only mobile screen sizes
  
  open() {
    this.showWrapper()
    this.revealableTargets.forEach(revealableTarget => {
      enter(revealableTarget)
    })
  }
  
  close() {
    Promise.all(
      this.revealableTargets.map(revealableTarget => {
        return leave(revealableTarget)
      })
    ).then(() => {
      this.hideWrapper()
    })
    
  }
  
  showWrapper() {
    this.wrapperTarget.classList.remove(this.hiddenClass)
  }
  
  hideWrapper() {
    this.wrapperTarget.classList.add(this.hiddenClass)
  }
}

Version data entries

153 entries across 153 versions & 1 rubygems

Version Path
bullet_train-1.4.7 app/javascript/controllers/mobile_menu_controller.js
bullet_train-1.4.6 app/javascript/controllers/mobile_menu_controller.js
bullet_train-1.4.5 app/javascript/controllers/mobile_menu_controller.js
bullet_train-1.4.4 app/javascript/controllers/mobile_menu_controller.js
bullet_train-1.4.3 app/javascript/controllers/mobile_menu_controller.js
bullet_train-1.4.2 app/javascript/controllers/mobile_menu_controller.js
bullet_train-1.4.1 app/javascript/controllers/mobile_menu_controller.js
bullet_train-1.4.0 app/javascript/controllers/mobile_menu_controller.js
bullet_train-1.3.25 app/javascript/controllers/mobile_menu_controller.js
bullet_train-1.3.24 app/javascript/controllers/mobile_menu_controller.js
bullet_train-1.3.23 app/javascript/controllers/mobile_menu_controller.js
bullet_train-1.3.22 app/javascript/controllers/mobile_menu_controller.js
bullet_train-1.3.21 app/javascript/controllers/mobile_menu_controller.js
bullet_train-1.3.20 app/javascript/controllers/mobile_menu_controller.js
bullet_train-1.3.19 app/javascript/controllers/mobile_menu_controller.js
bullet_train-1.3.18 app/javascript/controllers/mobile_menu_controller.js
bullet_train-1.3.17 app/javascript/controllers/mobile_menu_controller.js
bullet_train-1.3.16 app/javascript/controllers/mobile_menu_controller.js
bullet_train-1.3.15 app/javascript/controllers/mobile_menu_controller.js
bullet_train-1.3.14 app/javascript/controllers/mobile_menu_controller.js