Sha256: f1d209b13095ba1df6ba1aba2e5df8f08ea466b75c1ffebaf4638bb5fdb2782c
Contents?: true
Size: 1.69 KB
Versions: 2
Compression:
Stored size: 1.69 KB
Contents
module Components::TableHelper def render_table(caption = nil, **options, &block) content_tag :table, options.reverse_merge( class: tw("w-full text-sm border-b", options[:class]) ) do if caption.present? content_tag :caption, caption, class: "mt-4 text-sm text-muted-foreground " do capture(&block) end else capture(&block) end end end def table_head(**options, &block) content_tag :thead, options.reverse_merge( class: tw("[&_tr]:border-b", options[:class]) ) do content_tag :tr, class: "border-b transition-colors hover:bg-muted/50 data-[state=selected]:bg-muted" do capture(&block) end end end def table_header(content = nil, **options, &block) content_tag :th, options.reverse_merge( class: tw("h-12 px-4 text-left align-middle font-medium text-muted-foreground [&:has([role=checkbox])]:pr-0", options[:class]) ) do if block capture(&block) else content end end end def table_body(**options, &block) content_tag :tbody, class: options.reverse_merge( class: tw("[&_tr:last-child]:border-0", options[:class]) ), &block end def table_row(**options, &block) content_tag :tr, options.reverse_merge( class: tw("border-b transition-colors hover:bg-muted/50 data-[state=selected]:bg-muted", options[:class]) ), &block end def table_column(content = nil, **options, &block) content_tag :td, options.reverse_merge( class: tw("p-4 align-middle [&:has([role=checkbox])]:pr-0 font-medium", options[:class]) ) do if block capture(&block) else content end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
shadcn-ui-0.0.13 | app/helpers/components/table_helper.rb |
shadcn-ui-0.0.12 | app/helpers/components/table_helper.rb |