Sha256: fe7e9e16770faabc34dc7cf0611d01c188e0854f7a0d2d22b609326276e770db

Contents?: true

Size: 1.76 KB

Versions: 6

Compression:

Stored size: 1.76 KB

Contents

# frozen_string_literal: true

module UiBibz::Helpers::Ui::Core::NotificationsHelper
  # Alert Component
  #
  # +options+ (Hash)
  # +html_options+ (Hash)
  #
  def ui_alert(content = nil, options = nil, html_options = nil, &block)
    if tap?(content, options)
      UiBibz::Ui::Core::Notifications::Alert.new(content, options, html_options).tap(&block).render
    else
      UiBibz::Ui::Core::Notifications::Alert.new(content, options, html_options, &block).render
    end
  end

  # Badge (Label) Component
  #
  # +options+ (Hash)
  # +html_options+ (Hash)
  #
  def ui_badge(content = nil, options = nil, html_options = nil, &block)
    UiBibz::Ui::Core::Notifications::Badge.new(content, options, html_options, &block).render
  end

  # ProgressBar Component
  #
  # +options+ (Hash)
  # +html_options+ (Hash)
  def ui_progress_bar(percentage = nil, options = nil, html_options = nil, &block)
    if tap?(percentage, options)
      UiBibz::Ui::Core::Notifications::ProgressBar.new(percentage, options, html_options).tap(&block).render
    else
      UiBibz::Ui::Core::Notifications::ProgressBar.new(percentage, options, html_options, &block).render
    end
  end

  # Toast Component
  #
  # +options+ (Hash)
  # +html_options+ (Hash)
  def ui_toast(content = nil, options = nil, html_options = nil, &block)
    UiBibz::Ui::Core::Notifications::Toast.new(content, options, html_options).tap(&block).render
  end

  # Spinner Component
  #
  # +options+ (Hash)
  # +html_options+ (Hash)
  #
  def ui_spinner(content = nil, options = nil, html_options = nil, &block)
    UiBibz::Ui::Core::Notifications::Spinner.new(content, options, html_options, &block).render
  end

  private

  def tap?(content, options)
    (content[:tap] if content.is_a?(Hash)) || (options[:tap] unless options.nil?)
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
ui_bibz-2.5.6 lib/ui_bibz/helpers/ui/core/notifications_helper.rb
ui_bibz-2.5.5 lib/ui_bibz/helpers/ui/core/notifications_helper.rb
ui_bibz-2.5.3 lib/ui_bibz/helpers/ui/core/notifications_helper.rb
ui_bibz-2.5.2 lib/ui_bibz/helpers/ui/core/notifications_helper.rb
ui_bibz-2.5.1 lib/ui_bibz/helpers/ui/core/notifications_helper.rb
ui_bibz-2.5.0 lib/ui_bibz/helpers/ui/core/notifications_helper.rb