akkounts/app/components/notification_component.rb
Sebastian Kippe 8102fa1230
All checks were successful
continuous-integration/drone/push Build is passing
WIP Add notification component for flash messages
2022-02-20 17:22:49 -06:00

46 lines
740 B
Ruby

# 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