Skip to content

Commit

Permalink
feat: improve table expander (#683)
Browse files Browse the repository at this point in the history
  • Loading branch information
jsladerman authored Feb 18, 2025
1 parent f5e61af commit 3e81bc2
Show file tree
Hide file tree
Showing 10 changed files with 231 additions and 170 deletions.
5 changes: 5 additions & 0 deletions src/components/contexts/FillLevelContext.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { createContext, useContext } from 'react'
import { TableFillLevel } from '../table/tableUtils'

const MIN_FILL = 0
const MAX_FILL = 3
Expand All @@ -13,6 +14,10 @@ export function toFillLevel(x: number | FillLevel): FillLevel {
return Math.max(Math.min(Math.floor(x), MAX_FILL), MIN_FILL) as FillLevel
}

export function toTableFillLevel(x: number | FillLevel): TableFillLevel {
return Math.max(Math.min(Math.floor(x), 2), 0) as TableFillLevel
}

const isInteger = (x: unknown): x is number => Number.isInteger(x)

export function isFillLevel(x: unknown): x is FillLevel {
Expand Down
2 changes: 1 addition & 1 deletion src/components/table/FillerRows.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { Row } from '@tanstack/react-table'
import type { VirtualItem } from '@tanstack/react-virtual'

import { type TableFillLevel } from './Table'
import { type TableFillLevel } from './tableUtils'
import { Td } from './Td'
import { Tr } from './Tr'

Expand Down
Loading

0 comments on commit 3e81bc2

Please sign in to comment.