Class: RailsAppGenerator::AddOns::StimulusComponents
- Inherits:
-
RailsAppGenerator::Addon
- Object
- Rails::Generators::Base
- RailsAppGenerator::Addon
- RailsAppGenerator::AddOns::StimulusComponents
- Defined in:
- lib/rails_app_generator/addons/stimulus_components.rb
Overview
Stimulus components
Instance Attribute Summary
Attributes inherited from RailsAppGenerator::Addon
#context, #dependencies, #gem_entries
Instance Method Summary collapse
Methods inherited from RailsAppGenerator::Addon
addon_name, dependencies, depends_on, gem, gem_entries, #initialize, required_gem, reset_gem_entries
Constructor Details
This class inherits a constructor from RailsAppGenerator::Addon
Instance Method Details
#apply ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/rails_app_generator/addons/stimulus_components.rb', line 10 def apply run('yarn add tailwindcss-stimulus-components') inject_into_file('app/javascript/packs/application.js') do <<~JS import { Application } from "stimulus" import { definitionsFromContext } from "stimulus/webpack-helpers" const application = Application.start(); const context = require.context("controllers", true, /.js$/); application.load(definitionsFromContext(context)); import { Dropdown, Modal, Tabs, Popover, Toggle, Slideover } from "tailwindcss-stimulus-components" application.register('dropdown', Dropdown) application.register('modal', Modal) application.register('tabs', Tabs) application.register('popover', Popover) application.register('toggle', Toggle) application.register('slideover', Slideover) JS end end |