1.0.0 • Published 10 months ago

@launchpadlab/lp-stimulus-components v1.0.0

Weekly downloads
-
License
MIT
Repository
-
Last release
10 months ago

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 start to serve index.js on port 4000
  • In the Rails application using import maps, pin lp-stimulus-components to http://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-components in 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 link in the lp-stimulus-components project root directory
  • Run yarn link lp-stimulus-components in 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>
1.0.0

10 months ago