Class: Polaris::InlineComponent

Inherits:
Component
  • Object
show all
Includes:
ActiveModel::Validations
Defined in:
app/components/polaris/inline_component.rb

Constant Summary collapse

ALIGN_DEFAULT =
:start
ALIGN_OPTIONS =
%i[start center end space-around space-between space-evenly]
BLOCK_ALIGN_DEFAULT =
:center
BLOCK_ALIGN_OPTIONS =
%i[start center end baseline stretch]
GAP_DEFAULT =
4
WRAP_DEFAULT =
true

Constants included from ViewHelper

ViewHelper::POLARIS_HELPERS, ViewHelper::POLARIS_TEXT_STYLES

Constants included from FetchOrFallbackHelper

FetchOrFallbackHelper::InvalidValueError

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from ViewHelper

#polaris_body_styles, #polaris_html_classes, #polaris_html_styles, #polaris_icon_source

Methods included from StylesListHelper

#styles_list

Methods included from OptionHelper

#append_option, #prepend_option

Methods included from FetchOrFallbackHelper

#fetch_or_fallback, #fetch_or_fallback_boolean, #fetch_or_fallback_nested

Methods included from ClassNameHelper

#class_names

Constructor Details

#initialize(align: ALIGN_DEFAULT, block_align: BLOCK_ALIGN_DEFAULT, gap: GAP_DEFAULT, wrap: WRAP_DEFAULT, **system_arguments) ⇒ InlineComponent

Returns a new instance of InlineComponent.



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

def initialize(
  align: ALIGN_DEFAULT,
  block_align: BLOCK_ALIGN_DEFAULT,
  gap: GAP_DEFAULT,
  wrap: WRAP_DEFAULT,
  **system_arguments
)
  @system_arguments = system_arguments

  @system_arguments[:tag] = :div
  @system_arguments[:classes] = class_names(
    @system_arguments[:classes],
    "Polaris-Inline"
  )
  @system_arguments[:style] = "--pc-inline-align: #{align}; --pc-inline-block-align: #{block_align}; --pc-inline-wrap: #{wrap ? :wrap : :nowrap}; --pc-inline-gap-xs: var(--p-space-#{gap})"
end

Instance Attribute Details

#alignObject (readonly)

Returns the value of attribute align.



7
8
9
# File 'app/components/polaris/inline_component.rb', line 7

def align
  @align
end

#block_alignObject (readonly)

Returns the value of attribute block_align.



7
8
9
# File 'app/components/polaris/inline_component.rb', line 7

def block_align
  @block_align
end

#gapObject (readonly)

Returns the value of attribute gap.



7
8
9
# File 'app/components/polaris/inline_component.rb', line 7

def gap
  @gap
end

#wrapObject (readonly)

Returns the value of attribute wrap.



7
8
9
# File 'app/components/polaris/inline_component.rb', line 7

def wrap
  @wrap
end

Instance Method Details

#callObject



40
41
42
# File 'app/components/polaris/inline_component.rb', line 40

def call
  render(Polaris::BaseComponent.new(**@system_arguments)) { content }
end