Sha256: 41dfb9a78a38f02eb15530359958f1028383c25c223bfd0d884d4e7d9ffd6d05
Contents?: true
Size: 865 Bytes
Versions: 8
Compression:
Stored size: 865 Bytes
Contents
# frozen_string_literal: true module PandaCms module Admin class TableComponent < ViewComponent::Base attr_reader :columns def initialize(rows:) @rows = rows @columns = [] end def column(label, &) @columns << Column.new(label, &) end private # Ensures @columns gets populated [https://dev.to/rolandstuder/supercharged-table-component-built-with-viewcomponent-3j6i] def before_render content end end class Column attr_reader :label, :cell def initialize(label, &block) @label = label @cell = block end end class TagColumn < Column attr_reader :label, :cell def initialize(label, &block) @label = label @cell = PandaCms::Admin::TagComponent.new(status: block) end end end end
Version data entries
8 entries across 8 versions & 1 rubygems