Class: Primer::FlexItemComponent Deprecated

Inherits:
Component
  • Object
show all
Defined in:
app/components/primer/flex_item_component.rb

Overview

Deprecated.

Use <%= link_to_component(Primer::BoxComponent) %> instead.

Before:

“‘erb <%%= render Primer::FlexItemComponent.new(flex_auto: :auto) %> “`

After:

“‘erb <%%= render Primer::BoxComponent.new(flex: :auto) %> “`

Use ‘FlexItem` to specify the ability of a flex item to alter its dimensions to fill available space.

Constant Summary collapse

FLEX_AUTO_DEFAULT =
false
FLEX_AUTO_ALLOWED_VALUES =
[FLEX_AUTO_DEFAULT, true].freeze

Constants inherited from Component

Component::INVALID_ARIA_LABEL_TAGS

Constants included from Status::Dsl

Status::Dsl::STATUSES

Constants included from ViewHelper

ViewHelper::HELPERS

Constants included from TestSelectorHelper

TestSelectorHelper::TEST_SELECTOR_TAG

Constants included from FetchOrFallbackHelper

Primer::FetchOrFallbackHelper::InvalidValueError

Instance Method Summary collapse

Methods included from JoinStyleArgumentsHelper

#join_style_arguments

Methods included from TestSelectorHelper

#add_test_selector

Methods included from FetchOrFallbackHelper

#fetch_or_fallback, #fetch_or_fallback_boolean, #silence_deprecations?

Methods included from ClassNameHelper

#class_names

Constructor Details

#initialize(flex_auto: FLEX_AUTO_DEFAULT, **system_arguments) ⇒ FlexItemComponent

Returns a new instance of FlexItemComponent.

Examples:

Default

<%= render(Primer::FlexComponent.new) do %>
  <%= render(Primer::FlexItemComponent.new) do %>
    Item 1
  <% end %>

  <%= render(Primer::FlexItemComponent.new(flex_auto: true)) do %>
    Item 2
  <% end %>
<% end %>

Parameters:

  • flex_auto (Boolean) (defaults to: FLEX_AUTO_DEFAULT)

    Fills available space and auto-sizes based on the content. Defaults to <%= Primer::FlexItemComponent::FLEX_AUTO_DEFAULT %>

  • system_arguments (Hash)

    <%= link_to_system_arguments_docs %>



40
41
42
43
44
45
46
47
48
49
# File 'app/components/primer/flex_item_component.rb', line 40

def initialize(flex_auto: FLEX_AUTO_DEFAULT, **system_arguments)
  deprecated_component_warning(new_class: Primer::BoxComponent, version: "0.0.40")

  @system_arguments = system_arguments
  @system_arguments[:classes] =
    class_names(
      @system_arguments[:classes],
      "flex-auto" => fetch_or_fallback(FLEX_AUTO_ALLOWED_VALUES, flex_auto, FLEX_AUTO_DEFAULT)
    )
end

Instance Method Details

#callObject



51
52
53
# File 'app/components/primer/flex_item_component.rb', line 51

def call
  render(Primer::BoxComponent.new(**@system_arguments)) { content }
end