Skip to content

Conversation

@msynk
Copy link
Member

@msynk msynk commented Sep 9, 2025

closes #11349

Summary by CodeRabbit

  • New Features
    • Added a responsive DataGrid demo and responsive styles; cells now include titles for small screens.
  • Style
    • Refreshed DataGrid and Paginator visuals: new root classes, cleaner headers/cells, new sort indicator, zebra-striping, refined loading state, updated alignment, column options, and resize handles.
  • Refactor
    • Standardized CSS class names across DataGrid and Paginator to new prefixes for consistency.
  • Documentation
    • Simplified and unified demo samples, standardized search placeholders, added flag and action columns, introduced a responsive demo, and adjusted paginator display in examples.

@coderabbitai
Copy link

coderabbitai bot commented Sep 9, 2025

Important

Review skipped

Auto incremental reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Walkthrough

Component-wide class tokens and selectors for BitDataGrid and its paginator were renamed and restructured across Razor, C#, SCSS, and TypeScript. Data cells now include a data-title attribute. Demo pages and styles were simplified, a responsive demo/sample was added, and one demo model property was renamed from MedalsModel to Medals.

Changes

Cohort / File(s) Summary
DataGrid markup and behavior tokens
src/BlazorUI/Bit.BlazorUI.Extras/Components/DataGrid/BitDataGrid.razor, .../BitDataGrid.razor.cs, .../Columns/BitDataGridColumnBase.razor, .../BitDataGrid.ts
Renamed CSS class tokens (root: bitdatagrid→bit-dtg; headers, sort states, alignment, options, drag handle). Added data-title on data cells. Updated TS selectors for options (.bit-dtg-cop) and drag handle (.bit-dtg-drg). No public API changes.
DataGrid styles
src/BlazorUI/Bit.BlazorUI.Extras/Components/DataGrid/BitDataGrid.scss
Switched to .bit-dtg scope; overhauled header/cell/layout helpers; reworked sort indicator (bit-dtg-srt) and state classes (bit-dtg-csa/csd); updated padding and loading styles; renamed/remapped numerous selectors; pared back RTL rules (commented).
Paginator component and styles
src/BlazorUI/Bit.BlazorUI.Extras/Components/DataGrid/Pagination/BitDataGridPaginator.razor, .../BitDataGridPaginator.scss
Renamed classes to bit-dgp*; introduced .bit-dgp-nav and .bit-dgp-txt; updated icon pseudo-elements and RTL transforms; structure and behavior unchanged.
Demo Razor pages
src/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Pages/Components/Extras/DataGrid/BitDataGridDemo.razor
Simplified demos, flattened wrappers, standardized placeholders, added responsive sample; added template columns in customized sample; updated attributes (boolean flags).
Demo code-behind
src/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Pages/Components/Extras/DataGrid/BitDataGridDemo.razor.cs
Explicit private fields; added pagination6; added Virtual/OData name filters that trigger RefreshDataAsync on set; no signature changes.
Demo samples and model
src/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Pages/Components/Extras/DataGrid/BitDataGridDemo.razor.samples.cs
Unified sample patterns; added responsive example code; renamed CountryModel property from MedalsModel to Medals; adjusted datasets accordingly.
Demo styles
src/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Pages/Components/Extras/DataGrid/BitDataGridDemo.razor.scss
Replaced .grid1/.grid2/.grid3 with .custom-grid/.grid; added .responsive-grid for stacked mobile layout using data-title; updated table/header/body styling and zebra-striping; added .flag hook.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant U as User
  participant DG as BitDataGrid (demo: Virtual/OData)
  participant VM as Demo Page (Filters)
  participant P as ItemsProvider

  U->>VM: Update search input
  VM->>VM: Set filter property
  VM->>DG: RefreshDataAsync()
  DG->>P: Request data (with filter, pagination, sort)
  P-->>DG: Return items + total count
  DG-->>U: Render rows (td[data-title=col.Title])
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Pre-merge checks (2 passed, 2 warnings, 1 inconclusive)

