From 2be3911c2749942da03732963105c1d9b808ef86 Mon Sep 17 00:00:00 2001 From: Dmytro Soldatov Date: Sat, 29 Jul 2023 11:41:36 +0300 Subject: [PATCH] apply default styles --- src/Layout.ts | 13 +++++++++++-- src/stories/styles/ConditionalStyles.stories.ts | 5 +++-- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/src/Layout.ts b/src/Layout.ts index 6d1b3ef..92ccdef 100644 --- a/src/Layout.ts +++ b/src/Layout.ts @@ -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); diff --git a/src/stories/styles/ConditionalStyles.stories.ts b/src/stories/styles/ConditionalStyles.stories.ts index 6e5bbe7..18ca78c 100644 --- a/src/stories/styles/ConditionalStyles.stories.ts +++ b/src/stories/styles/ConditionalStyles.stories.ts @@ -69,10 +69,11 @@ class LayoutStory } }, styles: { - width: `80%`, - height: `80%`, + width: `60%`, + height: `60%`, position: 'center', overflow: 'hidden', + borderRadius: 20, portrait: { background: portraitColor, },