react-data-grid
Version:
Feature-rich and customizable data grid React component
78 lines (66 loc) • 2.48 kB
text/typescript
import { css } from 'ecij';
export const cell = css`
@layer rdg.Cell {
/* max-content does not work with size containment
* dynamically switching between different containment styles incurs a heavy relayout penalty
* Chromium bug: at odd zoom levels or subpixel positioning,
* layout/paint/style containment can make cell borders disappear
* https://issues.chromium.org/issues/40840864
*/
position: relative; /* needed for absolute positioning to work */
padding-block: 0;
padding-inline: 8px;
border-inline-end: var(--rdg-border-width) solid var(--rdg-border-color);
border-block-end: var(--rdg-border-width) solid var(--rdg-border-color);
align-content: center;
background-color: inherit;
white-space: nowrap;
overflow: clip;
text-overflow: ellipsis;
outline: none;
&[aria-selected='true'] {
outline: var(--rdg-selection-width) solid var(--rdg-selection-color);
outline-offset: calc(var(--rdg-selection-width) * -1);
}
}
`;
export const cellClassname = `rdg-cell ${cell}`;
// Single shared sticky/z-index rule reused by both edge-frozen variants.
// Selectors that need to distinguish start vs end use the marker classes
// (`.rdg-cell-frozen-start` / `.rdg-cell-frozen-end`) directly rather than this ecij identifier.
export const cellFrozenBase = css`
@layer rdg.Cell {
position: sticky;
/* Should have a higher value than 0 to show up above unfrozen cells */
z-index: 1;
}
`;
export const cellFrozenStartClassname = `rdg-cell-frozen-start ${cellFrozenBase}`;
export const cellFrozenEndClassname = `rdg-cell-frozen-end ${cellFrozenBase}`;
const cellDragHandle = css`
@layer rdg.DragHandle {
--rdg-drag-handle-size: 8px;
z-index: 0;
cursor: move;
inline-size: var(--rdg-drag-handle-size);
block-size: var(--rdg-drag-handle-size);
background-color: var(--rdg-selection-color);
place-self: end;
&:hover {
--rdg-drag-handle-size: 16px;
border: 2px solid var(--rdg-selection-color);
background-color: var(--rdg-background-color);
}
/* keep the handle visible on both Canvas and SelectedItem backgrounds */
@media (forced-colors: active) {
outline: 1px solid Canvas;
}
}
`;
export const cellDragHandleFrozenClassname = css`
@layer rdg.DragHandle {
z-index: 1;
position: sticky;
}
`;
export const cellDragHandleClassname = `rdg-cell-drag-handle ${cellDragHandle}`;