Sha256: 057ec34a272c5ea1e3a644433cc8656002997be5cdcbff71d81af81d10c8c41a

Contents?: true

Size: 840 Bytes

Versions: 2

Compression:

Stored size: 840 Bytes

Contents

module ExpressAdmin
  class IconLink < ExpressTemplates::Components::Configurable

    emits -> {
      if config[:right]
        a(anchor_args) {
          text_node config[:text]
          icon(config[:icon_name].to_sym)
        }
      else
        a(anchor_args) {
          icon(config[:icon_name].to_sym)
          text_node config[:text]
        }
      end
    }

    def anchor_args
      args = {class: class_list, 
              href:  config[:href]}
      args[:id] = config[:id] if config[:id]
      args[:target] = config[:target] if config[:target]
      args['data-delete'] = config[:delete] if config[:delete]
      args['data-confirm'] = config[:confirm] if config[:confirm]
      args[:title] = config[:title] if config[:title]
      args
    end

    def icon_options
      [:icon_name, :text, :right]
    end

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
express_admin-1.3.2 app/components/express_admin/icon_link.rb
express_admin-1.3.1 app/components/express_admin/icon_link.rb