README.md in amber_component-1.1.0 vs README.md in amber_component-1.1.1

- old
+ new

@@ -1,11 +1,11 @@ [![license](https://img.shields.io/badge/License-MIT-purple.svg)](LICENSE) [![Gem Version](https://img.shields.io/gem/v/amber_component.svg?style=flat)](https://rubygems.org/gems/amber_component) [![Maintainability](https://api.codeclimate.com/v1/badges/ad84af499e9791933a87/maintainability)](https://codeclimate.com/github/amber-ruby/amber_component/maintainability) [![CI badge](https://github.com/amber-ruby/amber_component/actions/workflows/ci_ruby.yml/badge.svg)](https://github.com/amber-ruby/amber_component/actions/workflows/ci_ruby.yml) [![Coverage Badge](https://img.shields.io/endpoint?url=https://gist.githubusercontent.com/Verseth/6a095c79278b074d79feaa4f8ceeb2a8/raw/amber_component__heads_main.json)](https://github.com/amber-ruby/amber_component/actions/workflows/ci_ruby.yml) -[![Downloads](https://ruby-gem-downloads-badge.herokuapp.com/amber_component)]((https://rubygems.org/gems/amber_component)) +<!-- [![Downloads](https://ruby-gem-downloads-badge.herokuapp.com/amber_component)]((https://rubygems.org/gems/amber_component)) --> <img src="banner.png" width="500px" style="margin-bottom: 2rem;"/> # AmberComponent @@ -52,10 +52,17 @@ - a Ruby file which defines its properties, encapsulates logic and may implement helper methods (like a controller) - a view/template file (html.erb, haml, slim etc.) - a style file (css, scss, sass etc.) - [optional] a JavaScript file with a Stimulus controller (if you installed the gem with `--stimulus`) +`amber_component` automatically detects what kind of view and stylesheet formats your app is configured to use. + +So if you've got `haml-rails`, components will be generated with `haml`. When your app uses `slim-rails`, components will be generated with `slim`. When your `Gemfile` contains `sassc-rails`, components will use `scss` etc. + +All of these formats can be overridden in +an initializer or by adding arguments to the component generator. + ``` app/components/ ├─ [name]_component.rb └─ [name]_component/ ├─ style.css # may be .sass or .scss @@ -195,17 +202,24 @@ ``` app/components/ ├─ [name]_component.rb └─ [name]_component/ - ├─ style.css - ├─ view.html.erb + ├─ style.css # may be `.scss` or `.sass` + ├─ view.html.erb # may be `.haml` or `.slim` └─ controller.js # if stimulus is configured test/components/ └─ [name]_component_test.rb ``` +View and stylesheet formats can be overridden by providing options. + +``` +-v, [--view=VIEW] # Indicate what type of view should be generated eg. [:erb, :haml, :slim] +--styles, -c, [--css=CSS] # Indicate what type of styles should be generated eg. [:css, :scss, :sass] +``` + ### Component properties There is a neat prop DSL. ```ruby @@ -407,9 +421,24 @@ <%= f.label :password_confirmation, "Confirm Password" %> <%= f.password_field :password_confirmation %> <%= f.submit "Create account" %> <% end %> +``` + +### Configuration + +This gem can be configured in an initializer. +If you used the installer generator it should already be present. + +```ruby +# config/initializers/amber_component.rb + +::AmberComponent.configure do |c| + c.stimulus = nil # [nil, :importmap, :webpacker, :jsbundling, :webpack, :esbuild, :rollup] + c.stylesheet_format = :css # [:css, :scss, :sass] + c.view_format = :erb # [:erb, :haml, :slim] +end ``` ### Testing Components ### Rails