From 48054884d8e6954b84a108972ae6896734059817 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A1bio=20Henriques?= Date: Fri, 25 Aug 2023 14:58:42 +0100 Subject: [PATCH 1/2] Migrate file to TS --- src/styles/addOutlineWidth/index.js | 25 ---------------------- src/styles/addOutlineWidth/index.native.js | 14 ------------ src/styles/addOutlineWidth/index.native.ts | 10 +++++++++ src/styles/addOutlineWidth/index.ts | 19 ++++++++++++++++ src/styles/addOutlineWidth/types.ts | 6 ++++++ 5 files changed, 35 insertions(+), 39 deletions(-) delete mode 100644 src/styles/addOutlineWidth/index.js delete mode 100644 src/styles/addOutlineWidth/index.native.js create mode 100644 src/styles/addOutlineWidth/index.native.ts create mode 100644 src/styles/addOutlineWidth/index.ts create mode 100644 src/styles/addOutlineWidth/types.ts diff --git a/src/styles/addOutlineWidth/index.js b/src/styles/addOutlineWidth/index.js deleted file mode 100644 index 2a2657b24910..000000000000 --- a/src/styles/addOutlineWidth/index.js +++ /dev/null @@ -1,25 +0,0 @@ -/** - * Web and desktop platforms support the "addOutlineWidth" property, so it - * can be added to the object - */ - -import themeDefault from '../themes/default'; - -/** - * Adds the addOutlineWidth property to an object to be used when styling - * - * @param {Object} obj - * @param {Number} val - * @param {boolean} [error=false] - * @returns {Object} - */ -function withOutlineWidth(obj, val, error = false) { - return { - ...obj, - outlineWidth: val, - outlineStyle: val ? 'auto' : 'none', - boxShadow: val !== 0 ? `0px 0px 0px ${val}px ${error ? themeDefault.danger : themeDefault.borderFocus}` : 'none', - }; -} - -export default withOutlineWidth; diff --git a/src/styles/addOutlineWidth/index.native.js b/src/styles/addOutlineWidth/index.native.js deleted file mode 100644 index b678aa95aef0..000000000000 --- a/src/styles/addOutlineWidth/index.native.js +++ /dev/null @@ -1,14 +0,0 @@ -/** - * Native platforms don't support the "addOutlineWidth" property, so this - * function is a no-op - */ - -/** - * @param {Object} obj - * @returns {Object} - */ -function withOutlineWidth(obj) { - return obj; -} - -export default withOutlineWidth; diff --git a/src/styles/addOutlineWidth/index.native.ts b/src/styles/addOutlineWidth/index.native.ts new file mode 100644 index 000000000000..69e2ffaf3a5b --- /dev/null +++ b/src/styles/addOutlineWidth/index.native.ts @@ -0,0 +1,10 @@ +/** + * Native platforms don't support the "addOutlineWidth" property, so this + * function is a no-op + */ + +import AddOutlineWidth from './types'; + +const addOutlineWidth: AddOutlineWidth = (obj) => obj; + +export default addOutlineWidth; diff --git a/src/styles/addOutlineWidth/index.ts b/src/styles/addOutlineWidth/index.ts new file mode 100644 index 000000000000..257a3de2b6cd --- /dev/null +++ b/src/styles/addOutlineWidth/index.ts @@ -0,0 +1,19 @@ +/** + * Web and desktop platforms support the "addOutlineWidth" property, so it + * can be added to the object + */ + +import themeDefault from '../themes/default'; +import AddOutlineWidth from './types'; + +/** + * Adds the addOutlineWidth property to an object to be used when styling + */ +const addOutlineWidth: AddOutlineWidth = (obj, val, error = false) => ({ + ...obj, + outlineWidth: val, + outlineStyle: val ? 'auto' : 'none', + boxShadow: val !== 0 ? `0px 0px 0px ${val}px ${error ? themeDefault.danger : themeDefault.borderFocus}` : 'none', +}); + +export default addOutlineWidth; diff --git a/src/styles/addOutlineWidth/types.ts b/src/styles/addOutlineWidth/types.ts new file mode 100644 index 000000000000..0f786143e78f --- /dev/null +++ b/src/styles/addOutlineWidth/types.ts @@ -0,0 +1,6 @@ +import {CSSProperties} from 'react'; +import {TextStyle} from 'react-native'; + +type AddOutlineWidth = (obj: TextStyle | CSSProperties, val: number, error: boolean) => TextStyle | CSSProperties; + +export default AddOutlineWidth; From 363793ba385404e36226b950a81a8870315f33af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A1bio=20Henriques?= Date: Mon, 28 Aug 2023 15:49:28 +0100 Subject: [PATCH 2/2] Fix type --- src/styles/addOutlineWidth/types.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/styles/addOutlineWidth/types.ts b/src/styles/addOutlineWidth/types.ts index 0f786143e78f..422d135ef759 100644 --- a/src/styles/addOutlineWidth/types.ts +++ b/src/styles/addOutlineWidth/types.ts @@ -1,6 +1,6 @@ import {CSSProperties} from 'react'; import {TextStyle} from 'react-native'; -type AddOutlineWidth = (obj: TextStyle | CSSProperties, val: number, error: boolean) => TextStyle | CSSProperties; +type AddOutlineWidth = (obj: TextStyle | CSSProperties, val?: number, error?: boolean) => TextStyle | CSSProperties; export default AddOutlineWidth;