Class: Ariadne::TableComponent::RowItem

Inherits:
Component
  • Object
show all
Defined in:
app/components/ariadne/table_component.rb

Overview

This component is part of TableComponent and should not be used as a standalone component.

Direct Known Subclasses

HeaderRowItem, CellItem, HeaderCellItem

Defined Under Namespace

Classes: CellItem, HeaderCellItem

Constant Summary collapse

DEFAULT_ROW_CLASSES =
"ariadne-whitespace-nowrap ariadne-py-4 ariadne-pl-4 ariadne-pr-3 ariadne-text-sm sm:ariadne-pl-6 flex flex-row"

Constants inherited from Component

Component::BASE_BODY_CLASSES, Component::BASE_HTML_CLASSES, Component::BASE_MAIN_CLASSES, Component::BASE_WRAPPER_CLASSES, Component::INVALID_ARIA_LABEL_TAGS

Constants included from ActionViewExtensions::FormHelper

ActionViewExtensions::FormHelper::DEFAULT_FORM_CLASSES

Constants included from Status::Dsl

Status::Dsl::STATUSES

Constants included from ViewHelper

ViewHelper::HELPERS

Constants included from FetchOrFallbackHelper

FetchOrFallbackHelper::INTEGER_TYPES, FetchOrFallbackHelper::InvalidValueError, FetchOrFallbackHelper::TRUE_OR_FALSE

Instance Method Summary collapse

Methods included from ActionViewExtensions::FormHelper

#ariadne_form_with

Methods included from ClassNameHelper

#class_names

Methods included from LoggerHelper

#logger, #silence_deprecations?, #silence_warnings?

Methods included from FetchOrFallbackHelper

#check_incoming_attribute, #check_incoming_tag, #check_incoming_value, #fetch_or_raise, #fetch_or_raise_boolean, #fetch_or_raise_integer

Constructor Details

#initialize(link: "", classes: "", attributes: {}) ⇒ RowItem

Returns a new instance of RowItem.

Parameters:

  • link (Hash) (defaults to: "")

    #TODO: link attributes



74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
# File 'app/components/ariadne/table_component.rb', line 74

def initialize(link: "", classes: "", attributes: {})
  @header = false
  @link = link

  @classes = if @link.present?
    class_names(
      DEFAULT_ROW_CLASSES,
      "ariadne-cursor-pointer",
      classes,
    )
  else
    class_names(
      DEFAULT_ROW_CLASSES,
      classes,
    )
  end

  @attributes = attributes
end

Instance Method Details

#callObject



94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
# File 'app/components/ariadne/table_component.rb', line 94

def call
  render(Ariadne::BaseComponent.new(tag: :li, classes: @classes, attributes: @attributes)) do
    if linked?
      render(Ariadne::LinkComponent.new(href: @link[:href], classes: @link[:classes], attributes: @link[:attributes])) do
        cells.each do |cell|
          concat(cell)
        end
      end
    else
      cells.each do |cell|
        concat(cell)
      end
    end
  end
end