Skip to content

Commit

Permalink
fix review
Browse files Browse the repository at this point in the history
  • Loading branch information
wagnerbsantos committed Nov 22, 2024
1 parent 60570dd commit 14b3e3b
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { ReactElement } from 'react'
import { max } from 'lodash'
import { isNil, max } from 'lodash'
import { KeyMap } from '../model'
import { PivotTableCell } from '../PivotTableCell/PivotTableCell'
import { GridArea } from '../PivotTableCell/classes/GridArea'
Expand Down Expand Up @@ -76,7 +76,7 @@ export function buildRectangularTable<T extends object>(
},
})

return [...horizontalDivs, ...verticalDivs]
return horizontalDivs.concat(verticalDivs)
}

function getHorizontal<T extends object>({
Expand All @@ -92,7 +92,7 @@ function getHorizontal<T extends object>({
const divs: ReactElement[] = []
const rowTotalValues = new Map<string, number>()
const cellPosition = new Set<string>()
const isMixedTable = mixedTable !== null && mixedTable !== undefined
const isMixedTable = !isNil(mixedTable)

buildHorizontalTableHeader<T>(keys, rowHeaderSpace, divs, keysMapping)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ const createComponent = () => {
}
const maxLeafValue = props.defaultTree.maxLeafValue as number
return (
<PivotTableProvider maxValue={maxLeafValue} suffix={''}>
<PivotTableProvider maxValue={maxLeafValue} suffix=''>
<PivotTableRenderer {...props}></PivotTableRenderer>
</PivotTableProvider>
)
Expand All @@ -104,6 +104,8 @@ describe('PivotTableRenderer', () => {
const cellColumnTotal = container.querySelector('div[data-columnnumber="3"][data-rownumber="5"]')!!
const cellRowTotal = container.querySelector('div[data-columnnumber="5"][data-rownumber="3"]')!!

expect(window.getComputedStyle(cellToHover).backgroundColor).toEqual('rgb(132, 170, 255)')

fireEvent.mouseEnter(cellToHover)

expect(window.getComputedStyle(cellToHover).backgroundColor).toEqual('rgba(132, 170, 255, 0.5)')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import { TableProps } from './model'
import { createPivotTableRenderStyles } from './styles'
import { buildHorizontalTable, buildRectangularTable, buildVerticalTable } from './PivotTableBuilder'

const SCROLL_LEFT_SHADOW_MARGIN = 10

export function PivotTableRenderer<T extends object>(props: TableProps<T>) {
const { rowKeys, columnKeys, keysMapping, defaultTree, complementaryTree } = props
const tableContainerRef = useRef<HTMLDivElement>(null)
Expand Down Expand Up @@ -36,8 +38,7 @@ export function PivotTableRenderer<T extends object>(props: TableProps<T>) {
tableContainerRef.current.scrollLeft !==
tableContainerRef.current.scrollWidth - tableContainerRef.current.clientWidth

const scrollLeftMargin = 10
const displayLeft = tableContainerRef.current.scrollLeft > scrollLeftMargin
const displayLeft = tableContainerRef.current.scrollLeft > SCROLL_LEFT_SHADOW_MARGIN

setDisplayLeftShadow(displayLeft)
setDisplayRightShadow(displayRight)
Expand Down

0 comments on commit 14b3e3b

Please sign in to comment.