Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: Extract chips component #181

Merged
merged 9 commits into from
Feb 16, 2023
3 changes: 1 addition & 2 deletions app/assets/stylesheets/application.css.scss.erb
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,9 @@
@import "browse";
@import "lostpassword";
@import "flatpickr/dist/themes/light";
@import "card_message";
@import "feedback";
@import "login";

@import "components/index";

/* Bootstrap and Font Awesome */
@import "bootstrap";
Expand Down
35 changes: 35 additions & 0 deletions app/assets/stylesheets/components/chips.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
.chips-container div{
margin-right: 10px;
}
.chips-check-icon{
margin-left: 6px;
margin-right: 6px;
display: none;
}

.chips-container div label{
cursor: pointer;
}
.chips-container div label input[type="checkbox"]{
display: none;
}
.chips-container div label span{
position: relative;
display: inline-block;
background:white;
border: 0.5px solid #BDBDBD;
color: #a7a7a7;
padding: 8px;
border-radius: 5px;
font-size: 13px;
user-select: none;

}
.chips-container div label input[type="checkbox"]:checked ~ span{
border: 1px solid var(--primary-color);
color: var(--primary-color);
}

.chips-container div label input[type="checkbox"]:checked ~ span .chips-check-icon{
display:unset;
}
2 changes: 2 additions & 0 deletions app/assets/stylesheets/components/index.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
@import 'chips';
@import 'card_message'
6 changes: 6 additions & 0 deletions app/components/chips_component.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
class ChipsComponent < ViewComponent::Base
def initialize(name:, value:)
@name = name
@value = value
end
end
7 changes: 7 additions & 0 deletions app/components/chips_component/chips_component.html.haml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.chips-container
%div
%label{:for => "chips-#{@name}-check"}
%input{:id => "chips-#{@name}-check", :name => @name, :type => "checkbox", :value => @value}/
%span
%img.chips-check-icon{:src => "#{asset_path('check.svg')}"}/
= @value