❌ Failed checks (2 warnings, 1 inconclusive)
Check name Status Explanation Resolution
Out of Scope Changes Check ⚠️ Warning This PR includes extensive renaming of internal CSS classes and string tokens across the BitDataGrid component, TypeScript, and SCSS files, which goes beyond the scope of demonstrating a responsive sample and introduces core refactoring unrelated to the linked issue. Please split out the core CSS and markup refactoring into a separate pull request so that this PR focuses solely on adding the responsive demo sample.
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
Description Check ❓ Inconclusive The current description only references closing issue #11349 and does not describe the changes introduced, making it too vague to convey the purpose of the pull request. Please update the description to include a brief summary of the responsive sample addition and how it addresses the linked issue’s objectives.
✅ Passed checks (2 passed)
Check name Status Explanation
Title Check ✅ Passed The title succinctly describes the primary change—adding a responsive sample to the BitDataGrid demo page—and aligns directly with the pull request’s objectives without extraneous details.
Linked Issues Check ✅ Passed The pull request adds the data-title attribute to table cells, introduces .responsive-grid CSS rules for block-based mobile layouts, and includes a new responsive example in the demo page, fulfilling the linked issue’s requirements for a responsive mobile layout with visible column labels and no horizontal scrolling.

Poem

Hop hop! I tidy grids with glee,
New tidy tags for cells to see.
Headers hum, pagers preen,
RTL flips—so crisp and clean.
On phones I stack, cards in a row,
Labels whisper where values go.
Carrot-approved: responsive glow! 🥕✨

✨ Finishing touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 5

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (3)
src/BlazorUI/Bit.BlazorUI.Extras/Components/DataGrid/BitDataGrid.ts (2)

47-47: Replace non‑standard scrollIntoViewIfNeeded with a robust fallback

scrollIntoViewIfNeeded is non-standard and not supported across browsers. Add a safe fallback.

-                colOptions.scrollIntoViewIfNeeded();
+                const anyElem = colOptions as any;
+                if (typeof anyElem.scrollIntoViewIfNeeded === 'function') {
+                    anyElem.scrollIntoViewIfNeeded();
+                } else {
+                    colOptions.scrollIntoView({ block: 'nearest', inline: 'nearest' });
+                }

76-80: Clamp column width to avoid negative/zero sizes

Rapid drags can produce negative or tiny widths. Clamp to a sensible minimum.

-                        const nextWidth = originalColumnWidth + (newPageX - startPageX) * rtlMultiplier;
+                        const nextWidth = Math.max(24, originalColumnWidth + (newPageX - startPageX) * rtlMultiplier);
src/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Pages/Components/Extras/DataGrid/BitDataGridDemo.razor.cs (1)

605-608: Escape single quotes in OData filter to prevent injection/broken queries

User input with ' breaks the filter and can lead to injection.

-    if (string.IsNullOrEmpty(_odataSampleNameFilter) is false)
-    {
-        query.Add("$filter", $"contains(Name,'{_odataSampleNameFilter}')");
-    }
+    if (string.IsNullOrEmpty(_odataSampleNameFilter) is false)
+    {
+        var safe = _odataSampleNameFilter.Replace("'", "''");
+        query.Add("$filter", $"contains(Name,'{safe}')");
+    }
🧹 Nitpick comments (8)
src/BlazorUI/Bit.BlazorUI.Extras/Components/DataGrid/BitDataGrid.ts (1)

90-96: Improve touch resizing behavior (prevent page scroll)

Touch moves are passive, so you can’t prevent scrolling. Prefer CSS touch-action on the drag handle.

Add in BitDataGrid.scss (.bit-dtg-drg):

 .bit-dtg-drg {
+    touch-action: none;
+    user-select: none;
+    -webkit-user-select: none;
 }
src/BlazorUI/Bit.BlazorUI.Extras/Components/DataGrid/Pagination/BitDataGridPaginator.scss (1)

31-48: Add focus-visible styles for keyboard accessibility

