Class: CubitComponents::PlaceholderComponent

Inherits:
BaseComponent
  • Object
show all
Defined in:
lib/cubit_components/placeholder_component.rb

Constant Summary collapse

DOTTED_GRID_STYLE =
"background-image:radial-gradient(currentColor 1px,transparent 1px);" \
"background-size:16px 16px"

Instance Method Summary collapse

Constructor Details

#initialize(label: nil, tokens: [], as: "div") ⇒ PlaceholderComponent

Returns a new instance of PlaceholderComponent.



17
18
19
20
21
22
23
24
25
# File 'lib/cubit_components/placeholder_component.rb', line 17

def initialize(label: nil, tokens: [], as: "div")
  unless CubitComponents.configuration.placeholder_allowed
    raise PlaceholderNotAllowedError,
      "PlaceholderComponent is only available when placeholder_allowed is enabled " \
      "(dev/test); it is disabled in this environment."
  end
  @label = label
  super(tokens:, as:)
end

Instance Method Details

#callObject



27
28
29
30
31
32
33
34
# File 'lib/cubit_components/placeholder_component.rb', line 27

def call
  (
    tag_name,
    @label,
    class: html_classes.map(&:to_s).join(" "),
    style: DOTTED_GRID_STYLE
  )
end