Browse Source

stimulus

main
pvincent 5 months ago
parent
commit
716637dc2d
  1. 5
      TODO.md
  2. 2
      app/javascript/application.js
  3. 2
      app/javascript/controllers/application.js
  4. 8
      app/javascript/controllers/toast_controller.js
  5. 4
      config/importmap.rb

5
TODO.md

@ -1,7 +1,9 @@
TODO TODO
==== ====
* [ ] Minitest
* [ ] Flash message
* [ ] https://reinteractive.com/articles/how-to-create-flash-messages-in-Rails-7
* [ ]
* [ ] Tailwind * [ ] Tailwind
* [ ] copy TailAdmin (or WindMill) layout * [ ] copy TailAdmin (or WindMill) layout
* [ ] https://demo.tailadmin.com/crm * [ ] https://demo.tailadmin.com/crm
@ -25,6 +27,7 @@ TODO
New Notes New Notes
--------- ---------
* [x] Minitest
* [x] Formatter * [x] Formatter
* [x] wrap warning containing \n * [x] wrap warning containing \n
* [x] "\e[0;35mhello".length => 12 instead of 5! * [x] "\e[0;35mhello".length => 12 instead of 5!

2
app/javascript/application.js

@ -7,4 +7,4 @@ import Toastify from 'toastify-js'
window.Toastify=Toastify window.Toastify=Toastify
// Js Controllers // Js Controllers
import "controllers"
import "controllers"

2
app/javascript/controllers/application.js

@ -3,7 +3,7 @@ import { Application } from "@hotwired/stimulus"
const application = Application.start() const application = Application.start()
// Configure Stimulus development experience // Configure Stimulus development experience
application.debug = false
application.debug = true
window.Stimulus = application window.Stimulus = application
export { application } export { application }

8
app/javascript/controllers/toast_controller.js

@ -0,0 +1,8 @@
import { Controller } from "@hotwired/stimulus"
export default class extends Controller {
connect() {
console.log('toast.js: ', this.element)
this.element.textContent = "Toast #1"
}
}

4
config/importmap.rb

@ -1,9 +1,9 @@
# Pin npm packages by running ./bin/importmap # Pin npm packages by running ./bin/importmap
pin 'application' pin 'application'
pin_all_from 'app/javascript/controllers', under: 'controllers'
pin '@hotwired/turbo-rails', to: 'turbo.min.js', preload: true pin '@hotwired/turbo-rails', to: 'turbo.min.js', preload: true
pin '@hotwired/stimulus', to: 'stimulus.min.js' pin '@hotwired/stimulus', to: 'stimulus.min.js'
pin '@hotwired/stimulus-loading', to: 'stimulus-loading.js' pin '@hotwired/stimulus-loading', to: 'stimulus-loading.js'
pin_all_from 'app/javascript/controllers', under: 'controllers'
pin 'toastify-js' # @1.12.0 pin 'toastify-js' # @1.12.0
Loading…
Cancel
Save