Class: Spark::Placeholder

Inherits:
Component::Base show all
Defined in:
app/components/spark/placeholder.rb

Constant Summary collapse

SIZE =
{ sm: 24, md: 32, lg: 44, xl: 84 }
THEME =
{
  default: {
    text: "#ffffff",
    fill: "#78858A"
  },
  gradient: {
    gradient: %w[#616c70 #959fa3],
    fill: "#78858A"
  },
  wisteria: {
    gradient: %w[#A8A2EC #5853AE]
  }
}

Instance Method Summary collapse

Methods inherited from Component::Base

#selector, #to_s, #unique_id

Constructor Details

#initializePlaceholder

Returns a new instance of Placeholder.



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'app/components/spark/placeholder.rb', line 23

def initialize(*)
  super

  aria.add(hidden: true)
  classname.base = "spark-icon-placeholder-wrapper" unless @remote

  @height ||= @width ||= SIZE[@size]
  tag_attrs.add(attr_hash(:width, :height))
  aria.add attr_hash(:alt)

  return if @remote

  raise no_icon_found if @icon && !Rails.env.production? && !Esvg.find_symbol(@icon)

  classname.add("spark-icon-placeholder")
  tag_attrs.add(svg_attrs)
end

Instance Method Details

#optionsObject



41
42
43
44
45
46
47
# File 'app/components/spark/placeholder.rb', line 41

def options
  return @options if @options

  @options ||= attr_hash(:width, :height, :alt, :text)
  @options[:class] = shape_class
  @options
end