Skip to content

Commit

Permalink
Refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
mlandauer committed May 16, 2024
1 parent f83ff18 commit d26d3f0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 16 deletions.
19 changes: 3 additions & 16 deletions app/components/tailwind/alert_component.html.erb
Original file line number Diff line number Diff line change
@@ -1,19 +1,6 @@
<div class="flex <%= @alignment_class %> <%= @padding_class %> text-2xl font-bold text-white rounded-lg <%= @bg_class %>">
<% case @type %>
<% when :success %>
<div class="mr-5 text-light-lavender">
<%= render Tailwind::Icon.new(name: :tick) %>
</div>
<% when :congratulations %>
<div class="mr-5 text-light-lavender">
<%= render Tailwind::Icon.new(name: :clapping) %>
</div>
<% when :warning %>
<div class="mr-5 text-white">
<%= render Tailwind::Icon.new(name: :warning) %>
</div>
<% else %>
<% raise "Invalid value for type: #{type}" %>
<% end %>
<div class="mr-5 <%= @icon_class %>">
<%= render Tailwind::Icon.new(name: @icon_name) %>
</div>
<div><%= content %></div>
</div>
6 changes: 6 additions & 0 deletions app/components/tailwind/alert_component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,20 @@ def initialize(type:)
@bg_class = T.let("bg-lavender", String)
@alignment_class = T.let("items-center", String)
@padding_class = T.let("px-4 py-3", String)
@icon_name = T.let(:tick, Symbol)
@icon_class = T.let("text-light-lavender", String)
when :congratulations
@bg_class = T.let("bg-lavender", String)
@alignment_class = T.let("items-start", String)
@padding_class = T.let("px-8 py-8", String)
@icon_name = :clapping
@icon_class = "text-light-lavender"
when :warning
@bg_class = "bg-error-red"
@alignment_class = T.let("items-center", String)
@padding_class = T.let("px-4 py-3", String)
@icon_name = :warning
@icon_class = "text-white"
else
raise "Invalid value for type: #{type}"
end
Expand Down

0 comments on commit d26d3f0

Please sign in to comment.