Browse Source

stimulus

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

5
TODO.md

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

2
app/javascript/controllers/application.js

@ -3,7 +3,7 @@ import { Application } from "@hotwired/stimulus"
const application = Application.start()
// Configure Stimulus development experience
application.debug = false
application.debug = true
window.Stimulus = 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 'application'
pin_all_from 'app/javascript/controllers', under: 'controllers'
pin '@hotwired/turbo-rails', to: 'turbo.min.js', preload: true
pin '@hotwired/stimulus', to: 'stimulus.min.js'
pin '@hotwired/stimulus-loading', to: 'stimulus-loading.js'
pin_all_from 'app/javascript/controllers', under: 'controllers'
pin 'toastify-js' # @1.12.0
Loading…
Cancel
Save