Buttons need visible focus cues.

     button {
       border: 0;
       width: 2rem;
       height: 2rem;
       background: none center center / 1rem no-repeat;
 
+      &:focus-visible {
+        outline: 2px solid var(--bit-clr-acc-pri, #5b9bd5);
+        outline-offset: 2px;
+      }
src/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Pages/Components/Extras/DataGrid/BitDataGridDemo.razor.scss (3)

1-3: Use themed border color for visual consistency.
Switch the wrapper border to the design token you already use elsewhere.

-.custom-grid {
-    border: 1px solid;
+.custom-grid {
+    border: 1px solid var(--bit-clr-brd-sec);

100-117: Match the requested breakpoint (≤768px) and deduplicate the selector list.
Issue #11349 calls for 768px; current 600px under-serves devices. Also, td appears twice.

-        @media (max-width: 600px) {
+        @media (max-width: 768px) {
             table {
                 width: 100%;
             }
 
-            table, thead, tbody, th, td, tr, td {
+            table, thead, tbody, th, tr, td {
                 display: block;
             }

113-116: Verify the source of data-title; labels won’t render without it.
This CSS relies on td[data-title]. Confirm BitDataGrid sets data-title on cells (from column Title). If not, add explicit Title on columns or emit data-title via cell templates.

If needed, set Titles on columns in the Responsive example:

-<BitDataGridPropertyColumn Property="@(c => c.Name)" />
+<BitDataGridPropertyColumn Property="@(c => c.Name)" Title="Name" />
src/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Pages/Components/Extras/DataGrid/BitDataGridDemo.razor (1)

141-149: Ensure friendly Titles for responsive labels.
Explicit Titles improve mobile labels and i18n.

-    <BitDataGrid Items="@allCountries" Pagination="@pagination6">
-        <BitDataGridPropertyColumn Property="@(c => c.Name)" />
-        <BitDataGridPropertyColumn Property="@(c => c.Medals.Gold)" />
-        <BitDataGridPropertyColumn Property="@(c => c.Medals.Silver)" />
-        <BitDataGridPropertyColumn Property="@(c => c.Medals.Bronze)" />
-        <BitDataGridPropertyColumn Property="@(c => c.Medals.Total)" />
+    <BitDataGrid Items="@allCountries" Pagination="@pagination6">
+        <BitDataGridPropertyColumn Property="@(c => c.Name)" Title="Country" />
+        <BitDataGridPropertyColumn Property="@(c => c.Medals.Gold)" Title="Gold" />
+        <BitDataGridPropertyColumn Property="@(c => c.Medals.Silver)" Title="Silver" />
+        <BitDataGridPropertyColumn Property="@(c => c.Medals.Bronze)" Title="Bronze" />
+        <BitDataGridPropertyColumn Property="@(c => c.Medals.Total)" Title="Total" />
     </BitDataGrid>
src/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Pages/Components/Extras/DataGrid/BitDataGridDemo.razor.samples.cs (2)

917-953: Align breakpoint and deduplicate selectors in the snippet.
Mirror the SCSS fix in the code sample so docs and live demo match.

-    @media (max-width: 600px) {
+    @media (max-width: 768px) {
         .responsive-grid table {
             width: 100%;
         }
 
-        .responsive-grid table, 
-        .responsive-grid thead, 
-        .responsive-grid tbody, 
-        .responsive-grid th, 
-        .responsive-grid td, 
-        .responsive-grid tr, 
-        .responsive-grid td {
+        .responsive-grid table,
+        .responsive-grid thead,
+        .responsive-grid tbody,
+        .responsive-grid th,
+        .responsive-grid tr,
+        .responsive-grid td {
             display: block;
         }

955-963: Make snippet consistent with markup (pagination6) and trim unused code.
The snippet defines pagination (not pagination6) and includes an unused filter. Keep it minimal and consistent.

-<BitDataGrid Items="@allCountries" Pagination="@pagination6">
+<BitDataGrid Items="@allCountries" Pagination="@pagination6">

And in the C# snippet below, rename the field and remove unused filter/FilteredItems:

-private string typicalSampleNameFilter = string.Empty;
-private BitDataGridPaginationState pagination = new() { ItemsPerPage = 7 };
-private IQueryable<CountryModel> FilteredItems => 
-    allCountries?.Where(x => x.Name.Contains(typicalSampleNameFilter ?? string.Empty, StringComparison.CurrentCultureIgnoreCase));
+private BitDataGridPaginationState pagination6 = new() { ItemsPerPage = 7 };
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

Knowledge Base: Disabled due to Reviews > Disable Knowledge Base setting

📥 Commits

Reviewing files that changed from the base of the PR and between cab38b1 and 3166020.

📒 Files selected for processing (11)
  • src/BlazorUI/Bit.BlazorUI.Extras/Components/DataGrid/BitDataGrid.razor (3 hunks)
  • src/BlazorUI/Bit.BlazorUI.Extras/Components/DataGrid/BitDataGrid.razor.cs (2 hunks)
  • src/BlazorUI/Bit.BlazorUI.Extras/Components/DataGrid/BitDataGrid.scss (1 hunks)
  • src/BlazorUI/Bit.BlazorUI.Extras/Components/DataGrid/BitDataGrid.ts (3 hunks)
  • src/BlazorUI/Bit.BlazorUI.Extras/Components/DataGrid/Columns/BitDataGridColumnBase.razor (1 hunks)
  • src/BlazorUI/Bit.BlazorUI.Extras/Components/DataGrid/Pagination/BitDataGridPaginator.razor (3 hunks)
  • src/BlazorUI/Bit.BlazorUI.Extras/Components/DataGrid/Pagination/BitDataGridPaginator.scss (1 hunks)
  • src/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Pages/Components/Extras/DataGrid/BitDataGridDemo.razor (4 hunks)
  • src/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Pages/Components/Extras/DataGrid/BitDataGridDemo.razor.cs (1 hunks)
  • src/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Pages/Components/Extras/DataGrid/BitDataGridDemo.razor.samples.cs (10 hunks)
  • src/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Pages/Components/Extras/DataGrid/BitDataGridDemo.razor.scss (3 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: build and test
🔇 Additional comments (9)
src/BlazorUI/Bit.BlazorUI.Extras/Components/DataGrid/BitDataGrid.razor (2)

106-116: LGTM on token renames

Header wrappers/options/drag handle tokens align with TS/SCSS. No issues.


78-82: No action needed: DataGrid demo CSS uses data-title consistently

src/BlazorUI/Bit.BlazorUI.Extras/Components/DataGrid/BitDataGrid.razor.cs (2)

430-435: LGTM on class token updates

Sorting/header/grid class mappings look correct and non-breaking.


477-482: LGTM on alignment classes

Center/right alignment map to new bit-dtg-cj* tokens properly.

src/BlazorUI/Bit.BlazorUI.Extras/Components/DataGrid/Columns/BitDataGridColumnBase.razor (1)

110-111: LGTM on header token renames

New bit-dtg-* classes are consistent with the rest of the grid.

Also applies to: 115-118, 122-125, 129-130

src/BlazorUI/Bit.BlazorUI.Extras/Components/DataGrid/BitDataGrid.scss (1)

70-82: LGTM on sort indicator styling

Ascending/descending states render correctly with the new tokens.

src/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Pages/Components/Extras/DataGrid/BitDataGridDemo.razor.cs (3)

512-521: LGTM on access modifiers and new pagination state

Privatizing fields and adding pagination6 is fine.


522-524: LGTM on making filtered queries private

Encapsulation improvement is good.


520-521: pagination6 usage confirmed. The demo binds pagination6 to both <BitDataGrid Pagination="@pagination6"> and <BitDataGridPaginator Value="@pagination6" />, so no further changes are needed.

@msynk msynk force-pushed the 11349-blazorui-datagrid-responsive branch from ee8e3c8 to fc0633e Compare September 11, 2025 13:21
@msynk msynk merged commit 35c349f into bitfoundation:develop Sep 11, 2025
3 checks passed
@msynk msynk deleted the 11349-blazorui-datagrid-responsive branch September 11, 2025 22:25
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.

BitDataGrid: Responsive mobile layout (stacked card view with column labels)

1 participant