Skip to content

[Ux] Mobile Table Component#247

Draft
CulmoneY wants to merge 1 commit intomainfrom
yianni/mobile-table-component
Draft

[Ux] Mobile Table Component#247
CulmoneY wants to merge 1 commit intomainfrom
yianni/mobile-table-component

Conversation

@CulmoneY
Copy link
Contributor

TL;DR

Briefly describe what this PR does and why it is needed. Include any relevant background or context.
image


Checklist

  • Changes have been top-hatted locally
  • Tests have been added or updated
  • Documentation has been updated (if applicable)
  • Linked related issues

Copilot AI review requested due to automatic review settings March 13, 2026 03:23
@CulmoneY CulmoneY force-pushed the yianni/mobile-table-component branch from da57861 to 30202f6 Compare March 13, 2026 03:27
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a mobile-friendly rendering for Shared::IndexTableComponent by splitting the existing table markup into dedicated desktop/mobile ViewComponents and updating the Stimulus controller to paginate/filter only the active (visible) layout.

Changes:

  • Introduces DesktopComponent and MobileComponent variants for the index table UI.
  • Updates Shared::IndexTableComponent to render the new subcomponents and centralizes helpers (column_sizes, empty state text, cell renderer).
  • Adjusts the Stimulus controller to handle multiple layouts/targets and refresh on window resize.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
app/javascript/controllers/index_table_component_controller.js Refreshes active rows by visible layout; updates empty state + pagination across desktop/mobile targets.
app/components/shared/index_table_component.rb Adds helper methods to support rendering via subcomponents.
app/components/shared/index_table_component.html.erb Renders new desktop/mobile subcomponents and hooks resize refresh action.
app/components/shared/index_table_component/desktop_component.rb New ViewComponent class for desktop layout.
app/components/shared/index_table_component/desktop_component.html.erb Desktop layout markup extracted from original component template.
app/components/shared/index_table_component/mobile_component.rb New ViewComponent class for mobile layout.
app/components/shared/index_table_component/mobile_component.html.erb Mobile card-based layout markup for small screens.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

<div data-controller="index-table-component" data-index-table-component-per-page-value="<%= per_page %>">
<div
data-controller="index-table-component"
data-action="resize@window->index-table-component#refreshLayout"
Comment on lines +1 to +14
module Shared
class IndexTableComponent
class DesktopComponent < ViewComponent::Base
attr_reader :records, :columns, :column_sizes, :empty_state_text, :cell_content_renderer

def initialize(records:, columns:, column_sizes:, empty_state_text:, cell_content_renderer:)
super()
@records = records
@columns = columns
@column_sizes = column_sizes
@empty_state_text = empty_state_text
@cell_content_renderer = cell_content_renderer
end
end
Comment on lines +1 to +27
module Shared
class IndexTableComponent
class MobileComponent < ViewComponent::Base
attr_reader :records, :columns, :empty_state_text, :cell_content_renderer

def initialize(records:, columns:, empty_state_text:, cell_content_renderer:)
super()
@records = records
@columns = columns
@empty_state_text = empty_state_text
@cell_content_renderer = cell_content_renderer
end

def content_columns
columns.reject { |column| action_column?(column) }
end

def actions_column
columns.find { |column| action_column?(column) }
end

private

def action_column?(column)
column.attribute.to_sym == :actions
end
end
Comment on lines +88 to +115
_updatePagination(lastPage) {
this.paginationTargets.forEach((container, index) => {
const layout = container.closest("[data-index-table-component-layout]");
const isActive = layout && window.getComputedStyle(layout).display !== "none";

if (!isActive || lastPage === 0) {
container.classList.add("hidden");
} else {
container.classList.remove("hidden");
}

const prevBtn = container.querySelector("[data-prev]");
const nextBtn = container.querySelector("[data-next]");

if (prevBtn) {
prevBtn.disabled = this._page === 0;
prevBtn.classList.toggle("btn-disabled", this._page === 0);
}

if (nextBtn) {
nextBtn.disabled = this._page === lastPage;
nextBtn.classList.toggle("btn-disabled", this._page === lastPage);
}

const pageInfo = this.pageInfoTargets[index];
if (pageInfo) {
pageInfo.textContent = `${this._page + 1} of ${lastPage + 1}`;
}
@CulmoneY CulmoneY marked this pull request as draft March 16, 2026 16:22
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