Class: RubyUIAdmin::UI::ToastRegion
- Defined in:
- app/components/ruby_ui_admin/ui/toast_region.rb
Constant Summary collapse
- SKELETON_VARIANTS =
%i[default success error warning info loading].freeze
- FLASH_VARIANTS =
Maps Rails flash keys to RubyUI toast variants (admin semantics: notice = success, alert = error), with explicit variant keys passed through.
{ "notice" => :success, "success" => :success, "alert" => :error, "error" => :error, "warning" => :warning, "info" => :info }.freeze
Constants inherited from Base
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
-
#initialize(position: :bottom_right, expand: false, max: 3, duration: 4000, gap: 14, offset: 24, theme: :system, rich_colors: false, close_button: false, hotkey: %w[alt t],, dir: :ltr, flash: nil, **attrs) ⇒ ToastRegion
constructor
A new instance of ToastRegion.
- #view_template(&block) ⇒ Object
Constructor Details
#initialize(position: :bottom_right, expand: false, max: 3, duration: 4000, gap: 14, offset: 24, theme: :system, rich_colors: false, close_button: false, hotkey: %w[alt t],, dir: :ltr, flash: nil, **attrs) ⇒ ToastRegion
Returns a new instance of ToastRegion.
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'app/components/ruby_ui_admin/ui/toast_region.rb', line 22 def initialize( position: :bottom_right, expand: false, max: 3, duration: 4000, gap: 14, offset: 24, theme: :system, rich_colors: false, close_button: false, hotkey: %w[alt t], dir: :ltr, flash: nil, **attrs ) @position = position.to_sym @expand = @max = max @duration = duration @gap = gap @offset = offset @theme = theme.to_sym @rich_colors = rich_colors @close_button = @hotkey = hotkey @dir = dir @flash = flash super(**attrs) end |
Instance Method Details
#view_template(&block) ⇒ Object
52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'app/components/ruby_ui_admin/ui/toast_region.rb', line 52 def view_template(&block) div(**attrs) do ol(id: "ruby-ui-toaster", class: "pointer-events-auto relative m-0 p-0 list-none w-[356px] max-w-full") do render_flash if @flash yield(self) if block end SKELETON_VARIANTS.each { |v| skeleton(v) } slot_template("actionTpl") { render ToastAction.new(label: "") } slot_template("cancelTpl") { render ToastCancel.new(label: "") } slot_template("closeTpl") { render ToastClose.new } end end |