Documentation

Utilities

Rails Designer has various smaller utilities packed. They range from small, reusable Stimulus controllers, to little JavaScript helpers to a custom confirmation dialog for Turbo.

You can get any of the following utilities by running:

bin/rails generate rails_designer:utility #{utility_name}

All available utilities

The currently available utilities.

Toggle Class Controller

Useful little Stimulus controller that allows you to add one or many CSS classes to the given element.

bin/rails generate rails_designer:utility toggle_class

String Helpers

General string helpers that every Rails developer misses in their JavaScript toolbox.

bin/rails generate rails_designer:utility string_helpers

Included are:

  • capitalize
  • dasherize
  • isBlank

Cookies helpers

Need to store or get a cookie. No need to rewrite that logic again and again.

bin/rails generate rails_designer:utility cookies_helpers

Local Storage helpers

Easier implementation for setting, getting and resetting a key/value into the localStorage.

bin/rails generate rails_designer:utility local_storage_helpers

Custom Confirm dialog

Turbo allows you to override the default confirm dialog. By adding this utility + just a few lines of code, your confirm dialogs have never looked this good!

button_to "Delete…",
filters_path(filter),
  method: :delete,
  data: {
    turbo_method: "delete",
    turbo_confirm: "Really delete this filter?",
    turbo_confirm_confirm_label: "Yes, put it in the shredder!",
    turbo_confirm_cancel_label: "Oops, no go back…",
  }

Comes with three themes:

  • light
  • dark
  • lightGlass