class RailsFeather::RailsFeather
Attributes
options[R]
Public Class Methods
new(icon, size: 24, stroke_width: 2, **options)
click to toggle source
# File lib/rails_feather/rails_feather.rb, line 5 def initialize(icon, size: 24, stroke_width: 2, **options) @icon = icon.to_s @options = options @options.merge!(a11y) @options.merge!({ fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", version: 1.1, width: size, height: size, "stroke-width": stroke_width, "stroke-linecap": "round", "stroke-linejoin": "round" }) end
Public Instance Methods
svg_path()
click to toggle source
Finds the svg icon with respect to variant.
# File lib/rails_feather/rails_feather.rb, line 24 def svg_path file_path = "#{ICON_PATH}/#{@icon}.svg" raise "Couldn't find icon for #{@icon}" unless File.exist?(file_path) File.read(file_path) end
Private Instance Methods
a11y()
click to toggle source
# File lib/rails_feather/rails_feather.rb, line 33 def a11y accessible = {} if @options[:"aria-label"].nil? && @options["aria-label"].nil? && @options.dig(:aria, :label).nil? accessible[:"aria-hidden"] = "true" else accessible[:role] = "img" end accessible end