Sha256: 1caa70958c19037959d3e29f345030876374c0af0d78c81e16ebfec90714a349
Contents?: true
Size: 1.11 KB
Versions: 2
Compression:
Stored size: 1.11 KB
Contents
# frozen_string_literal: true module Primer class FlashComponent < Primer::Component include ViewComponent::Slotable with_slot :actions, class_name: "Actions" DEFAULT_VARIANT = :default VARIANT_MAPPINGS = { DEFAULT_VARIANT => "", :warning => "flash-warn", :danger => "flash-error", :success => "flash-success" }.freeze def initialize(full: false, spacious: false, dismissible: false, icon: nil, variant: DEFAULT_VARIANT, **kwargs) @icon = icon @dismissible = dismissible @kwargs = kwargs @kwargs[:tag] = :div @kwargs[:classes] = class_names( @kwargs[:classes], "flash", VARIANT_MAPPINGS[fetch_or_fallback(VARIANT_MAPPINGS.keys, variant, DEFAULT_VARIANT)], "flash-full": full ) @kwargs[:mb] ||= spacious ? 4 : nil end class Actions < ViewComponent::Slot include ClassNameHelper attr_reader :kwargs def initialize(**kwargs) @kwargs = kwargs @kwargs[:tag] = :div @kwargs[:classes] = class_names(@kwargs[:classes], "flash-action") end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
primer_view_components-0.0.10 | app/components/primer/flash_component.rb |
primer_view_components-0.0.9 | app/components/primer/flash_component.rb |