Browse Source

Hotwire, stimulus and turbo added

pull/21/head
Matthew Phelan 3 years ago
parent
commit
610a35ed47
  1. 1
      Gemfile
  2. 7
      app/javascript/controllers/hello_controller.js
  3. 14
      app/javascript/controllers/index.js
  4. 0
      app/views/form/age.html.erb
  5. 1
      app/views/form/index.html.erb
  6. 3
      package.json

1
Gemfile

@ -20,6 +20,7 @@ gem "bootsnap", ">= 1.4.4", require: false
# Gov.UK frontend components
gem "govuk-components"
gem "govuk_design_system_formbuilder"
gem 'hotwire-rails'
group :development, :test do
# Call 'byebug' anywhere in the code to stop execution and get a debugger console

7
app/javascript/controllers/hello_controller.js

@ -0,0 +1,7 @@
import { Controller } from "@hotwired/stimulus"
export default class extends Controller {
connect() {
this.element.textContent = "Hello World!"
}
}

14
app/javascript/controllers/index.js

@ -0,0 +1,14 @@
import { Application } from "@hotwired/stimulus"
const application = Application.start()
// Configure Stimulus development experience
application.warnings = true
application.debug = false
window.Stimulus = application
// Import and register all your controllers within this directory and all subdirectories
// Controller files must be named *_controller.js or *_controller.ts
import { definitionsFromContext } from "@hotwired/stimulus"
const context = require.context("controllers", true, /_controller\.(js|ts)$/)
application.load(definitionsFromContext(context))

0
app/views/form/age.html.erb

1
app/views/form/index.html.erb

@ -1,3 +1,4 @@
<%= turbo_frame_tag "form" %>
<%= form_with url:'/test', builder: GOVUKDesignSystemFormBuilder::FormBuilder do |f| %>
<%= f.govuk_number_field :age, label: { text: "Age" } %>
<%= f.govuk_submit %>

3
package.json

@ -2,6 +2,9 @@
"name": "data-collector",
"private": true,
"dependencies": {
"@hotwired/stimulus": "^3.0.0-beta.1",
"@hotwired/turbo": "^7.0.0-rc.3",
"@hotwired/turbo-rails": "^7.0.0-rc.3",
"@rails/actioncable": "^6.0.0",
"@rails/activestorage": "^6.0.0",
"@rails/ujs": "^6.0.0",

Loading…
Cancel
Save