Class: Kanso::NotificationComponent
- Inherits:
-
ViewComponent::Base
- Object
- ViewComponent::Base
- Kanso::NotificationComponent
- Defined in:
- app/components/kanso/notification_component.rb
Defined Under Namespace
Classes: Theme
Constant Summary collapse
- THEMES =
{ success: Theme.new( icon_name: "check-circle", icon_bg_classes: "bg-green-100", icon_color_classes: "text-green-600", title_text_classes: "text-green-800", body_text_classes: "text-green-700", aria_role: "status" ), error: Theme.new( icon_name: "x-circle", icon_bg_classes: "bg-red-100", icon_color_classes: "text-red-600", title_text_classes: "text-red-800", body_text_classes: "text-red-700", aria_role: "alert" ), warning: Theme.new( icon_name: "exclamation-triangle", icon_bg_classes: "bg-yellow-100", icon_color_classes: "text-yellow-600", title_text_classes: "text-yellow-800", body_text_classes: "text-yellow-700", aria_role: "alert" ), info: Theme.new( icon_name: "information-circle", icon_bg_classes: "bg-blue-100", icon_color_classes: "text-blue-600", title_text_classes: "text-blue-800", body_text_classes: "text-blue-700", aria_role: "status" ) }.freeze
- RAILS_FLASH_ALIASES =
{ notice: :success, alert: :error }.freeze
Instance Attribute Summary collapse
-
#message ⇒ Object
readonly
Returns the value of attribute message.
-
#theme_data ⇒ Object
readonly
Returns the value of attribute theme_data.
-
#title ⇒ Object
readonly
Returns the value of attribute title.
Instance Method Summary collapse
-
#initialize(message:, title: nil, theme: :info) ⇒ NotificationComponent
constructor
A new instance of NotificationComponent.
Constructor Details
#initialize(message:, title: nil, theme: :info) ⇒ NotificationComponent
Returns a new instance of NotificationComponent.
57 58 59 60 61 62 63 64 |
# File 'app/components/kanso/notification_component.rb', line 57 def initialize(message:, title: nil, theme: :info) @title = title @message = theme_sym = theme.to_sym mapped_theme = RAILS_FLASH_ALIASES[theme_sym] || theme_sym @theme_data = THEMES[mapped_theme] || THEMES[:info] end |
Instance Attribute Details
#message ⇒ Object (readonly)
Returns the value of attribute message.
55 56 57 |
# File 'app/components/kanso/notification_component.rb', line 55 def @message end |
#theme_data ⇒ Object (readonly)
Returns the value of attribute theme_data.
55 56 57 |
# File 'app/components/kanso/notification_component.rb', line 55 def theme_data @theme_data end |
#title ⇒ Object (readonly)
Returns the value of attribute title.
55 56 57 |
# File 'app/components/kanso/notification_component.rb', line 55 def title @title end |