Class: CodengageViewComponents::FlashComponent
- Inherits:
-
ApplicationComponent
- Object
- ViewComponent::Base
- ApplicationComponent
- CodengageViewComponents::FlashComponent
- Defined in:
- app/components/codengage_view_components/flash_component.rb
Defined Under Namespace
Classes: Message
Constant Summary collapse
- STYLES =
{ "notice" => { bg: "bg-green-700", stroke: "#48BB78", icon: "check" }, "alert" => { bg: "bg-red-700", stroke: "#DC3545", icon: "circle-alert" } }.freeze
Instance Method Summary collapse
-
#initialize(flash:, classes: "") ⇒ FlashComponent
constructor
A new instance of FlashComponent.
Constructor Details
#initialize(flash:, classes: "") ⇒ FlashComponent
Returns a new instance of FlashComponent.
12 13 14 15 16 17 18 |
# File 'app/components/codengage_view_components/flash_component.rb', line 12 def initialize(flash:, classes: "") @classes = classes @messages = flash.map do |type, text| style = STYLES[type] Message.new(type:, text: text.to_s, **style) end end |