Skip to content

Commit

Permalink
jsを変更
Browse files Browse the repository at this point in the history
  • Loading branch information
manabeai committed Aug 21, 2024
1 parent 770e7e7 commit e449418
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 9 deletions.
2 changes: 0 additions & 2 deletions app/javascript/application.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// Entry point for the build script in your package.json
import "@hotwired/turbo-rails"
import "./controllers"

Turbo.session.drive = false
4 changes: 2 additions & 2 deletions app/javascript/controllers/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@

import { application } from "./application"

import HelloController from "./hello_controller"
application.register("hello", HelloController)
import RemovalsController from "./removals_controller"
application.register("removals", RemovalsController)
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Controller } from "@hotwired/stimulus"

export default class extends Controller {
connect() {
this.element.textContent = "Hello World!"
remove() {
this.element.remove()
}
}
}
8 changes: 6 additions & 2 deletions app/views/layouts/_flash.html.erb
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
<% flash.each do |flash_type, message| %>
<div class="flash__message">
<div
class="flash__message"
data-controller="removals"
data-action="animationend->removals#remove"
>
<%= message %>
</div>
<% end %>
<% end %>
3 changes: 3 additions & 0 deletions app/views/layouts/application.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@

<body>
<%= render "layouts/navbar" %>
<div class="flash">
<%= render "layouts/flash" %>
</div>
<%= yield %>
</body>
</html>

0 comments on commit e449418

Please sign in to comment.