Class: Ariadne::TableComponent

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

Overview

Add a general description of component here Add additional usage considerations or best practices that may aid the user to use the component correctly.

Defined Under Namespace

Classes: FooterItem, HeaderRowItem, PaginationBarItem, RowItem

Constant Summary collapse

DEFAULT_CLASSES =
"ariadne-min-w-full ariadne-divide-y ariadne-divide-gray-300 flex flex-col"

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(classes: "", attributes: {}) ⇒ TableComponent

<%= render(Ariadne::TableComponent.new) do |table| %>

<%= table.header_row do |header_row| %>
  <% header_row.cell do %>
    State
  <% end %>
<% end %>
<%= table.row do |row| %>
  <% row.cell do %>
    "California"
  <% end %>
<% end %>
<%= table.row do |row| %>
  <% row.cell do %>
    "New York"
  <% end %>
<% end %>
<%= table.row do |row| %>
  <% row.cell do %>
    "Texas"
  <% end %>
<% end %>

<% end %>

Examples:

Default


Parameters:

  • classes (String) (defaults to: "")

    <%= link_to_classes_docs %>

  • attributes (Hash) (defaults to: {})

    <%= link_to_attributes_docs %>



42
43
44
45
46
47
48
49
50
# File 'app/components/ariadne/table_component.rb', line 42

def initialize(classes: "", attributes: {})
  @tag = :div
  @classes = class_names(
    DEFAULT_CLASSES,
    classes,
  )

  @attributes = attributes
end

Instance Method Details

#has_footer?Boolean

Returns:

  • (Boolean)


56
57
58
# File 'app/components/ariadne/table_component.rb', line 56

def has_footer?
  footer.present?
end

#has_header_row?Boolean

Returns:

  • (Boolean)


52
53
54
# File 'app/components/ariadne/table_component.rb', line 52

def has_header_row?
  header_row.present?
end