grape-swagger-rails icon indicating copy to clipboard operation
grape-swagger-rails copied to clipboard

Customizing the CSS

Open jwigal opened this issue 5 years ago • 2 comments

Provide an easy way to add your own CSS file on top of the delivered CSS.

jwigal avatar Dec 10 '20 12:12 jwigal

2 Warnings
:warning: There’re library changes, but not tests. That’s OK as long as you’re refactoring existing code.
:warning: Unless you’re refactoring existing code, please update CHANGELOG.md.

Here's an example of a CHANGELOG.md entry:

* [#103](https://github.com/ruby-grape/grape-swagger-rails/pull/103): Customizing the css - [@jwigal](https://github.com/jwigal).

Generated by :no_entry_sign: danger

grape-bot avatar Dec 10 '20 13:12 grape-bot

I have some questions.

Why would you rather do this than include the additional stylesheet in your app/assets/stylesheets/application.css?

Assuming we still want this feature, I think we should make it more generic and allow overriding all CSS, i.e. default it to the built-in CSS. I propose that we name this stylesheet_paths and make it an Array.

GrapeSwaggerRails.options.stylesheet_paths << 'some.css' # [ 'grape_swagger_rails/application.css', 'some.css' ]

Then

  <% GrapeSwaggerRails.options.stylesheet_paths.each do |stylesheet_path| %>
    <%= stylesheet_link_tag stylesheet_path %>
  <% end %> 

To be merged this needs tests, too, please.

If you really want to be ambitious, users should also be able to configure script_paths, i.e. all the JS.

dblock avatar Dec 10 '20 14:12 dblock