WIP Add notification component for flash messages
continuous-integration/drone/push Build is passing

This commit is contained in:
2022-02-20 17:22:49 -06:00
parent 835152c656
commit 8102fa1230
292 changed files with 397 additions and 8 deletions
+45
View File
@@ -0,0 +1,45 @@
# frozen_string_literal: true
class NotificationComponent < ViewComponent::Base
def initialize(type:, data:)
@type = type
@data = prepare_data(data)
@icon_name = icon_name
@icon_color_class = icon_color_class
end
def prepare_data(data)
case data
when Hash
data
else
{ title: data }
end
end
def icon_name
case @type
when 'success'
'check-circle'
when 'error'
'alert-octagon'
when 'alert'
'alert-octagon'
else
'info'
end
end
def icon_color_class
case @type
when 'success'
'text-emerald-500'
when 'error'
'text-rose-600'
when 'alert'
'text-rose-600'
else
'text-gray-400'
end
end
end