Giter VIP home page Giter VIP logo

vitrail's People

Contributors

guillaumecabanel avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar

vitrail's Issues

[moved to discussions] use helper instead of direct reference of components

I find referencing component constant everywhere cumbersome and a bit of lost space, and I'd like to implement a kind of helper I already used on an app of mine.

<div>
  <%= render vitrail.title(level: 2).with_content("Hello there!") %>

  <%= render vitrail.card(class: "bg-blue-200") do %>
    <p>What a nice gem!</p>
  <% end %>
</div>

Base component may cause unexpected behavior with html_options handling

In Vitrail::BaseComponent, initialize is:

def initialize(**html_options)
  super

  @custom_classes = html_options.delete(:class) || ""
  @html_options = html_options.stringify_keys
end

but by doing so, the html_options is mutated and key :class is removed. It could cause unexpected behavior in such examples:

<div>
  <% html_options = { class: "text-red-500", data: { some_stimulus_target: "target" } %>
  <% @elements.each do |element| %>
    <%= render Vitrail::Card.new(**html_options).with_content(element.content) %> <!-- class is not passed after first element-->
  <% end %>
</div>

In this case, after the first iteration, hash hold by html_options variable is mutated and :class key is remove.
I can see this method comes from Rails codebase but when it is done like, hash is cloned before being mutated.

Edit: I made a PR with a fix #4

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.