Class: Playbook::PbIcon::Icon

Inherits:
KitBase
  • Object
show all
Defined in:
app/pb_kits/playbook/pb_icon/icon.rb

Instance Method Summary collapse

Methods inherited from KitBase

#object

Methods included from NumberSpacing

included

Methods included from ZIndex

included

Methods included from Spacing

included, #max_width_options, #max_width_props, #max_width_values, #spacing_options, #spacing_props, #spacing_values

Methods included from Classnames

#generate_classname, #generate_classname_without_spacing, included

Methods included from Playbook::Props

#initialize, #prop

Methods included from Playbook::PbKitHelper

#pb_rails

Methods included from Playbook::PbFormsHelper

#pb_form_with

Instance Method Details

#classnameObject



36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'app/pb_kits/playbook/pb_icon/icon.rb', line 36

def classname
  generate_classname(
    "pb_icon_kit",
    "far",
    icon_class,
    border_class,
    fixed_width_class,
    flip_class,
    inverse_class,
    list_item_class,
    pull_class,
    pulse_class,
    rotation_class,
    size_class,
    spin_class,
    separator: " "
  )
end

#custom_icon_classnameObject



55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# File 'app/pb_kits/playbook/pb_icon/icon.rb', line 55

def custom_icon_classname
  generate_classname(
    "pb_icon_kit",
    border_class,
    fixed_width_class,
    flip_class,
    inverse_class,
    list_item_class,
    pull_class,
    pulse_class,
    rotation_class,
    size_class,
    spin_class,
    separator: " "
  )
end

#render_svg(path) ⇒ Object



72
73
74
75
76
77
78
79
80
81
# File 'app/pb_kits/playbook/pb_icon/icon.rb', line 72

def render_svg(path)
  if File.extname(path) == ".svg"
    doc = Nokogiri::XML(open(path)) # rubocop:disable Security/Open
    svg = doc.at_css "svg"
    svg["class"] = "pb_custom_icon " + object.custom_icon_classname
    raw doc
  else
    raise("Custom icon must be an svg. Please check your path and file type.")
  end
end