Skip to content

Commit

Permalink
Update Grid.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
vanvianen committed Jan 12, 2025
1 parent 0dbfad9 commit ec64db0
Showing 1 changed file with 28 additions and 3 deletions.
31 changes: 28 additions & 3 deletions src/ts/Grid.ts
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -18,4 +43,4 @@ class Grid {
toString(): string {
return `Grid: ${this.columns} columns, gutter ${this.gutter.toString()}, row height ${this.rowHeight.toString()}`;
}
}
}

0 comments on commit ec64db0

Please sign in to comment.