Skip to content

Commit 21f6db7

Browse files
committed
Rename processLayoutProps
1 parent ce1c390 commit 21f6db7

File tree

6 files changed

+28
-26
lines changed

6 files changed

+28
-26
lines changed

Libraries/Components/View/View.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
import type {ViewProps} from './ViewPropTypes';
1212

1313
import flattenStyle from '../../StyleSheet/flattenStyle';
14-
import processLayoutProps from '../../StyleSheet/processStyles';
14+
import processStyles from '../../StyleSheet/processStyles';
1515
import TextAncestor from '../../Text/TextAncestor';
1616
import {getAccessibilityRoleFromRole} from '../../Utilities/AcessibilityMapping';
1717
import ViewNativeComponent from './ViewNativeComponent';
@@ -100,7 +100,7 @@ const View: React.AbstractComponent<
100100
}
101101

102102
let style = flattenStyle(otherProps.style);
103-
style = processLayoutProps(style);
103+
style = processStyles(style);
104104

105105
const newPointerEvents = style?.pointerEvents || pointerEvents;
106106

Libraries/Image/Image.android.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import type {ImageAndroid} from './Image.flow';
1313
import type {ImageProps as ImagePropsType} from './ImageProps';
1414

1515
import flattenStyle from '../StyleSheet/flattenStyle';
16-
import processLayoutProps from '../StyleSheet/processStyles';
16+
import processStyles from '../StyleSheet/processStyles';
1717
import StyleSheet from '../StyleSheet/StyleSheet';
1818
import TextAncestor from '../Text/TextAncestor';
1919
import ImageAnalyticsTagContext from './ImageAnalyticsTagContext';
@@ -167,7 +167,7 @@ const BaseImage = (props: ImagePropsType, forwardedRef) => {
167167

168168
const {height, width, ...restProps} = props;
169169

170-
style = processLayoutProps(style);
170+
style = processStyles(style);
171171

172172
const {onLoadStart, onLoad, onLoadEnd, onError} = props;
173173
const nativeProps = {

Libraries/Image/Image.ios.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import type {ImageIOS} from './Image.flow';
1414
import type {ImageProps as ImagePropsType} from './ImageProps';
1515

1616
import flattenStyle from '../StyleSheet/flattenStyle';
17-
import processLayoutProps from '../StyleSheet/processStyles';
17+
import processStyles from '../StyleSheet/processStyles';
1818
import StyleSheet from '../StyleSheet/StyleSheet';
1919
import ImageAnalyticsTagContext from './ImageAnalyticsTagContext';
2020
import ImageInjection from './ImageInjection';
@@ -138,7 +138,7 @@ const BaseImage = (props: ImagePropsType, forwardedRef) => {
138138
// $FlowFixMe[prop-missing]
139139
const tintColor = props.tintColor || style.tintColor;
140140

141-
style = processLayoutProps(style);
141+
style = processStyles(style);
142142

143143
if (props.children != null) {
144144
throw new Error(

Libraries/StyleSheet/StyleSheetTypes.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -185,19 +185,19 @@ type ____LayoutStyle_Internal = $ReadOnly<{
185185
marginBlock?: DimensionValue,
186186

187187
/** `marginBlockEnd` works like `margin-bottom` in CSS.
188-
* See https://developer.mozilla.org/en-US/docs/Web/CSS/margin-bottom
188+
* See https://developer.mozilla.org/en-US/docs/Web/CSS/margin-block
189189
* for more details.
190190
*/
191191
marginBlockEnd?: DimensionValue,
192192

193193
/** `marginBlockStart` works like `margin-top` in CSS.
194-
* See https://developer.mozilla.org/en-US/docs/Web/CSS/margin-top
194+
* See https://developer.mozilla.org/en-US/docs/Web/CSS/margin-block-end
195195
* for more details.
196196
*/
197197
marginBlockStart?: DimensionValue,
198198

199199
/** `marginBottom` works like `margin-bottom` in CSS.
200-
* See https://developer.mozilla.org/en-US/docs/Web/CSS/margin-bottom
200+
* See https://developer.mozilla.org/en-US/docs/Web/CSS/margin-block-start
201201
* for more details.
202202
*/
203203
marginBottom?: DimensionValue,
@@ -268,17 +268,19 @@ type ____LayoutStyle_Internal = $ReadOnly<{
268268

269269
/** Setting `paddingBlock` is like setting both of
270270
* `paddingTop` and `paddingBottom`.
271+
* See https://developer.mozilla.org/en-US/docs/Web/CSS/padding-block
272+
* for more details.
271273
*/
272274
paddingBlock?: DimensionValue,
273275

274276
/** `paddingBlockEnd` works like `padding-bottom` in CSS.
275-
* See https://developer.mozilla.org/en-US/docs/Web/CSS/padding-bottom
277+
* See https://developer.mozilla.org/en-US/docs/Web/CSS/padding-block-end
276278
* for more details.
277279
*/
278280
paddingBlockEnd?: DimensionValue,
279281

280282
/** `paddingBlockStart` works like `padding-top` in CSS.
281-
* See https://developer.mozilla.org/en-US/docs/Web/CSS/padding-top
283+
* See https://developer.mozilla.org/en-US/docs/Web/CSS/padding-block-start
282284
* for more details.
283285
*/
284286
paddingBlockStart?: DimensionValue,

Libraries/StyleSheet/__tests__/processStyles-test.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@
1010

1111
'use strict';
1212

13-
const processLayoutProps = require('../processStyles');
13+
const processStyles = require('../processStyles');
1414

15-
describe('processLayoutProps', () => {
15+
describe('processStyles', () => {
1616
it('it should map layout style properties', () => {
1717
const style = {
1818
backgroundColor: 'white',
@@ -30,7 +30,7 @@ describe('processLayoutProps', () => {
3030
paddingInline: 120,
3131
verticalAlign: 'middle',
3232
};
33-
const processedStyle = processLayoutProps(style);
33+
const processedStyle = processStyles(style);
3434
expect(processedStyle).toMatchInlineSnapshot(`
3535
Object {
3636
"backgroundColor": "white",
@@ -53,26 +53,26 @@ describe('processLayoutProps', () => {
5353

5454
it('should override style properties', () => {
5555
const style = {marginStart: 20, marginInlineStart: 40};
56-
const processedStyle = processLayoutProps(style);
56+
const processedStyle = processStyles(style);
5757
expect(processedStyle.marginStart).toBe(40);
5858
});
5959

6060
it('should overwrite properties with `undefined`', () => {
6161
const style = {marginInlineStart: 40, marginStart: undefined};
62-
const processedStyle = processLayoutProps(style);
62+
const processedStyle = processStyles(style);
6363
expect(processedStyle.marginStart).toBe(40);
6464
});
6565

6666
it('should not fail on falsy values', () => {
67-
expect(() => processLayoutProps({})).not.toThrow();
68-
expect(() => processLayoutProps(null)).not.toThrow();
69-
expect(() => processLayoutProps(false)).not.toThrow();
70-
expect(() => processLayoutProps(undefined)).not.toThrow();
67+
expect(() => processStyles({})).not.toThrow();
68+
expect(() => processStyles(null)).not.toThrow();
69+
expect(() => processStyles(false)).not.toThrow();
70+
expect(() => processStyles(undefined)).not.toThrow();
7171
});
7272

7373
it('should not change style if there is no layout style property', () => {
7474
const style = {backgroundColor: '#000', width: 10};
75-
const processedStyle = processLayoutProps(style);
75+
const processedStyle = processStyles(style);
7676
expect(processedStyle).toStrictEqual(style);
7777
});
7878
});

Libraries/StyleSheet/processStyles.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
import type {____FlattenStyleProp_Internal} from './StyleSheetTypes';
1414

15-
const propMap = {
15+
const propMap: {[key: string]: string} = {
1616
marginInlineStart: 'marginStart',
1717
marginInlineEnd: 'marginEnd',
1818
marginBlockStart: 'marginTop',
@@ -28,7 +28,7 @@ const propMap = {
2828
verticalAlign: 'textAlignVertical',
2929
};
3030

31-
const verticalAlignValueMap = {
31+
const verticalAlignValueMap: {[key: string]: string} = {
3232
auto: 'auto',
3333
top: 'top',
3434
bottom: 'bottom',
@@ -38,12 +38,12 @@ const verticalAlignValueMap = {
3838
function processStyles<T>(
3939
flattenedStyle: ____FlattenStyleProp_Internal<T>,
4040
): ____FlattenStyleProp_Internal<T> {
41-
const _flattenedStyle = {...flattenedStyle};
41+
const _flattenedStyle: ____FlattenStyleProp_Internal<T> = {...flattenedStyle};
4242

4343
if (_flattenedStyle != null) {
44-
Object.keys(_flattenedStyle).forEach(key => {
44+
Object.keys(_flattenedStyle).forEach((key: string) => {
4545
const alt = propMap[key];
46-
const originalValue = _flattenedStyle[key];
46+
const originalValue: string = _flattenedStyle[key];
4747
let _value = originalValue;
4848
if (key === 'verticalAlign') {
4949
_value = verticalAlignValueMap[originalValue];

0 commit comments

Comments
 (0)