Skip to content

Commit

Permalink
apply default styles
Browse files Browse the repository at this point in the history
  • Loading branch information
CyberDex committed Jul 29, 2023
1 parent 8303da5 commit 2be3911
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
13 changes: 11 additions & 2 deletions src/Layout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,13 +124,22 @@ export class LayoutSystem
{
this.dpr = 'portrait';

this.setStyles(this.options.styles.portrait);
const defaultStyles = { ...this.options.styles };

defaultStyles.portrait = undefined;

this.setStyles({ ...defaultStyles, ...this.options.styles.portrait });
}

if (this.dpr !== 'landscape' && this.options?.styles?.landscape && parentHeight < parentWidth)
{
this.dpr = 'landscape';
this.setStyles(this.options.styles.landscape);

const defaultStyles = { ...this.options.styles };

defaultStyles.landscape = undefined;

this.setStyles({ ...defaultStyles, ...this.options.styles.landscape });
}

this.size.update(parentWidth, parentHeight);
Expand Down
5 changes: 3 additions & 2 deletions src/stories/styles/ConditionalStyles.stories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,11 @@ class LayoutStory
}
},
styles: {
width: `80%`,
height: `80%`,
width: `60%`,
height: `60%`,
position: 'center',
overflow: 'hidden',
borderRadius: 20,
portrait: {
background: portraitColor,
},
Expand Down

0 comments on commit 2be3911

Please sign in to comment.