-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #33 from DevoInc/feature/QUV-1299_implement_table_…
…windowing feat(Table): QUV-1299 Implement Table windowing
- Loading branch information
Showing
21 changed files
with
282 additions
and
240 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,24 @@ | ||
import styled, { css } from 'styled-components'; | ||
import styled, { DefaultTheme } from 'styled-components'; | ||
|
||
interface StyledTableCellWrapperProps { | ||
width?: React.CSSProperties['width']; | ||
height?: React.CSSProperties['height']; | ||
translateX?: number; | ||
translateY?: number; | ||
theme: DefaultTheme; | ||
} | ||
|
||
export const StyledTableCellWrapper = styled.td<StyledTableCellWrapperProps>` | ||
export const StyledTableCellWrapper = styled.td.attrs( | ||
({ width, theme, translateX, translateY }: StyledTableCellWrapperProps) => ({ | ||
style: { | ||
width, | ||
color: theme.alias.color.text.body.base, | ||
transform: `translateX(${translateX}px) translateY(${translateY}px)`, | ||
}, | ||
}), | ||
)<StyledTableCellWrapperProps>` | ||
position: relative; | ||
box-sizing: border-box; | ||
vertical-align: middle; | ||
${({ width }) => css` | ||
width: ${width}; | ||
`} | ||
${({ theme }) => css` | ||
color: ${theme.alias.color.text.body.base}; | ||
`} | ||
text-align: center; | ||
`; |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,22 @@ | ||
import { VirtualItem } from '@tanstack/react-virtual'; | ||
import React from 'react'; | ||
|
||
import { ColDef } from '../../declarations'; | ||
import { TextRenderer } from '../../renderers'; | ||
import { StyledHeaderCell } from './StyledTableHeaderCellWrapper'; | ||
|
||
interface HeaderCellProps { | ||
columnDef: ColDef; | ||
scrolled?: boolean; | ||
virtualColumn: VirtualItem; | ||
} | ||
|
||
export const HeaderCell: React.FC<HeaderCellProps> = ({ | ||
columnDef, | ||
scrolled, | ||
virtualColumn, | ||
}) => ( | ||
<StyledHeaderCell scrolled={scrolled} width={columnDef?.cellStyle?.width}> | ||
<TextRenderer value={columnDef.headerName} bold /> | ||
<StyledHeaderCell | ||
scrolled={scrolled} | ||
width={`${virtualColumn.size}px`} | ||
offsetX={virtualColumn.start} | ||
> | ||
<TextRenderer value={virtualColumn.key} bold /> | ||
</StyledHeaderCell> | ||
); |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,37 @@ | ||
import * as React from 'react'; | ||
|
||
import { StyledTableRow } from './StyledTableRow'; | ||
import { ColDef } from '../../declarations'; | ||
import { Cell } from '../Cell'; | ||
import { VirtualItem, Virtualizer } from '@tanstack/react-virtual'; | ||
|
||
interface RowProps { | ||
columnDefs: ColDef[]; | ||
data: { [key: string]: unknown }; | ||
height?: React.CSSProperties['height']; | ||
styles?: React.CSSProperties; | ||
columnVirtualizer: Virtualizer<undefined, Element>; | ||
virtualRow: VirtualItem; | ||
} | ||
|
||
export const Row: React.FC<RowProps> = ({ columnDefs, data, height }) => ( | ||
<StyledTableRow height={height}> | ||
{columnDefs.map((columnDef: ColDef) => { | ||
return ( | ||
<Cell | ||
columnDef={columnDef} | ||
key={`cell-${columnDef.colId}`} | ||
data={data[columnDef.field] ?? ''} | ||
/> | ||
); | ||
})} | ||
</StyledTableRow> | ||
); | ||
export const Row: React.FC<RowProps> = ({ | ||
columnDefs, | ||
data, | ||
styles, | ||
columnVirtualizer, | ||
virtualRow, | ||
}) => { | ||
return ( | ||
<StyledTableRow styles={styles}> | ||
{columnVirtualizer.getVirtualItems().map((virtualColumn: VirtualItem) => { | ||
return ( | ||
<Cell | ||
columnDef={columnDefs[virtualColumn.index]} | ||
key={`cell-${virtualColumn.key}`} | ||
data={data[columnDefs[virtualColumn.index].id] ?? ''} | ||
virtualColumn={virtualColumn} | ||
virtualRow={virtualRow} | ||
/> | ||
); | ||
})} | ||
</StyledTableRow> | ||
); | ||
}; |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,49 +1,15 @@ | ||
import styled, { css } from 'styled-components'; | ||
import { pseudoElementMixin } from '@devoinc/genesys-ui'; | ||
import { getSizes } from '../utils'; | ||
import styled from 'styled-components'; | ||
|
||
interface StyledTableRowProps { | ||
height?: React.CSSProperties['height']; | ||
styles?: React.CSSProperties; | ||
} | ||
|
||
export const StyledTableRow = styled.tr<StyledTableRowProps>` | ||
${({ theme }) => { | ||
const tableTokens = theme.cmp.table; | ||
const cmpTokens = tableTokens.row; | ||
const transitionDuration = cmpTokens.mutation.transitionDuration; | ||
return css` | ||
@keyframes modifiedBlink { | ||
0% { | ||
background-color: ${cmpTokens.color.background.modifiedBlink}; | ||
} | ||
100% { | ||
background-color: ${cmpTokens.color.background.even.highlighted}; | ||
} | ||
} | ||
transition: background-color ease ${transitionDuration.bgColor}; | ||
`; | ||
}} | ||
${({ height, theme }) => { | ||
const tableTokens = theme.cmp.table; | ||
const cmpTokens = tableTokens.row; | ||
const borderRadius = getSizes(tableTokens).row.br; | ||
return css` | ||
border: none; | ||
border-radius: ${borderRadius}; | ||
height: ${height + 'px'}; | ||
background-color: ${cmpTokens.color.background.odd.base}; | ||
// border bottom with pseudo element to avoid border radius effect | ||
&::after { | ||
${pseudoElementMixin(null)}; | ||
bottom: 0; | ||
left: ${borderRadius}; | ||
right: ${borderRadius}; | ||
height: ${cmpTokens.shape.borderSize.after}; | ||
background-color: ${cmpTokens.color.background.after}; | ||
pointer-events: none; | ||
} | ||
`; | ||
}} | ||
position: ${({ styles }) => styles.position}; | ||
top: 0; | ||
left: 0; | ||
width: 100%; | ||
height: ${({ styles }) => styles.height}; | ||
transform: ${({ styles }) => styles.transform}; | ||
display: table; | ||
`; |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,14 @@ | ||
import * as React from 'react'; | ||
import styled, { css } from 'styled-components'; | ||
import styled from 'styled-components'; | ||
|
||
export interface StyledTableProps { | ||
width?: React.CSSProperties['width']; | ||
minWidth?: React.CSSProperties['minWidth']; | ||
height?: React.CSSProperties['height']; | ||
} | ||
|
||
export const StyledTable = styled.table<StyledTableProps>` | ||
height: auto; | ||
margin: 0; | ||
${({ width }) => css` | ||
width: ${width}; | ||
`} | ||
${({ minWidth }) => css` | ||
min-width: ${minWidth}; | ||
`} | ||
border: none; | ||
position: relative; | ||
height: ${({ height }) => height}; | ||
width: 100%; | ||
`; |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,14 @@ | ||
import * as React from 'react'; | ||
import styled, { css } from 'styled-components'; | ||
import { scrollbars } from '@devoinc/genesys-ui'; | ||
import styled from 'styled-components'; | ||
|
||
export interface StyledTableWrapperProps { | ||
maxHeight?: React.CSSProperties['maxHeight']; | ||
scrolled?: boolean; | ||
height?: React.CSSProperties['height']; | ||
} | ||
|
||
export const StyledTableWrapper = styled.div<StyledTableWrapperProps>` | ||
display: block; | ||
${({ theme }) => { | ||
return css` | ||
${scrollbars({ theme })} | ||
`; | ||
}} | ||
overflow-x: auto; | ||
${({ scrolled }) => { | ||
return css` | ||
overflow-y: ${scrolled ? 'auto' : 'visible'}; | ||
`; | ||
}} | ||
${({ maxHeight = '100%' }) => { | ||
return css` | ||
max-height: ${maxHeight}; | ||
`; | ||
}} | ||
width: 100%; | ||
height: ${({ height }) => height}; | ||
overflow: auto; | ||
`; |
Oops, something went wrong.