HeartRatingSystemComponent

InfoGeneratePackages

This code defines a Ruby class named `RatingComponent`, which inherits from `ApplicationComponent`. The class includes a method named `template` that creates a set of five radio input elements, each styled as a heart in different colors (red, orange, yellow, lime, and green). These radio inputs are part of a rating system, where users can select one of the hearts to rate something (implied by the naming convention 'rating-3'). The radio input with the class 'bg-orange-400' is pre-selected, indicated by the `checked` attribute. This component appears to be designed for a web application interface, potentially utilizing a Ruby on Rails framework with a view component library to manage reusable UI components efficiently.

# frozen_string_literal: true

class RatingComponent < ApplicationComponent
  def template
    div(class: "rating gap-1") do
      input(type: "radio", name: "rating-3", class: "mask mask-heart bg-red-400")
      input(type: "radio", name: "rating-3", class: "mask mask-heart bg-orange-400", checked: true)
      input(type: "radio", name: "rating-3", class: "mask mask-heart bg-yellow-400")
      input(type: "radio", name: "rating-3", class: "mask mask-heart bg-lime-400")
      input(type: "radio", name: "rating-3", class: "mask mask-heart bg-green-400")
    end
  end
end