Skip to content

Commit

Permalink
[change] W3C verticalAlign style
Browse files Browse the repository at this point in the history
* Add support for verticalAlign style.
* Deprecate textAlignVertical style.

Ref #2379
  • Loading branch information
necolas committed Mar 20, 2023
1 parent c6e77c3 commit 5bc5142
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,17 @@ describe('compiler/createReactDOMStyle', () => {
});
});

test('verticalAlign', () => {
expect(
createReactDOMStyle({
verticalAlign: 'top',
textAlignVertical: 'center'
})
).toEqual({
verticalAlign: 'top'
});
});

describe('transform', () => {
// passthrough if transform value is ever a string
test('string', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,13 @@ const createReactDOMStyle = (style: Style, isInline?: boolean): Style => {
resolvedStyle[prop] = value;
}
} else if (prop === 'textAlignVertical') {
resolvedStyle.verticalAlign = value === 'center' ? 'middle' : value;
warnOnce(
'textAlignVertical',
'"textAlignVertical" style is deprecated. Use "verticalAlign".'
);
if (resolvedStyle.verticalAlign == null) {
resolvedStyle.verticalAlign = value === 'center' ? 'middle' : value;
}
} else if (prop === 'textDecorationLine') {
// use 'text-decoration' for browsers that only support CSS2
// text-decoration (e.g., IE, Edge)
Expand Down
7 changes: 5 additions & 2 deletions packages/react-native-web/src/exports/Text/types.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ export type TextStyle = {
| 'left'
| 'right'
| 'start',
textAlignVertical?: ?string,
textDecorationColor?: ?ColorValue,
textDecorationLine?:
| 'none'
Expand All @@ -67,6 +66,7 @@ export type TextStyle = {
| 'geometricPrecision'
| 'optimizeLegibility'
| 'optimizeSpeed',
textShadow?: ?string,
textShadowColor?: ?ColorValue,
textShadowOffset?: {| width?: number, height?: number |},
textShadowRadius?: ?number,
Expand All @@ -79,13 +79,16 @@ export type TextStyle = {
| 'isolate-override'
| 'plaintext',
userSelect?: 'none' | 'text',
verticalAlign?: ?string,
whiteSpace?: ?string,
wordBreak?: 'normal' | 'break-all' | 'break-word' | 'keep-all',
wordWrap?: ?string,
writingDirection?: 'auto' | 'ltr' | 'rtl',
/* @platform web */
MozOsxFontSmoothing?: ?string,
WebkitFontSmoothing?: ?string
WebkitFontSmoothing?: ?string,
// deprecated
textAlignVertical?: ?string
};

export type TextProps = {
Expand Down
1 change: 1 addition & 0 deletions packages/react-native-web/src/types/styles.js
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,7 @@ export type LayoutStyles = {|
*/

export type ShadowStyles = {|
// @deprecated
shadowColor?: ?ColorValue,
shadowOffset?: {|
width?: DimensionValue,
Expand Down

0 comments on commit 5bc5142

Please sign in to comment.