@shoutem/ui 9.3.1 → 9.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,16 +1,25 @@
1
1
  import { Dimensions } from 'react-native';
2
2
 
3
+ /**
4
+ * Returns the width available to HTML content: the window width minus the
5
+ * SimpleHtml container's horizontal padding and `outerPadding`, the horizontal
6
+ * space the parent containers take between the screen edge and SimpleHtml.
7
+ * Embedded images and videos are capped at this width so they don't overflow.
8
+ *
9
+ * @param {Object} style Resolved SimpleHtml style.
10
+ * @param {Object} [style.container] Container style; `paddingLeft` and
11
+ * `paddingRight` (expanded from `padding` by the theme) are subtracted.
12
+ * @param {number} [style.outerPadding] Total horizontal space (both sides)
13
+ * taken by parent containers.
14
+ * @returns {number}
15
+ */
3
16
  export function resolveMaxWidth(style) {
4
- // parentContainerPadding - padding between screen & SimpleHtml. Parent container
5
- // can have it's own padding. If it does, we have to include it in calculation,
6
- // otherwise maxWidth will be more than max & images will go over the edge
7
- const parentContainerPadding = style.outerPadding || 0;
8
- const paddingValue =
9
- style.container.paddingLeft ||
10
- 0 + style.container.paddingRight ||
11
- 0 + parentContainerPadding;
17
+ const { paddingLeft = 0, paddingRight = 0 } = style.container || {};
18
+ const outerPadding = style.outerPadding || 0;
12
19
 
13
- return Dimensions.get('window').width - paddingValue;
20
+ return (
21
+ Dimensions.get('window').width - paddingLeft - paddingRight - outerPadding
22
+ );
14
23
  }
15
24
 
16
25
  export function resolveDimensions(objectToResize, style) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shoutem/ui",
3
- "version": "9.3.1",
3
+ "version": "9.3.2",
4
4
  "description": "Styleable set of components for React Native applications",
5
5
  "scripts": {
6
6
  "lint": "eslint .",