Class: Polaris::SpacerComponent

Inherits:
Component
  • Object
show all
Defined in:
app/components/polaris/spacer_component.rb

Constant Summary collapse

VERTICAL_SPACING_DEFAULT =
:default
VERTICAL_SPACING_MAPPINGS =
{
  VERTICAL_SPACING_DEFAULT => "",
  :extra_tight => "Polaris-Spacer--verticalSpacingExtraTight",
  :tight => "Polaris-Spacer--verticalSpacingTight",
  :base_tight => "Polaris-Spacer--verticalSpacingBaseTight",
  :base => "Polaris-Spacer--verticalSpacingBase",
  :loose => "Polaris-Spacer--verticalSpacingLoose",
  :extra_loose => "Polaris-Spacer--verticalSpacingExtraLoose"
}
VERTICAL_SPACING_OPTIONS =
VERTICAL_SPACING_MAPPINGS.keys
HORIZONTAL_SPACING_DEFAULT =
:default
HORIZONTAL_SPACING_MAPPINGS =
{
  HORIZONTAL_SPACING_DEFAULT => "",
  :extra_tight => "Polaris-Spacer--horizontalSpacingExtraTight",
  :tight => "Polaris-Spacer--horizontalSpacingTight",
  :base_tight => "Polaris-Spacer--horizontalSpacingBaseTight",
  :base => "Polaris-Spacer--horizontalSpacingBase",
  :loose => "Polaris-Spacer--horizontalSpacingLoose",
  :extra_loose => "Polaris-Spacer--horizontalSpacingExtraLoose"
}
HORIZONTAL_SPACING_OPTIONS =
HORIZONTAL_SPACING_MAPPINGS.keys

Constants included from ViewHelper

ViewHelper::POLARIS_HELPERS, ViewHelper::POLARIS_TEXT_STYLES

Constants included from FetchOrFallbackHelper

FetchOrFallbackHelper::InvalidValueError

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(vertical: VERTICAL_SPACING_DEFAULT, horizontal: HORIZONTAL_SPACING_DEFAULT, **system_arguments) ⇒ SpacerComponent

Returns a new instance of SpacerComponent.



29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'app/components/polaris/spacer_component.rb', line 29

def initialize(
  vertical: VERTICAL_SPACING_DEFAULT,
  horizontal: HORIZONTAL_SPACING_DEFAULT,
  **system_arguments
)
  @system_arguments = system_arguments
  @system_arguments[:tag] = "div"
  @system_arguments[:classes] = class_names(
    @system_arguments[:classes],
    "Polaris-Spacer",
    VERTICAL_SPACING_MAPPINGS[fetch_or_fallback(VERTICAL_SPACING_OPTIONS, vertical, VERTICAL_SPACING_DEFAULT)],
    HORIZONTAL_SPACING_MAPPINGS[fetch_or_fallback(HORIZONTAL_SPACING_OPTIONS, horizontal, HORIZONTAL_SPACING_DEFAULT)]
  )
end

Instance Method Details

#callObject



44
45
46
47
48
# File 'app/components/polaris/spacer_component.rb', line 44

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