diff options
author | hellekin <hellekin@cepheide.org> | 2020-10-23 18:41:22 +0200 |
---|---|---|
committer | hellekin <hellekin@cepheide.org> | 2020-10-23 18:41:22 +0200 |
commit | f9d0f6c6d771dbf57843bdc6034b2a20dddb128a (patch) | |
tree | 6cac53679a5d0307a856a2aa3771299e4a60f2d0 | |
parent | 8970b8532c8d40786c3c00f9b77a5e74dfa53a2f (diff) | |
download | incommon-map-f9d0f6c6d771dbf57843bdc6034b2a20dddb128a.tar.gz |
Add stimulus.js
-rw-r--r-- | app/javascript/controllers/hello_controller.js | 18 | ||||
-rw-r--r-- | app/javascript/controllers/index.js | 9 | ||||
-rw-r--r-- | app/javascript/packs/application.js | 2 | ||||
-rw-r--r-- | package.json | 1 | ||||
-rw-r--r-- | yarn.lock | 32 |
5 files changed, 62 insertions, 0 deletions
diff --git a/app/javascript/controllers/hello_controller.js b/app/javascript/controllers/hello_controller.js new file mode 100644 index 0000000..28fdb13 --- /dev/null +++ b/app/javascript/controllers/hello_controller.js @@ -0,0 +1,18 @@ +// Visit The Stimulus Handbook for more details +// https://stimulusjs.org/handbook/introduction +// +// This example controller works with specially annotated HTML like: +// +// <div data-controller="hello"> +// <h1 data-target="hello.output"></h1> +// </div> + +import { Controller } from "stimulus" + +export default class extends Controller { + static targets = [ "output" ] + + connect() { + this.outputTarget.textContent = 'Hello, Stimulus!' + } +} diff --git a/app/javascript/controllers/index.js b/app/javascript/controllers/index.js new file mode 100644 index 0000000..6f53d84 --- /dev/null +++ b/app/javascript/controllers/index.js @@ -0,0 +1,9 @@ +// Load all the controllers within this directory and all subdirectories. +// Controller files must be named *_controller.js. + +import { Application } from "stimulus" +import { definitionsFromContext } from "stimulus/webpack-helpers" + +const application = Application.start() +const context = require.context("controllers", true, /_controller\.js$/) +application.load(definitionsFromContext(context)) diff --git a/app/javascript/packs/application.js b/app/javascript/packs/application.js index 5512f7f..5e3eec0 100644 --- a/app/javascript/packs/application.js +++ b/app/javascript/packs/application.js @@ -14,3 +14,5 @@ require("@rails/activestorage").start() // // const images = require.context('../images', true) // const imagePath = (name) => images(name, true) + +import "controllers" diff --git a/package.json b/package.json index cf700bb..241e4f3 100644 --- a/package.json +++ b/package.json @@ -5,6 +5,7 @@ "@rails/activestorage": "^6.0.0", "@rails/ujs": "^6.0.0", "@rails/webpacker": "4.3.0", + "stimulus": "^1.1.1", "turbolinks": "^5.2.0" }, "version": "0.1.0", @@ -906,6 +906,30 @@ webpack-cli "^3.3.10" webpack-sources "^1.4.3" +"@stimulus/core@^1.1.1": + version "1.1.1" + resolved "https://registry.yarnpkg.com/@stimulus/core/-/core-1.1.1.tgz#42b0cfe5b73ca492f41de64b77a03980bae92c82" + integrity sha512-PVJv7IpuQx0MVPCBblXc6O2zbCmU8dlxXNH4bC9KK6LsvGaE+PCXXrXQfXUwAsse1/CmRu/iQG7Ov58himjiGg== + dependencies: + "@stimulus/mutation-observers" "^1.1.1" + +"@stimulus/multimap@^1.1.1": + version "1.1.1" + resolved "https://registry.yarnpkg.com/@stimulus/multimap/-/multimap-1.1.1.tgz#b95e3fd607345ab36e5d5b55486ee1a12d56b331" + integrity sha512-26R1fI3a8uUj0WlMmta4qcfIQGlagegdP4PTz6lz852q/dXlG6r+uPS/bx+H8GtfyS+OOXVr3SkZ0Zg0iRqRfQ== + +"@stimulus/mutation-observers@^1.1.1": + version "1.1.1" + resolved "https://registry.yarnpkg.com/@stimulus/mutation-observers/-/mutation-observers-1.1.1.tgz#0f6c6f081308427fed2a26360dda0c173b79cfc0" + integrity sha512-/zCnnw1KJlWO2mrx0yxYaRFZWMGnDMdOgSnI4hxDLxdWVuL2HMROU8FpHWVBLjKY3T9A+lGkcrmPGDHF3pfS9w== + dependencies: + "@stimulus/multimap" "^1.1.1" + +"@stimulus/webpack-helpers@^1.1.1": + version "1.1.1" + resolved "https://registry.yarnpkg.com/@stimulus/webpack-helpers/-/webpack-helpers-1.1.1.tgz#eff60cd4e58b921d1a2764dc5215f5141510f2c2" + integrity sha512-XOkqSw53N9072FLHvpLM25PIwy+ndkSSbnTtjKuyzsv8K5yfkFB2rv68jU1pzqYa9FZLcvZWP4yazC0V38dx9A== + "@types/glob@^7.1.1": version "7.1.3" resolved "https://registry.yarnpkg.com/@types/glob/-/glob-7.1.3.tgz#e6ba80f36b7daad2c685acd9266382e68985c183" @@ -6763,6 +6787,14 @@ stdout-stream@^1.4.0: dependencies: readable-stream "^2.0.1" +stimulus@^1.1.1: + version "1.1.1" + resolved "https://registry.yarnpkg.com/stimulus/-/stimulus-1.1.1.tgz#53c2fded6849e7b85eed3ed8dd76e33abd74bec5" + integrity sha512-R0mBqKp48YnRDZOxZ8hiOH4Ilph3Yj78CIFTBkCwyHs4iGCpe7xlEdQ7cjIxb+7qVCSxFKgxO+mAQbsNgt/5XQ== + dependencies: + "@stimulus/core" "^1.1.1" + "@stimulus/webpack-helpers" "^1.1.1" + stream-browserify@^2.0.1: version "2.0.2" resolved "https://registry.yarnpkg.com/stream-browserify/-/stream-browserify-2.0.2.tgz#87521d38a44aa7ee91ce1cd2a47df0cb49dd660b" |