Class: BetterUi::Table::HeaderCellComponent
- Inherits:
-
ApplicationComponent
- Object
- ViewComponent::Base
- ApplicationComponent
- BetterUi::Table::HeaderCellComponent
- Includes:
- Concerns::SortIcons
- Defined in:
- app/components/better_ui/table/header_cell_component.rb
Overview
A table header cell component that renders a <th> element.
Used within HeaderComponent to render column headers. Supports text alignment, size-based padding, and label text.
Constant Summary collapse
- SIZES =
{ xs: { padding: "px-2 py-1.5", text: "text-xs" }, sm: { padding: "px-3 py-2", text: "text-sm" }, md: { padding: "px-3 py-3.5", text: "text-sm" }, lg: { padding: "px-4 py-4", text: "text-base" }, xl: { padding: "px-6 py-5", text: "text-lg" } }.freeze
- ALIGNMENTS =
i[left center right].freeze
- SORT_DIRECTIONS =
i[asc desc].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
-
#initialize(label: nil, align: :left, size: :md, style: :default, scope: :col, variant: :primary, sortable: false, sorted: false, sort_direction: :asc, sort_url: nil, sort_html: {}, container_classes: nil, **options) ⇒ HeaderCellComponent
constructor
A new instance of HeaderCellComponent.
Constructor Details
#initialize(label: nil, align: :left, size: :md, style: :default, scope: :col, variant: :primary, sortable: false, sorted: false, sort_direction: :asc, sort_url: nil, sort_html: {}, container_classes: nil, **options) ⇒ HeaderCellComponent
Returns a new instance of HeaderCellComponent.
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'app/components/better_ui/table/header_cell_component.rb', line 28 def initialize(label: nil, align: :left, size: :md, style: :default, scope: :col, variant: :primary, sortable: false, sorted: false, sort_direction: :asc, sort_url: nil, sort_html: {}, container_classes: nil, **) @label = label @align = validate_align(align) @size = validate_size(size) @style = style @scope = scope&.to_s @variant = variant @sortable = sortable @sorted = sorted @sort_direction = validate_sort_direction(sort_direction) @sort_url = sort_url @sort_html = sort_html || {} @container_classes = container_classes = end |