Sha256: 4d8b74fa211263985cae5ce0980023f673a14ee819159348e333fb0d286a2a41
Contents?: true
Size: 1.14 KB
Versions: 130
Compression:
Stored size: 1.14 KB
Contents
# frozen_string_literal: true module NfgUi module Bootstrap module Utilities # Allows component to swap out the main component wrapping element (ex. :div vs. :span) # Pass in :as -- only unique logic at the moment # is converting :link to :a for tag generation module Wrappable attr_accessor :as def utility_initialize self.as = options.fetch(:as, automatic_as) super end private def assistive_html_attributes if as == :button super.merge(type: options.fetch(:type, 'button')) # prefer type submit else super end end def automatic_as if href :a elsif options[:type] == 'submit' :button else default_html_wrapper_element end end # Set default_html_wrapper_element on individual components as needed def default_html_wrapper_element @default_html_wrapper_element ||= :span end def non_html_attribute_options super.push(:as) end end end end end
Version data entries
130 entries across 130 versions & 1 rubygems