Sha256: dbae09457959c9115d0927baa8461adf99b4da78be28fb1ee41d38285660d3b2
Contents?: true
Size: 880 Bytes
Versions: 1
Compression:
Stored size: 880 Bytes
Contents
module Coco class Snackbar < Coco::Component include Concerns::WithIcon include Concerns::ActsAsNotification THEME_ICONS = { positive: :check, warning: :alert_triangle, negative: :alert_circle, pending: :loader_2 }.freeze accepts_option :theme, from: [:positive, :warning, :negative, :pending] renders_one :action, ->(*args, **kwargs, &block) do coco_button(*args, **kwargs, theme: :blank, size: :sm, icon: nil, &block) end before_render do theme = get_option_value(:theme) unless tag_attr?(:id) set_tag_attr(:id, "snackbar-#{rand(1000)}") end if !icon? && theme.present? icon_opts = get_option_group(:icon).values icon_name = THEME_ICONS[theme] spin = theme == :pending icon(**icon_opts, name: icon_name, spin: spin) end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
coveragebook_components-0.13.0 | app/components/coco/messaging/snackbar/snackbar.rb |