Add responsive DataTable feature with configurable breakpoints#259
Open
alexandre-castelain wants to merge 5 commits into
Open
Add responsive DataTable feature with configurable breakpoints#259alexandre-castelain wants to merge 5 commits into
alexandre-castelain wants to merge 5 commits into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds opt-in responsive support to data tables, letting columns collapse a configurable breakpoint instead of being rendered at every viewport.
The goal is to make tables usable on narrow viewports without consumers having write custom CSS or duplicate column configurations.
Motivation
Data tables render poorly on small viewports when they contain many columns.
Today, consumers have to either hide columns via external CSS (brittle) or maintain per-device column configurations by hand. A first-class breakpoint inside the bundle solves this once, in a way that integrates with the column priority / visibility / personalization features.
Design
sm: 576,md: 768,lg: 992,xl: 1200) but can be overridden globally or perDataTableType.) and sent as a raw pixel value. PHP then resolves the breakpoint viaBreakpointResolver`. This means a table displayed in a sidebar and one displayed full-width can resolve different breakpoints on the same screen.UserAgentDeviceDetectorprovides a server-side fallback (for the initial render, before JS measures the viewport) based on estimated widths.visible_from: 'md'(string | false | null) controls the minimum breakpoint at which a column is rendered.responsive_enabledglobal flag and per-table override. Existing tables are unaffected.bootstrap_5_responsive.html.twig,tabler_responsive.html.twig) and a_responsive.html.twigpartial for reuse in custom themes.Backwards compatibility
No breaking changes. The feature is opt-in:
responsive_enableddefaults tofalseand existingDataTableTypes behave exactly as before.Open questions for maintainers
visible_fromvs.breakpointvs. something else for the column option? I pickedvisible_fromfor symmetry with the existingvisibleoption, but open to whatever matches your conventions.sm/md/lg/xl. Would you prefer unitless / framework-agnostic names, or keep Bootstrap aliases since one of the built-in themes already targets Bootstrap 5?Thanks for the bundle — happy to iterate on review.