Skip to content

Commit

Permalink
refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
CyberDex committed Jul 31, 2023
1 parent dbf92ad commit 6499419
Showing 1 changed file with 21 additions and 27 deletions.
48 changes: 21 additions & 27 deletions src/controllers/StyleController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export class StyleController
protected defaultStyles: Styles;

/** Conditional styles */
protected conditionalStyles: ConditionalStyles = {};
protected conditionalStyles?: ConditionalStyles;

/**
* Manages and sets all the styles of {@link LayoutSystem}
Expand Down Expand Up @@ -200,52 +200,46 @@ export class StyleController
finalStyles = { ...finalStyles, ...this.conditionalStyles.landscape };
}

if (this.conditionalStyles?.max)
if (this.conditionalStyles?.max?.height)
{
if (this.conditionalStyles.max.height)
for (const [key, value] of Object.entries(this.conditionalStyles.max.height))
{
for (const [key, value] of Object.entries(this.conditionalStyles.max.height))
if (this.parentHeight <= parseInt(key, 10))
{
if (this.parentHeight <= parseInt(key, 10))
{
finalStyles = { ...finalStyles, ...value };
}
finalStyles = { ...finalStyles, ...value };
}
}
}

if (this.conditionalStyles.max.width)
if (this.conditionalStyles?.max?.width)
{
for (const [key, value] of Object.entries(this.conditionalStyles.max.width))
{
for (const [key, value] of Object.entries(this.conditionalStyles.max.width))
if (this.parentWidth <= parseInt(key, 10))
{
if (this.parentWidth <= parseInt(key, 10))
{
finalStyles = { ...finalStyles, ...value };
}
finalStyles = { ...finalStyles, ...value };
}
}
}

if (this.conditionalStyles?.min)
if (this.conditionalStyles?.min?.height)
{
if (this.conditionalStyles.min.height)
for (const [key, value] of Object.entries(this.conditionalStyles.min.height))
{
for (const [key, value] of Object.entries(this.conditionalStyles.min.height))
if (this.parentHeight >= parseInt(key, 10))
{
if (this.parentHeight >= parseInt(key, 10))
{
finalStyles = { ...finalStyles, ...value };
}
finalStyles = { ...finalStyles, ...value };
}
}
}

if (this.conditionalStyles.min.width)
if (this.conditionalStyles?.min?.width)
{
for (const [key, value] of Object.entries(this.conditionalStyles.min.width))
{
for (const [key, value] of Object.entries(this.conditionalStyles.min.width))
if (this.parentWidth >= parseInt(key, 10))
{
if (this.parentWidth >= parseInt(key, 10))
{
finalStyles = { ...finalStyles, ...value };
}
finalStyles = { ...finalStyles, ...value };
}
}
}
Expand Down

0 comments on commit 6499419

Please sign in to comment.