Sha256: d5f954f65f8d93d5de8ab5b4342e9d1547dd7758070f8dcf3502ed6898e6c15a
Contents?: true
Size: 1.08 KB
Versions: 94
Compression:
Stored size: 1.08 KB
Contents
# frozen_string_literal: true class AlertComponent < ViewComponent::Base def initialize(type:, toast: false, dismissible: true) @type = type.to_s unless @type.in? ApplicationController._flash_types.map(&:to_s) raise PgEngine::Error, 'el type no es válido' end # rubocop:enable Style/IfUnlessModifier @toast = toast @dismissible = dismissible @klass = [ "alert-#{flash_type_to_class}", ('alert-dismissible' if @dismissible), ('position-absolute pg-toast' if @toast) ].join(' ') super end def icon_class { 'critical' => 'bi-emoji-dizzy me-3 fs-2', 'alert' => 'bi-exclamation-triangle-fill me-2', 'warning' => 'bi-exclamation-circle me-2', 'success' => 'bi-check-lg me-2', 'notice' => 'bi-info-circle me-2' }[@type] end def flash_type_to_class case @type when 'notice' 'info' when 'critical', 'alert' 'danger' when 'warning' 'warning' when 'success' 'success' else # :nocov: pg_err 'no debería pasar' # :nocov: end end end
Version data entries
94 entries across 94 versions & 1 rubygems