From 827b8cff2923a5516a6dc6347e5a03b32ed0c462 Mon Sep 17 00:00:00 2001 From: Carlos Garcia Date: Mon, 17 Jul 2023 13:05:13 +0200 Subject: [PATCH] Remove unneeded fix for text font-weight style --- src/setup.js | 2 - src/text-font-weight-correct.js | 74 --------------------------------- 2 files changed, 76 deletions(-) delete mode 100644 src/text-font-weight-correct.js diff --git a/src/setup.js b/src/setup.js index 55a8bebd77..c5ecd6d20a 100644 --- a/src/setup.js +++ b/src/setup.js @@ -7,7 +7,6 @@ import { initialHtmlGutenberg } from '@wordpress/react-native-editor'; /** * Internal dependencies */ -import correctTextFontWeight from './text-font-weight-correct'; import initialHtml from './initial-html'; import initAnalytics from './analytics'; @@ -15,7 +14,6 @@ const setupHooks = () => { // Hook triggered before the editor is rendered addAction( 'native.pre-render', 'gutenberg-mobile', () => { require( './strings-overrides' ); - correctTextFontWeight(); } ); addFilter( diff --git a/src/text-font-weight-correct.js b/src/text-font-weight-correct.js deleted file mode 100644 index 7b8e0a8ae3..0000000000 --- a/src/text-font-weight-correct.js +++ /dev/null @@ -1,74 +0,0 @@ -/** - * External dependencies - */ -import { Platform, Text } from 'react-native'; -import { merge } from 'lodash'; -/** - * WordPress dependencies - */ -import { cloneElement } from '@wordpress/element'; - -const textRender = Text.render; - -const getCorrectFontWeight = ( fontWeight ) => { - switch ( fontWeight ) { - case '100': - case '200': - case '300': - return { - fontFamily: 'sans-serif-thin', - fontWeight: 'normal', - }; - case '400': - return { - fontFamily: 'sans-serif-light', - fontWeight: 'normal', - }; - case '500': - case 'normal': - return { - fontFamily: 'sans-serif', - fontWeight: 'normal', - }; - case '600': - return { - fontFamily: 'sans-serif-medium', - fontWeight: 'normal', - }; - case '700': - case 'bold': - return { - fontFamily: 'sans-serif', - fontWeight: 'bold', - }; - case '800': - case '900': - return { - fontFamily: 'sans-serif-medium', - fontWeight: 'bold', - }; - } -}; - -const correctTextFontWeight = ( args ) => { - const baseText = textRender.call( this, args ); - const { style } = baseText.props; - - const flatStyle = Array.isArray( style ) ? merge( {}, ...style ) : style; - const shouldCorrectFontWeight = flatStyle && flatStyle.fontWeight; - - return shouldCorrectFontWeight - ? cloneElement( baseText, { - style: [ - flatStyle, - getCorrectFontWeight( flatStyle.fontWeight ), - ], - } ) - : baseText; -}; - -export default () => { - if ( Platform.OS === 'android' ) { - Text.render = correctTextFontWeight; - } -};