From ec64db06407d08b3a486cce29a947a6319656e6f Mon Sep 17 00:00:00 2001 From: Lars van Vianen Date: Sun, 12 Jan 2025 17:02:33 +0100 Subject: [PATCH] Update Grid.ts --- src/ts/Grid.ts | 31 ++++++++++++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-) diff --git a/src/ts/Grid.ts b/src/ts/Grid.ts index 1628306..83f282e 100644 --- a/src/ts/Grid.ts +++ b/src/ts/Grid.ts @@ -1,14 +1,39 @@ -class Grid { +// ============================================================================ +// Import +// ============================================================================ + +import Unit from "./Unit"; + + +// ============================================================================ +// Classes +// ============================================================================ + +export default class Grid { + + // Parameters + // ======================================================================== + columns: number; gutter: Unit; rowHeight: Unit; - constructor(columns: number, gutter: Unit, rowHeight: Unit) { + // Constructor + // ======================================================================== + + constructor( + columns: number, + gutter: Unit, + rowHeight: Unit + ) { this.columns = columns; this.gutter = gutter; this.rowHeight = rowHeight; } + // Methods + // ======================================================================== + getColumnWidth(containerWidth: Unit): Unit { const totalGutterWidth = this.gutter.value * (this.columns - 1); const columnWidth = (containerWidth.value - totalGutterWidth) / this.columns; @@ -18,4 +43,4 @@ class Grid { toString(): string { return `Grid: ${this.columns} columns, gutter ${this.gutter.toString()}, row height ${this.rowHeight.toString()}`; } -} \ No newline at end of file +}