diff options
| author | Josh Kingsley <josh@joshkingsley.me> | 2025-11-23 19:27:57 +0200 |
|---|---|---|
| committer | Josh Kingsley <josh@joshkingsley.me> | 2025-11-23 19:27:57 +0200 |
| commit | 602145c956bb594ca0d0e10601cc4ad1a71cf70d (patch) | |
| tree | d9f9980bd2054cff5819d01379f5c1c55f8eb66d /web/src/types.ts | |
| parent | c2a6efb1b761014a90d90373cad47a14054af40b (diff) | |
feat: integrate web and doc packages
Diffstat (limited to 'web/src/types.ts')
| -rw-r--r-- | web/src/types.ts | 55 |
1 files changed, 0 insertions, 55 deletions
diff --git a/web/src/types.ts b/web/src/types.ts deleted file mode 100644 index dc26c89..0000000 --- a/web/src/types.ts +++ /dev/null @@ -1,55 +0,0 @@ -import { Immutable } from "immer"; -import Ratio from "./math/Ratio"; - -export type Cell = Immutable<{ - value?: string; - widthRatio: Ratio; -}>; - -export interface Row { - cells: Cell[]; -} - -export interface Part { - title?: string; - rows: Row[]; -} - -export interface Grid { - id: string; - baseCellSize: number; - baseCellWidthRatio: Ratio; - parts: Part[]; -} - -export interface Doc { - grids: Grid[]; -} - -export interface RowRef { - partIndex: number; - rowIndex: number; -} - -export interface CellRef { - partIndex: number; - rowIndex: number; - cellIndex: number; -} - -export function cellRefEquals(a: CellRef, b: CellRef): boolean { - return ( - a.partIndex === b.partIndex && - a.rowIndex === b.rowIndex && - a.cellIndex === b.cellIndex - ); -} - -export function renderedRowIndexToRef( - grid: Grid, - renderedRowIndex: number, -): RowRef { - const partIndex = renderedRowIndex % grid.parts.length; - const rowIndex = Math.floor(renderedRowIndex / grid.parts.length); - return { partIndex, rowIndex }; -} |
