Skip to content

Commit

Permalink
Update Spacing.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
vanvianen committed Jan 12, 2025
1 parent c2a8b3f commit fdfc41b
Showing 1 changed file with 32 additions and 4 deletions.
36 changes: 32 additions & 4 deletions src/ts/Spacing.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,36 @@
class Spacing {
// ============================================================================
// Import
// ============================================================================

import { default as Unit, default as UnitType } from "./Unit";


// ============================================================================
// Classes
// ============================================================================

export default class Spacing {

// Parameters
// ========================================================================

top: Unit;
right: Unit;
bottom: Unit;
left: Unit;

constructor(top: Unit, right: Unit, bottom: Unit, left: Unit) {
if (top.unit !== right.unit || top.unit !== bottom.unit || top.unit !== left.unit) {
// Constructor
// ========================================================================

constructor(
top: Unit,
right: Unit,
bottom: Unit,
left: Unit
) {
if (
top.unit !== right.unit || top.unit !== bottom.unit || top.unit !== left.unit
) {
throw new Error('All sides must have the same unit');
}
this.top = top;
Expand All @@ -14,6 +39,9 @@ class Spacing {
this.left = left;
}

// Methods
// ========================================================================

add(other: Spacing): Spacing {
return new Spacing(
this.top.add(other.top),
Expand Down Expand Up @@ -65,4 +93,4 @@ class Padding extends Spacing {
constructor(top: Unit, right: Unit, bottom: Unit, left: Unit) {
super(top, right, bottom, left);
}
}
}

0 comments on commit fdfc41b

Please sign in to comment.