Skip to content

Commit

Permalink
Add the checked property to the chips component
Browse files Browse the repository at this point in the history
  • Loading branch information
Bilelkihal authored and syphax-bouazzouni committed Apr 19, 2023
1 parent e10b7e7 commit c57eb9f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
7 changes: 6 additions & 1 deletion app/components/chips_component.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
class ChipsComponent < ViewComponent::Base
def initialize(name:, value:)
def initialize(name:, value:, checked: false)
@name = name
@value = value
@checked = checked
end

def checked?
@checked
end
end
2 changes: 1 addition & 1 deletion app/components/chips_component/chips_component.html.haml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
.chips-container
%div
%label{:for => "chips-#{@name}-check"}
%input{:id => "chips-#{@name}-check", :name => @name, :type => "checkbox", :value => @value}/
%input{:id => "chips-#{@name}-check", :name => @name, :type => "checkbox", :value => @value, checked: checked?}
%span
%svg.chips-check-icon{:fill => "none", :height => "8", :viewbox => "0 0 10 8", :width => "10", :xmlns => "http://www.w3.org/2000/svg"}
%path{:d => "M9.76764 0.232287C9.45824 -0.0775267 8.95582 -0.0773313 8.646 0.232287L3.59787 5.28062L1.35419 3.03696C1.04438 2.72714 0.542174 2.72714 0.23236 3.03696C-0.0774534 3.34677 -0.0774534 3.84897 0.23236 4.15879L3.03684 6.96326C3.19165 7.11807 3.39464 7.19567 3.59765 7.19567C3.80067 7.19567 4.00386 7.11827 4.15867 6.96326L9.76764 1.3541C10.0775 1.0445 10.0775 0.542081 9.76764 0.232287Z"}
Expand Down

0 comments on commit c57eb9f

Please sign in to comment.