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 card message component #166

Merged
merged 13 commits into from
Feb 3, 2023
3 changes: 3 additions & 0 deletions app/assets/images/green-check.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions app/assets/images/red-warning.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion app/assets/stylesheets/application.css.scss.erb
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
@import "file_uploader";
@import "browse";
@import "flatpickr/dist/themes/light";

@import "card_message";
/* Bootstrap and Font Awesome */
@import "bootstrap";
@import "bootstrap_overrides";
Expand Down
40 changes: 40 additions & 0 deletions app/assets/stylesheets/card_message.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
.card-message-card{
margin-top: 30px;
padding: 37px 41px;
box-shadow: rgba(0, 0, 0, 0.05) 0px 20px 50px;
border-radius: 14px;
}
.card-message-title{
font-size: 19px;
text-align: center;
margin-bottom: 10px;
font-weight: 700;
}
.card-message-text{
text-align: center;
width: 310px;
font-size: 14px;
font-weight: 500;
margin-bottom: 21px;
}
.card-message-button{
padding: 16px;
border-radius: 9px;
display: flex;
justify-content: center;
align-items: center;
cursor: pointer;
text-decoration: none !important;
}
.card-message-button-success{
color: var(--primary-color);
border: 1px solid var(--primary-color);
}
.card-message-button-failure{
color: #EE404C !important;
border: 1px solid #EE404C;
}
.card-message-has-title{
color: #666666;
font-weight: 400;
}
26 changes: 26 additions & 0 deletions app/components/card_message_component.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
class CardMessageComponent < ViewComponent::Base
def initialize(title: nil ,message:, button_text: nil, type:)
@title = title
@message = message
@button_text = button_text
@type = type

end

def no_title?
@title.nil?
end

def no_button?
@button_text.nil?
end

def icon
case @type
when "success"
"green-check.svg"
when "failure"
"red-warning.svg"
end
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
.d-flex.justify-content-center.m-4
.card-message-card
.d-flex.justify-content-center.mb-4
%img{:src => "#{asset_path(icon)}"}/
- if no_title?
%p.card-message-text
= @message
- else
%h2.card-message-title
= @title
%p.card-message-text.card-message-has-title
= @message
- unless no_button?
- case @type
- when "success"
%a.card-message-button.card-message-button-success{:href => "/"}
= @button_text
- when "failure"
%a.card-message-button.card-message-button-failure{:href => "/"}
= @button_text