Sha256: f4b77a82e5c7c2b4cdac147f7c9fc28bbd2aecd059ba3d74f78bf5040319589c

Contents?: true

Size: 1.58 KB

Versions: 76

Compression:

Stored size: 1.58 KB

Contents

// Configure your import map in config/importmap.rb. Read more: https://github.com/rails/importmap-rails
import "@hotwired/turbo-rails"
import "controllers"

document.addEventListener("turbo:before-stream-render", function(event) {
  // Add a class to an element we are about to add to the page
  // as defined by its "data-stream-enter-class"
  if (event.target.firstElementChild instanceof HTMLTemplateElement) {
    var enterAnimationClass = event.target.templateContent.firstElementChild.dataset.streamEnterClass
    if (enterAnimationClass) {
      event.target.templateElement.content.firstElementChild.classList.add(enterAnimationClass)
    }
  }

  // Add a class to an element we are about to remove from the page
  // as defined by its "data-stream-exit-class"
  var elementToRemove = document.getElementById(event.target.target)
  if (elementToRemove) {
    var streamExitClass = elementToRemove.dataset.streamExitClass
    if (streamExitClass) {
      // Intercept the removal of the element
      event.preventDefault()
      elementToRemove.classList.add(streamExitClass)
      // Wait for its animation to end before removing the element
      elementToRemove.addEventListener("animationend", function() {
        event.target.performAction()
      })
    }
  }
})

// FIX this using stimulus
// Add Theme Changer Event Listener
var items = Array.from(document.querySelector('.dropdown > ul').children);
items.forEach(item => {
  item.addEventListener('click', event => {
    var html = document.querySelector('html');
    html.setAttribute("data-theme", event.target.getAttribute('data-value'));
  })
})

Version data entries

76 entries across 76 versions & 1 rubygems

Version Path
rails_app_generator-0.2.10 after_templates/rag/tailwind_hotwire_form_search/application.js
rails_app_generator-0.2.9 after_templates/rag/tailwind_hotwire_form_search/application.js
rails_app_generator-0.2.8 after_templates/rag/tailwind_hotwire_form_search/application.js
rails_app_generator-0.2.7 after_templates/rag/tailwind_hotwire_form_search/application.js
rails_app_generator-0.2.6 after_templates/rag/tailwind_hotwire_form_search/application.js
rails_app_generator-0.2.5 after_templates/rag/tailwind_hotwire_form_search/application.js
rails_app_generator-0.2.4 after_templates/rag/tailwind_hotwire_form_search/application.js
rails_app_generator-0.2.3 after_templates/rag/tailwind_hotwire_form_search/application.js
rails_app_generator-0.2.2 after_templates/rag/tailwind_hotwire_form_search/application.js
rails_app_generator-0.2.1 after_templates/rag/tailwind_hotwire_form_search/application.js
rails_app_generator-0.2.0 after_templates/rag_tailwind_hotwire_form_search/application.js
rails_app_generator-0.1.28 after_templates/rag_tailwind_hotwire_form_search/application.js
rails_app_generator-0.1.27 after_templates/rag_tailwind_hotwire_form_search/application.js
rails_app_generator-0.1.26 after_templates/rag_tailwind_hotwire_form_search/application.js
rails_app_generator-0.1.25 after_templates/rag_tailwind_hotwire_form_search/application.js
rails_app_generator-0.1.24 after_templates/rag_tailwind_hotwire_form_search/application.js
rails_app_generator-0.1.23 after_templates/rag_tailwind_hotwire_form_search/application.js
rails_app_generator-0.1.22 after_templates/rag_tailwind_hotwire_form_search/application.js
rails_app_generator-0.1.21 after_templates/rag_tailwind_hotwire_form_search/application.js
rails_app_generator-0.1.20 after_templates/rag_tailwind_hotwire_form_search/application.js