Skip to content

feat(data_table_avo): Avo-inspired server-rendered data table#452

Draft
cirdes wants to merge 52 commits intomainfrom
da-datatable-avo
Draft

feat(data_table_avo): Avo-inspired server-rendered data table#452
cirdes wants to merge 52 commits intomainfrom
da-datatable-avo

Conversation

@cirdes
Copy link
Copy Markdown
Contributor

@cirdes cirdes commented Apr 16, 2026

Summary

Adds a new DataTableAvo component family as an alternative to the existing TanStack-based DataTable. Every interaction (sort, pagination, search, filter) is a Rails request answered with HTML and swapped via <turbo-frame> — no client-side table state for data.

  • Architecture: inspired by Avo's ResourceTableComponent — server-rendered, Turbo Frame for partial updates, query params carry state.
  • Composition API: mirrors shadcn's data-table — consumer composes Table / Header / Body / Row / Head / Cell primitives. We copy these primitives (same Tailwind classes as the existing RubyUI::Table*) into the DataTableAvo* namespace so the component family is self-contained.
  • Shadcn feature parity: filter input, sortable headers, "Columns" dropdown, row selection with select-all, "X of N row(s) selected", per-row actions dropdown, Previous/Next pagination.
  • Client-side state (selection, column visibility, dropdown open) is handled by a small Stimulus controller (~80 lines) and resets on Turbo Frame navigation — by design, matches the server-first philosophy.

What's included

16 new components under app/components/ruby_ui/data_table_avo/:

  • 8 shadcn primitive copies: DataTableAvoTable, DataTableAvoHeader, DataTableAvoBody, DataTableAvoFooter, DataTableAvoRow, DataTableAvoHead, DataTableAvoCell, DataTableAvoCaption
  • 7 Avo-specific: DataTableAvo (Turbo Frame wrapper), DataTableAvoSortHead, DataTableAvoPagination, DataTableAvoToolbar, DataTableAvoSearch, DataTableAvoColumnToggle, DataTableAvoSelectionSummary

1 Stimulus controller app/javascript/controllers/ruby_ui/data_table_avo_controller.js — handles ephemeral UI state only (selection, column visibility, dropdown open). No data-fetching JS.

Docs page at /docs/data_table_avo with sidebar entry, inline preview, props reference, and "when to use this vs DataTable" table.

Refactor: extracts shared EMPLOYEES demo data into Docs::DataTableDemoData module (reused by both TanStack and Avo demo controllers). Sort also uses numeric comparison when the column value is Numeric (was previously string-coerced).

Screenshots

  • Demo renders with shadcn parity (same filter / Columns / checkboxes / actions / labeled Prev-Next) — validated in headless Chrome.
  • Page available at /docs/data_table_avo with sidebar entry "Data Table (Avo)".
Screen.Recording.2026-04-16.at.19.20.56.mov

Notes for reviewers

  • This branches off da-datatable-test, so the PR diff includes the whole DataTable (TanStack) work as well. The delta specific to this change is the app/components/ruby_ui/data_table_avo/ folder plus the small edits to docs_controller.rb, routes.rb, menu.rb, index.js, and the extraction of DataTableDemoData.
  • Row selection is intentionally ephemeral (resets on sort/page/search). Persistent cross-page selection (Avo-style encrypted query) is out of scope for this PR.
  • bundle exec standardrb passes on all new/changed files.

Test plan

  • Visit /docs/data_table_avo — docs page loads, preview renders inline
  • Click column headers to sort (asc → desc → none); URL updates, only frame re-renders
  • Use "Filter emails..." input; search resets to page 1
  • Click "Columns" dropdown; toggle Email/Department/Status/Salary — cells hide/show
  • Check a row checkbox — "X of 5 row(s) selected" updates
  • Click select-all — all rows toggle
  • Click a row's — actions menu opens (Copy ID / View details / View payments)
  • Navigate Previous/Next; selection/columns reset (expected)
  • Visit /docs/data_table — TanStack variant still works after EMPLOYEES refactor
  • Sidebar shows "Data Table (Avo)" with "New" badge

🤖 Generated with Claude Code

- Add DataTable component files and Stimulus controller
- Add docs page with live search, sort, and pagination demo
- Add demo controller with fake employee data
- Add route, controller action, and menu entry
djalmaaraujo and others added 22 commits April 15, 2026 20:45
Adds `DataTableAvo` component family as an alternative to the TanStack-based
`DataTable`. Every interaction (sort, pagination, search, filter) is a Rails
request answered with HTML, swapped via `<turbo-frame>`.

Architecture inspired by Avo's `ResourceTableComponent`; composition API
mirrors shadcn's data-table demo (Table / TableHeader / TableBody / TableRow /
TableHead / TableCell) — primitives are copies of the existing shadcn-style
ones, namespaced under `DataTableAvo*` for full autonomy.

Features replicated from shadcn's data-table:
  - Filter input (Turbo-Frame GET form)
  - Sortable column headers with asc/desc/none cycle
  - "Columns" dropdown for client-side column visibility
  - Row selection checkboxes + select-all
  - "X of N row(s) selected" summary
  - Per-row actions dropdown
  - "Previous" / "Next" pagination with preserved query params

Client-side state (selection, column visibility, dropdown open) is handled
by a small Stimulus controller and resets on Turbo Frame navigation — by
design, matches the server-first Avo philosophy.

Also:
  - Extracts shared EMPLOYEES demo data into `Docs::DataTableDemoData` module
    reused by both DataTable and DataTableAvo demo controllers
  - Sort uses numeric comparison when the column value is Numeric
  - Docs page at /docs/data_table_avo with sidebar entry

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants