Sha256: a54b02f12c7b20d23a616728ebf4b522decc06c4c1401c8db52599a5ecf64d63
Contents?: true
Size: 1.06 KB
Versions: 3
Compression:
Stored size: 1.06 KB
Contents
# frozen_string_literal: true module Blacklight module System class FlashMessageComponent < ViewComponent::Base renders_one :message with_collection_parameter :message def initialize(type:, message: nil) @message = message @classes = alert_class(type) end def before_render with_message { @message } if @message end # Bootstrap 4 requires the span, but Bootstrap 5 should not have it. # See https://getbootstrap.com/docs/4.6/components/alerts/#dismissing # https://getbootstrap.com/docs/5.1/components/alerts/#dismissing def button_contents return if helpers.controller.blacklight_config.bootstrap_version == 5 tag.span '×'.html_safe, aria: { hidden: true } end def alert_class(type) case type.to_s when 'success' then "alert-success" when 'notice' then "alert-info" when 'alert' then "alert-warning" when 'error' then "alert-danger" else "alert-#{type}" end end end end end
Version data entries
3 entries across 3 versions & 1 rubygems