Skip to content

Commit

Permalink
import and install stimulus
Browse files Browse the repository at this point in the history
  • Loading branch information
syphax-bouazzouni committed May 28, 2022
1 parent 1f56d3c commit e7002ec
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 0 deletions.
2 changes: 2 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ source 'https://rubygems.org'
gem 'rails', '7.0.3'

gem 'jsbundling-rails'
gem 'stimulus-rails'

gem 'sass-rails', '~> 5.0'
gem 'uglifier', '>= 1.0.3'
# See https://github.com/rails/execjs#readme for more supported runtimes
Expand Down
1 change: 1 addition & 0 deletions app/javascript/application.js
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
// Entry point for the build script in your package.json
import "./controllers"
9 changes: 9 additions & 0 deletions app/javascript/controllers/application.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { Application } from "@hotwired/stimulus"

const application = Application.start()

// Configure Stimulus development experience
application.debug = false
window.Stimulus = application

export { application }
7 changes: 7 additions & 0 deletions app/javascript/controllers/hello_controller.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { Controller } from "@hotwired/stimulus"

export default class extends Controller {
connect() {
this.element.textContent = "Hello World!"
}
}
8 changes: 8 additions & 0 deletions app/javascript/controllers/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// This file is auto-generated by ./bin/rails stimulus:manifest:update
// Run that command whenever you add a new controller or create them with
// ./bin/rails generate stimulus controllerName

import { application } from "./application"

import HelloController from "./hello_controller.js"
application.register("hello", HelloController)

0 comments on commit e7002ec

Please sign in to comment.