summaryrefslogtreecommitdiff
path: root/web/src/types.ts
diff options
context:
space:
mode:
authorJosh Kingsley <josh@joshkingsley.me>2025-11-23 19:27:57 +0200
committerJosh Kingsley <josh@joshkingsley.me>2025-11-23 19:27:57 +0200
commit602145c956bb594ca0d0e10601cc4ad1a71cf70d (patch)
treed9f9980bd2054cff5819d01379f5c1c55f8eb66d /web/src/types.ts
parentc2a6efb1b761014a90d90373cad47a14054af40b (diff)
feat: integrate web and doc packages
Diffstat (limited to 'web/src/types.ts')
-rw-r--r--web/src/types.ts55
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 };
-}