-
Notifications
You must be signed in to change notification settings - Fork 140
fix(core/aggrid): updated row zebra pattern #2638
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
Changes from all commits
6a29605
713dad9
4b8e059
f1c3b95
0dd5de9
9ebdeb7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| /* | ||
| * SPDX-FileCopyrightText: 2025 Siemens AG | ||
| * | ||
| * SPDX-License-Identifier: MIT | ||
| * | ||
| * This source code is licensed under the MIT license found in the | ||
| * LICENSE file in the root directory of this source tree. | ||
| */ | ||
|
|
||
| .ag-row.ag-row-hover .ag-cell { | ||
| background-image: linear-gradient( | ||
| var(--theme-color-ghost--hover), | ||
| var(--theme-color-ghost--hover) | ||
| ) !important; | ||
| } | ||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,111 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /* | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| * SPDX-FileCopyrightText: 2024 Siemens AG | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| * | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| * SPDX-License-Identifier: MIT | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| * | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| * This source code is licensed under the MIT license found in the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| * LICENSE file in the root directory of this source tree. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| */ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import type { Meta, StoryObj } from '@storybook/web-components-vite'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import { getIxTheme } from '@siemens/ix-aggrid'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import * as agGridCommunity from 'ag-grid-community'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| AllCommunityModule, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ModuleRegistry, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| createGrid, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| type GridOptions, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } from 'ag-grid-community'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ModuleRegistry.registerModules([AllCommunityModule]); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| type AgGridArgs = { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| gridOptions: GridOptions; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const rowData = [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| { type: 'Equipment', status: 'Normal', hwVersion: '2.0' }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| { type: 'Positioner', status: 'Maintenance', hwVersion: '1.0' }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| { type: 'Pressure sensor', status: 'Unknown', hwVersion: 'N/A' }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| { type: 'Flow meter', status: 'Normal', hwVersion: '3.1' }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| { type: 'Temperature sensor', status: 'Warning', hwVersion: '2.2' }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| { type: 'Valve', status: 'Normal', hwVersion: '1.5' }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| { type: 'Actuator', status: 'Maintenance', hwVersion: '2.0' }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| { type: 'Controller', status: 'Normal', hwVersion: '4.0' }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| { type: 'Safety relay', status: 'Unknown', hwVersion: 'N/A' }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| { type: 'Power supply', status: 'Normal', hwVersion: '1.8' }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| function renderGrid(args: AgGridArgs) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const container = document.createElement('div'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| container.style.height = '20rem'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| container.style.width = '100%'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| createGrid(container, { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ...args.gridOptions, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| theme: getIxTheme(agGridCommunity), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return container; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+38
to
+49
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🩺 Stability & Availability | 🔵 Trivial | ⚡ Quick win Store grid API and call
♻️ Proposed fix to add grid cleanup+let gridApi: ReturnType<typeof createGrid> | null = null;
+
function renderGrid(args: AgGridArgs) {
+ if (gridApi) {
+ gridApi.destroy();
+ gridApi = null;
+ }
const container = document.createElement('div');
container.style.height = '20rem';
container.style.width = '100%';
- createGrid(container, {
+ gridApi = createGrid(container, {
...args.gridOptions,
theme: getIxTheme(agGridCommunity),
});
return container;
}📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const meta = { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| title: 'Example/AgGrid', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| tags: [], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| render: (args) => renderGrid(args), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| parameters: { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| design: { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| type: 'figma', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| url: 'https://www.figma.com/design/r2nqdNNXXZtPmWuVjIlM1Q/iX-Components---Brand-Dark?node-id=86777-15993&m=dev', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } satisfies Meta<AgGridArgs>; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| export default meta; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| type Story = StoryObj<AgGridArgs>; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| export const Default: Story = { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| args: { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| gridOptions: { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| rowDragManaged: true, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| tooltipShowDelay: 500, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| rowSelection: { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| mode: 'multiRow', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| checkboxes: true, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| headerCheckbox: true, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| selectAll: 'filtered', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| columnDefs: [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| field: 'type', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| headerName: 'Type', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| resizable: true, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| rowDrag: true, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| tooltipField: 'type', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| field: 'status', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| headerName: 'Status', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| resizable: true, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| sortable: true, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| filter: true, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| tooltipValueGetter: (params) => | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| `Status: ${params.value} - Type: ${params.data.type}`, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| field: 'hwVersion', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| headerName: 'HW version', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| resizable: true, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| tooltipValueGetter: (params) => | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| params.value === 'N/A' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ? 'Hardware version not available' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| : `Hardware Version ${params.value}`, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| autoSizeStrategy: { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| type: 'fitGridWidth', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| rowData, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| suppressCellFocus: true, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using
background-image: linear-gradient(...) !importantto apply the hover overlay will completely override any custombackground-image(such as icons, custom gradients, or patterns) that might be set on cells by custom cell renderers or other styles.To avoid overriding cell background images while still achieving the desired overlay effect, you can use an inset
box-shadowinstead. An inset box-shadow overlays on top of bothbackground-colorandbackground-imagewithout replacing them.Additionally, since we are manually painting the hover overlay on the cell, please ensure that AG Grid's built-in
rowHoverColorparameter inaggrid-ix-theme-params.tsis set totransparent(orrgba(0, 0, 0, 0)) to prevent AG Grid from rendering its own hover overlay simultaneously, which would result in double-hover tinting.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rowHoverColor is intentionally retained; it and the cell tint layer together to produce consistent hover across zebra rows. Removing it regresses odd/even consistency.
The box-shadow: inset approach produces per-cell border seams, so it's not suitable here.