Sha256: 5d6135bf5b27dc3205dc2ec2b357d4130995da34460d72ba4c708f993b605f44

Contents?: true

Size: 1.4 KB

Versions: 4

Compression:

Stored size: 1.4 KB

Contents

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

    tag :a

    has_argument :id, "The name of the ionic icon withouth the ion- prefix. See http://ionicons.com/cheatsheet.html",
                     as: :icon_name,
                     type: [:symbol, :string]

    has_option :text,    "Link text to accompany the icon."

    has_option :right,   "Aligns the icon to the right of the text.",
                         default: false
    has_option :href,    "Link path, URL or anchor.",
                         required: true, attribute: true
    has_option :title,   "Title text for accessibility; appears on mouse hover.",
                         attribute: true
    has_option :confirm, "Should trigger a confirm message.",
                         type: :boolean
    has_option :delete,  "Should perform a delete action.",
                         type: :boolean
    has_option :target,  "The link target attribute. Set to open in a new window or tab.",
                         attribute: true

    before_build -> {
      set_attribute 'data-delete', config[:delete] if config[:delete]
      set_attribute 'data-confirm', config[:confirm] if config[:confirm]
    }

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

  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
express_admin-1.4.3 app/components/express_admin/icon_link.rb
express_admin-1.4.2 app/components/express_admin/icon_link.rb
express_admin-1.4.1 app/components/express_admin/icon_link.rb
express_admin-1.4.0 app/components/express_admin/icon_link.rb