Class: Spark::Block

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

Direct Known Subclasses

Header

Constant Summary collapse

GUTTER =
%i[small base medium large xl].freeze
LAYOUT =
%i[flush padded].freeze
SPACER_SIZE =
%i[base].freeze

Instance Method Summary collapse

Methods inherited from Component::Base

#selector, #to_s, #unique_id

Constructor Details

#initializeBlock

Returns a new instance of Block.



53
54
55
56
57
58
59
60
61
62
# File 'app/components/spark/block.rb', line 53

def initialize(*)
  super

  classname.base = "spark-block"
  classname.add("gutter-#{@gutter}")
  classname.add("action-gutter-#{@action_gutter}")
  classname.add("flex-no-wrap") unless @wrap
  classname.add("layout-#{@layout}")
  tag_attrs.add(role: @role)
end

Instance Method Details

#content_only?Boolean

When direct content is passed but no item or action elements are used

Returns:

  • (Boolean)


65
66
67
# File 'app/components/spark/block.rb', line 65

def content_only?
  items.empty? && actions.empty? && @content.present?
end