@launchpadlab/lp-stimulus-components
v1.0.0
Published
Stimulus components for Ruby on Rails projects
Readme
lp-stimulus-components
Stimulus components for Ruby on Rails projects.
Contributing
Local Workflow
Apps using Importmaps
To test the package locally on another application, you can run a local server to make the package contents available
- Run
$ yarn startto serveindex.json port4000 - In the Rails application using import maps, pin
lp-stimulus-componentstohttp://localhost:4000/index.js:
# config/importmap.rb
pin "lp-stimulus-components", to: "http://localhost:4000/index.js"- Import and use functions provided by
lp-stimulus-componentsin the JavaScript files for your Rails app
// application.js
import { helloWorld } from 'lp-stimulus-components'Apps With a Build Step
For applications using a build step (e.g. esbuild) you can add a symlink to this package during development
- Run
yarn linkin thelp-stimulus-componentsproject root directory - Run
yarn link lp-stimulus-componentsin your sample Rails application - You should see the package appear in the Rails app's
node_modules/folder - Import and register the stimulus controller you are testing
- Connect the imported controller to your HTML element using the data-controller attribute
// app/javascript/controllers/index.js
import { SampleController } from "lp-stimulus-components"
application.register("sample", SampleController)<div data-controller="sample">
<!-- ... -->
</div>