Class: BetterUi::Table::CellComponent

Inherits:
ApplicationComponent show all
Defined in:
app/components/better_ui/table/cell_component.rb

Overview

A table cell component that renders a element.

Used within RowComponent to render individual data cells. Supports text alignment and size-based padding.

Examples:

Basic cell

<%= render BetterUi::Table::CellComponent.new { "Cell content" } %>

Right-aligned cell

<%= render BetterUi::Table::CellComponent.new(align: :right) { "$100.00" } %>

Constant Summary collapse

SIZES =
{
  xs: { padding: "px-2 py-2", text: "text-xs" },
  sm: { padding: "px-3 py-2.5", text: "text-sm" },
  md: { padding: "px-3 py-4", text: "text-sm" },
  lg: { padding: "px-4 py-5", text: "text-base" },
  xl: { padding: "px-6 py-6", text: "text-lg" }
}.freeze
ALIGNMENTS =
%i[left center right].freeze

Constants inherited from ApplicationComponent

ApplicationComponent::SHADOWS, ApplicationComponent::VARIANTS, ApplicationComponent::VARIANT_BODY_DIVIDE, ApplicationComponent::VARIANT_DIVIDE, ApplicationComponent::VARIANT_HEADER_BG, ApplicationComponent::VARIANT_HEADER_TEXT, ApplicationComponent::VARIANT_HIGHLIGHTED, ApplicationComponent::VARIANT_HOVERABLE, ApplicationComponent::VARIANT_RING, ApplicationComponent::VARIANT_SORT_ICON, ApplicationComponent::VARIANT_STRIPED

Instance Method Summary collapse

Constructor Details

#initialize(align: :left, size: :md, style: :default, container_classes: nil, **options) ⇒ CellComponent

Returns a new instance of CellComponent.



26
27
28
29
30
31
32
# File 'app/components/better_ui/table/cell_component.rb', line 26

def initialize(align: :left, size: :md, style: :default, container_classes: nil, **options)
  @align = validate_align(align)
  @size = validate_size(size)
  @style = style
  @container_classes = container_classes
  @options = options
end