Skip to content

tamiru/stimulus-components

Repository files navigation

Stimulus Components

A Ruby gem that packages the stimulus-components collection of 34+ Stimulus controllers for easy integration with Rails applications.

Requirements

  • Rails 7.1+
  • Ruby 3.1+

Installation

Add this line to your application's Gemfile:

gem "stimulus-components"

Then run:

bundle install

Usage

Importmap (Recommended for Rails 7.1+)

Add to your config/importmap.rb:

pin "stimulus-components", to: "stimulus-components.js"
pin "@hotwired/stimulus", to: "https://cdn.jsdelivr.net/gh/hotwired/stimulus@3.2.2/dist/stimulus.umd.js"
pin "@hotwired/stimulus-loading", to: "https://cdn.jsdelivr.net/gh/hotwired/stimulus-loading@1.0.5/dist/stimulus-loading.umd.js"
pin "stimulus-use", to: "https://cdn.jsdelivr.net/npm/stimulus-use@1.0.0/dist/index.js"

Sprockets

Add to your app/assets/javascripts/application.js:

//= require stimulus-components

Application Controller

In your JavaScript entry point (e.g., app/javascript/controllers/index.js):

import { application } from "stimulus-components"

window.Stimulus = application

Or import individual controllers:

import ClipboardController from "stimulus-components/clipboard"
import PasswordVisibilityController from "stimulus-components/password-visibility"

Available Controllers

Controller Description
animated-number Animates numbers on scroll
auto-submit Auto-submits forms with debounce
carousel Swiper-based carousel
character-counter Counts characters in inputs
chartjs Chart.js integration
checkbox-select-all Select all checkbox functionality
clipboard Copy to clipboard
color-picker Color picker with Pickr
confirmation Form confirmation checks
content-loader Load remote content
dialog Native dialog element
dropdown Dropdown with transitions
glow Hover glow effect
hotkey Keyboard shortcuts
lightbox Image lightbox gallery
notification Toast notifications
password-visibility Toggle password visibility
places-autocomplete Google Places autocomplete
popover Popover content display
prefetch Link prefetching
rails-nested-form Nested form management
read-more Expandable content
remote-rails Remote response handling
reveal Toggle element visibility
scroll-progress Scroll progress bar
scroll-reveal Scroll-based animations
scroll-to Smooth scroll to element
sortable Sortable lists
sound Audio playback
speech-recognition Voice input
textarea-autogrow Auto-growing textarea
timeago Relative timestamps

External Dependencies

Some controllers require external libraries. Add these to your package.json or via CDN:

{
  "dependencies": {
    "@hotwired/stimulus": "^3.2",
    "@rails/request.js": "^0.0.8",
    "chart.js": "^4.0",
    "lightgallery": "^2.0",
    "sortablejs": "^1.15",
    "stimulus-use": "^1.0",
    "swiper": "^11.0",
    "@simonwep/pickr": "^1.9",
    "date-fns": "^3.0"
  }
}

Documentation

For detailed usage instructions, see the official documentation.

License

MIT License - see LICENSE.txt

Contributing

  1. Fork it
  2. Create your feature branch
  3. Commit your changes
  4. Push to the branch
  5. Create a new Pull Request

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors