Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SAGE-757] Table - responsive updates #1573

Draft
wants to merge 16 commits into
base: develop
Choose a base branch
from

Conversation

QuintonJason
Copy link
Contributor

@QuintonJason QuintonJason commented Aug 29, 2022

Description

Repurposes table markup for a "stacked" visual layout on small screens.

  • Table structure semantics are affected when setting display. Each default role has been added back in with JS.
  • We're using JS to duplicate table header (th) text into each individual cell td as span elements. The actual table headers are visually hidden but remain readable for screen readers, keeping existing semantics/relationship with cells intact.

Requirements:

  • responsive_stack property must be enabled
  • Existing is_responsive property can still be set independently, and will take effect on larger screen sizes OR when mobile stack content overflows its container
  • JS runs on page load/init only to minimize reflow. The expectation being that users will not switch between multiple viewports, so adding a listener for resize should not be needed

Current assumptions:

  • headers are required for tables
  • cells will have a max of 4 children
    • example: multiple tags/badges within a cell
  • truncated text is disabled on mobile
    • max-width set on truncated text causes issue with cell width layout
  • some specific content will always be hidden when "stacked"
    • avatars: use varying nested containers

TODOs

  • Design: confirm moving row selection checkbox (in table header) to bulk actions
  • Design: confirm patterns:
    • does this apply to all tables, or only special cases?
    • if all tables, strict rules will be needed to enforce markup order/structure
    • verify overflow approach
  • account for React headers schema override
  • investigate simplified use of dropdowns with sage_table_for - requires nested string(s)/schema
  • investigate "action" column container for checkbox, avatar, options content

Screenshots

Before After
Standard table rails after-table-stack
Using sage_table_for before-table-for after-table-for-stack

Testing in sage-lib

Visit the table view and verify that the mobile view aligns with the design spec

Testing in kajabi-products

⚠️ Note: when testing the responsive view using browser devtools, you must refresh the page after resizing (see description above, under Requirements)

  1. (HIGH) Update mobile styles for Table.
    • People Page

Related

Closes SAGE-757

@QuintonJason QuintonJason self-assigned this Aug 29, 2022
@QuintonJason QuintonJason added the improvement Improve on existing work label Aug 29, 2022
@QuintonJason QuintonJason changed the title [SAGE-757] Table - responsive [SAGE-757] Table - responsive updates Aug 29, 2022
@QuintonJason QuintonJason force-pushed the SAGE-757/qj-table-responsive branch 2 times, most recently from eda642a to 3750449 Compare September 9, 2022 00:37
@teenwolfblitzer teenwolfblitzer force-pushed the SAGE-757/qj-table-responsive branch 2 times, most recently from dc30519 to 086ddaa Compare November 9, 2022 01:48
@teenwolfblitzer teenwolfblitzer force-pushed the SAGE-757/qj-table-responsive branch from 086ddaa to 0411d30 Compare November 10, 2022 22:57
@teenwolfblitzer teenwolfblitzer force-pushed the SAGE-757/qj-table-responsive branch from 0411d30 to 50f2118 Compare November 21, 2022 18:50
@teenwolfblitzer teenwolfblitzer force-pushed the SAGE-757/qj-table-responsive branch from 50f2118 to 3263a9a Compare December 3, 2022 02:07
table_classlist << " sage-table--condensed" if table.condensed
table_classlist << " sage-table--has-leading-input" if table.has_leading_input
table_classlist << " sage-table--has-menu-options" if table.has_menu_options
table_classlist << " sage-table--stack" if table.responsive_stack
Copy link
Member

@teenwolfblitzer teenwolfblitzer Dec 6, 2022

Choose a reason for hiding this comment

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

Will need to clarify with design here:

I've created a new prop responsive_stack rather than repurposing is_responsive. This is all under the assumption that we want to maintain maximum backwards compatibility with overflow/scrolling tables since the responsive stack layout conditions are somewhat stringent. Retrofitting all current table uses is not likely to be a trivial effort.

tableHeadings.push(label);
})

rows.forEach(row => {
Copy link
Member

Choose a reason for hiding this comment

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

Using multiple nested loops to dig into the table markup. Probably not ideal, but I'm not sure we have much of an alternative. Performance impact should be minimal with the majority of cases rendering paginated results.

<%= "sage-table--condensed" if component.condensed %>
"
<table
class="<%= sage_table_classes(component) %>"
Copy link
Member

Choose a reason for hiding this comment

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

Moved CSS class output logic to sage_table_helper

@teenwolfblitzer teenwolfblitzer force-pushed the SAGE-757/qj-table-responsive branch from 98a2550 to 79a813a Compare December 6, 2022 17:36
@teenwolfblitzer teenwolfblitzer self-assigned this Dec 7, 2022
@teenwolfblitzer teenwolfblitzer force-pushed the SAGE-757/qj-table-responsive branch from 034eb39 to f783196 Compare December 13, 2022 17:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
improvement Improve on existing work WIP
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants