Module: UI::SonnerToasterBehavior
- Included in:
- SonnerToaster
- Defined in:
- app/behaviors/ui/sonner_toaster_behavior.rb
Overview
UI::SonnerToasterBehavior
Constant Summary collapse
- POSITIONS =
%w[top-left top-center top-right bottom-left bottom-center bottom-right].freeze
- THEMES =
%w[light dark system].freeze
Instance Method Summary collapse
Instance Method Details
#toaster_classes ⇒ Object
39 40 41 |
# File 'app/behaviors/ui/sonner_toaster_behavior.rb', line 39 def toaster_classes TailwindMerge::Merger.new.merge(["toaster group", @classes].compact.join(" ")) end |
#toaster_data_attributes ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'app/behaviors/ui/sonner_toaster_behavior.rb', line 25 def toaster_data_attributes base_data = @attributes&.dig(:data) || {} { controller: "ui--sonner", ui__sonner_position_value: @position, ui__sonner_theme_value: @theme, ui__sonner_rich_colors_value: @rich_colors, ui__sonner_expand_value: , ui__sonner_duration_value: @duration, ui__sonner_close_button_value: , ui__sonner_visible_toasts_value: @visible_toasts }.compact.merge(base_data) end |
#toaster_html_attributes ⇒ Object
17 18 19 20 21 22 23 |
# File 'app/behaviors/ui/sonner_toaster_behavior.rb', line 17 def toaster_html_attributes base_attrs = @attributes&.except(:data) || {} base_attrs.merge( class: toaster_classes, data: toaster_data_attributes ) end |