Module: Card::Set::All::Bootstrap::Icon::HtmlFormat

Extended by:
Card::Set::AbstractFormat
Defined in:
tmpsets/set/mod026-bootstrap/all/bootstrap/icon.rb

Constant Summary collapse

ICON_MAP =

same for all: :search,

{
  material: {
    plus: :add,
    pencil: :edit,
    trash: :delete,
    wrench: :build,
    new_window: :open_in_new,
    history: :history,
    triangle_left: :expand_less,
    triangle_right: :expand_more,
    flag: :flag,
    option_horizontal: :more_horiz,
    option_vertical: :more_vert,
    pushpin: :pin_drop,
    baby_formula: :device_hub,
    log_out: :call_made,
    log_in: :call_received,
    explore: :explore,
    remove: :close,
    expand: :expand_more,
    collapse_down: :expand_less,
    globe: :public,
    check_circle_o: nil,
    commenting: :comment
  },
  font_awesome: {
    option_horizontal: :ellipsis_h,
    pushpin: "thumb-tack",
    globe: :globe,
    zoom_out: "search-minus",
    close: :remove,
    check_circle_o: "check-circle-o",
    check_circe: "check-circle",
    reorder: "align-justify",
    commenting: :commenting
  },
  glyphicon: {
    option_horizontal: "option-horizontal",
    option_vertical: "option-vertical",
    triangle_left: "triangle-left",
    triangle_right: "triangle-right",
    baby_formula: "baby-formula",
    log_out: "log-out",
    log_in: "log-in",
    collapse_down: "collapse-down",
    globe: :globe,
    zoom_out: "zoom-out",
    close: :remove,
    new_window: "new-window",
    history: :time,
    check_circle_o: "ok-circle",
    check_circle: "ok-sign",
    reorder: "align-justify"
  }

}.freeze

Instance Method Summary collapse

Instance Method Details

#default_icon_libraryObject



98
99
100
# File 'tmpsets/set/mod026-bootstrap/all/bootstrap/icon.rb', line 98

def default_icon_library
  :material
end

#fa_icon(icon, opts = {}) ⇒ Object



80
81
82
# File 'tmpsets/set/mod026-bootstrap/all/bootstrap/icon.rb', line 80

def fa_icon icon, opts={}
  universal_icon_tag icon, :font_awesome, opts
end

#font_awesome_icon_tag(icon, opts = {}) ⇒ Object



107
108
109
110
# File 'tmpsets/set/mod026-bootstrap/all/bootstrap/icon.rb', line 107

def font_awesome_icon_tag icon, opts={}
  prepend_class opts, "fa fa-#{icon_class(:font_awesome, icon)}"
  wrap_with :i, "", opts
end

#glyphicon(icon, opts = {}) ⇒ Object



76
77
78
# File 'tmpsets/set/mod026-bootstrap/all/bootstrap/icon.rb', line 76

def glyphicon icon, opts={}
  universal_icon_tag icon, :glyphicon, opts
end

#glyphicon_icon_tag(icon, opts = {}) ⇒ Object



102
103
104
105
# File 'tmpsets/set/mod026-bootstrap/all/bootstrap/icon.rb', line 102

def glyphicon_icon_tag icon, opts={}
  prepend_class opts, "glyphicon glyphicon-#{icon_class(:glyphicon, icon)}"
  wrap_with :span, "", opts.merge("aria-hidden": true)
end

#icon_class(library, icon) ⇒ Object



68
69
70
# File 'tmpsets/set/mod026-bootstrap/all/bootstrap/icon.rb', line 68

def icon_class library, icon
  ICON_MAP[library][icon] || icon
end

#icon_tag(icon, opts = {}) ⇒ Object



84
85
86
87
88
# File 'tmpsets/set/mod026-bootstrap/all/bootstrap/icon.rb', line 84

def icon_tag icon, opts={}
  opts = { class: opts } unless opts.is_a? Hash
  library = opts.delete(:library) || default_icon_library
  universal_icon_tag icon, library, opts
end

#material_icon(icon, opts = {}) ⇒ Object



72
73
74
# File 'tmpsets/set/mod026-bootstrap/all/bootstrap/icon.rb', line 72

def material_icon icon, opts={}
  universal_icon_tag icon, :material, opts
end

#material_icon_tag(icon, opts = {}) ⇒ Object



112
113
114
115
# File 'tmpsets/set/mod026-bootstrap/all/bootstrap/icon.rb', line 112

def material_icon_tag icon, opts={}
  add_class opts, "material-icons"
  wrap_with :i, icon_class(:material, icon), opts
end

#universal_icon_tag(icon, icon_library = default_icon_library, opts = {}) ⇒ Object



90
91
92
93
94
95
96
# File 'tmpsets/set/mod026-bootstrap/all/bootstrap/icon.rb', line 90

def universal_icon_tag icon, icon_library=default_icon_library, opts={}
  return "" unless icon.present?

  opts = { class: opts } unless opts.is_a? Hash
  icon_method = "#{icon_library}_icon_tag"
  send icon_method, icon, opts
end