From 418fae973e7b54cd43ec6d6eaf50cad505108378 Mon Sep 17 00:00:00 2001 From: DrStoop Date: Tue, 22 Oct 2024 23:17:50 +0300 Subject: [PATCH] Enabling `backgroundOpacity` and `foregroundOpacity` for `ContentLoader` in React Native environment (#324) * Update `IContentLoaderProps` in index.ts Extended `IcontentLoaderProps` with props `backgroundOpacity` and `foregroundOpacity`. * Update NativeSvg fore back/foregroundOpacity Svg.tsx Added `backgroundOpacity` and `foregroundOpacity` freature for Native. * Enabling `backgroundOpacity` and `foregroundOpacity` for `ContentLoader` on Native. in README.md Updated docs to describe `backgourndOpacity` and `foregroundOpacity` props of `ContentLoader` available in React Native environment. --- README.md | 4 ++-- src/native/Svg.tsx | 10 +++++++--- src/native/index.ts | 2 ++ 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 01ca203d..fc605ce4 100755 --- a/README.md +++ b/README.md @@ -119,8 +119,8 @@ const MyLoader = () => ( | **`rtl?: boolean`**
Defaults to `false` | React DOM
React Native | Content right-to-left. | | **`backgroundColor?: string`**
Defaults to `#f5f6f7` | React DOM
React Native | Used as background of animation. | | **`foregroundColor?: string`**
Defaults to `#eee` | React DOM
React Native | Used as the foreground of animation. | -| **`backgroundOpacity?: number`**
Defaults to `1` | React DOM only | Background opacity (0 = transparent, 1 = opaque)
used to solve an issue in [Safari](#safari--ios) | -| **`foregroundOpacity?: number`**
Defaults to `1` | React DOM only | Animation opacity (0 = transparent, 1 = opaque)
used to solve an issue in [Safari](#safari--ios) | +| **`backgroundOpacity?: number`**
Defaults to `1` | React DOM
React Native | Background opacity (0 = transparent, 1 = opaque)
used to solve an issue in [Safari](#safari--ios) | +| **`foregroundOpacity?: number`**
Defaults to `1` | React DOM
React Native | Animation opacity (0 = transparent, 1 = opaque)
used to solve an issue in [Safari](#safari--ios) | | **`style?: React.CSSProperties`**
Defaults to `{}` | React DOM only | | | **`uniqueKey?: string`**
Defaults to random unique id | React DOM only | Use the same value of prop key, 
that will solve inconsistency on the SSR, see more [here](https://github.com/danilowoz/react-content-loader/issues/78). | | **`beforeMask?: JSX.Element`**
Defaults to null | React DOM
React Native | Define custom shapes before content, 
see more [here](https://github.com/danilowoz/react-content-loader/issues/266). | diff --git a/src/native/Svg.tsx b/src/native/Svg.tsx index af748eda..68fbf791 100644 --- a/src/native/Svg.tsx +++ b/src/native/Svg.tsx @@ -17,7 +17,9 @@ class NativeSvg extends Component { static defaultProps = { animate: true, backgroundColor: '#f5f6f7', + backgroundOpacity: 1, foregroundColor: '#eee', + foregroundOpacity: 1, rtl: false, speed: 1.2, interval: 0.25, @@ -74,7 +76,9 @@ class NativeSvg extends Component { const { children, backgroundColor, + backgroundOpacity, foregroundColor, + foregroundOpacity, rtl, style, beforeMask, @@ -124,9 +128,9 @@ class NativeSvg extends Component { y1={0} y2={0} > - - - + + + diff --git a/src/native/index.ts b/src/native/index.ts index c0f4e269..a5c1a842 100644 --- a/src/native/index.ts +++ b/src/native/index.ts @@ -5,7 +5,9 @@ import ContentLoader from './ContentLoader' export interface IContentLoaderProps extends SvgProps { animate?: boolean backgroundColor?: string + backgroundOpacity?: number foregroundColor?: string + foregroundOpacity?: number rtl?: boolean speed?: number interval?: number