Class: Primer::OpenProject::GridLayout::Area

Inherits:
Component
  • Object
show all
Defined in:
app/components/primer/open_project/grid_layout/area.rb

Overview

GridLayout::Area is an internal component that wraps the items in a div with the given new class and responding “grid-area”

Constant Summary collapse

DEFAULT_TAG =
:div
TAG_OPTIONS =
[DEFAULT_TAG, :span].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

FetchOrFallbackHelper::InvalidValueError

Constants included from AttributesHelper

AttributesHelper::PLURAL_ARIA_ATTRIBUTES, AttributesHelper::PLURAL_DATA_ATTRIBUTES

Instance Method Summary collapse

Methods inherited from Component

deprecated?, generate_id

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

Methods included from AttributesHelper

#aria, #data, #extract_data, #merge_aria, #merge_data, #merge_prefixed_attribute_hashes

Methods included from ExperimentalSlotHelpers

included

Methods included from ExperimentalRenderHelpers

included

Constructor Details

#initialize(css_class, area_name, component = ::Primer::BaseComponent, tag: DEFAULT_TAG, **system_arguments) ⇒ Area

Returns a new instance of Area.

Parameters:

  • css_class (String)

    The basic css class applied on the grid-container

  • area_name (Symbol)

    The specific area name, used for creating the element class and the “grid-area” style

  • component (ViewComponent::Base) (defaults to: ::Primer::BaseComponent)

    The instance of the component to be rendered.

  • tag (Symbol) (defaults to: DEFAULT_TAG)

    <%= one_of(Primer::OpenProject::GridLayout::Area::TAG_OPTIONS) %>

  • system_arguments (Hash)

    <%= link_to_system_arguments_docs %>



18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'app/components/primer/open_project/grid_layout/area.rb', line 18

def initialize(css_class, area_name, component = ::Primer::BaseComponent, tag: DEFAULT_TAG, **system_arguments)
  @component = component
  @system_arguments = system_arguments
  @styles = [
    "grid-area: #{area_name}"
  ]
  @system_arguments[:tag] = fetch_or_fallback(TAG_OPTIONS, tag, DEFAULT_TAG)
  @system_arguments[:style] = join_style_arguments(@system_arguments[:style], *@styles)
  @system_arguments[:classes] = class_names(
    @system_arguments[:classes],
    "#{css_class}--#{area_name}"
  )
end

Instance Method Details

#callObject



32
33
34
# File 'app/components/primer/open_project/grid_layout/area.rb', line 32

def call
  render(@component.new(**@system_arguments)) { content }
end