-
Notifications
You must be signed in to change notification settings - Fork 87
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(celo-news): skeleton placeholder while loading #3274
Merged
Merged
Changes from 5 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
7a359ea
feat(celo-news): skeleton placeholder while loading
jeanregisser 1125997
Fix test
jeanregisser 4a26ef7
Fix lint
jeanregisser 8d4dc8e
Add comment
jeanregisser 999ccfe
Merge branch 'main' into jeanregisser/skeleton-placeholder
MuckT db4566c
Merge branch 'main' into jeanregisser/skeleton-placeholder
jeanregisser File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
diff --git a/node_modules/react-native-skeleton-placeholder/lib/skeleton-placeholder.d.ts b/node_modules/react-native-skeleton-placeholder/lib/skeleton-placeholder.d.ts | ||
index a3dc594..3a58d21 100644 | ||
--- a/node_modules/react-native-skeleton-placeholder/lib/skeleton-placeholder.d.ts | ||
+++ b/node_modules/react-native-skeleton-placeholder/lib/skeleton-placeholder.d.ts | ||
@@ -34,6 +34,8 @@ declare type SkeletonPlaceholderProps = { | ||
* Determines width of the highlighted area | ||
*/ | ||
shimmerWidth?: number; | ||
+ // TODO: remove this patch once a release is published with https://github.com/chramos/react-native-skeleton-placeholder/pull/71 | ||
+ testID?: string; | ||
}; | ||
declare type SkeletonPlaceholderItemProps = ViewStyle & { | ||
style?: StyleProp<ViewStyle>; | ||
diff --git a/node_modules/react-native-skeleton-placeholder/lib/skeleton-placeholder.js b/node_modules/react-native-skeleton-placeholder/lib/skeleton-placeholder.js | ||
index 353abb6..5ff4824 100644 | ||
--- a/node_modules/react-native-skeleton-placeholder/lib/skeleton-placeholder.js | ||
+++ b/node_modules/react-native-skeleton-placeholder/lib/skeleton-placeholder.js | ||
@@ -39,7 +39,7 @@ const react_native_1 = require("react-native"); | ||
const react_native_linear_gradient_1 = __importDefault(require("react-native-linear-gradient")); | ||
const WINDOW_WIDTH = react_native_1.Dimensions.get('window').width; | ||
const logEnabled = false; | ||
-const SkeletonPlaceholder = ({ children, enabled = true, backgroundColor = '#E1E9EE', highlightColor = '#F2F8FC', speed = 800, direction = 'right', borderRadius, shimmerWidth, }) => { | ||
+const SkeletonPlaceholder = ({ children, enabled = true, backgroundColor = '#E1E9EE', highlightColor = '#F2F8FC', speed = 800, direction = 'right', borderRadius, shimmerWidth, testID, }) => { | ||
const [layout, setLayout] = React.useState(); | ||
const animatedValueRef = React.useRef(new react_native_1.Animated.Value(0)); | ||
const isAnimationReady = Boolean(speed && (layout === null || layout === void 0 ? void 0 : layout.width) && (layout === null || layout === void 0 ? void 0 : layout.height)); | ||
@@ -79,10 +79,10 @@ const SkeletonPlaceholder = ({ children, enabled = true, backgroundColor = '#E1E | ||
if (!enabled || !placeholders) | ||
return children; | ||
if (!(layout === null || layout === void 0 ? void 0 : layout.width) || !layout.height) | ||
- return <react_native_1.View onLayout={(event) => setLayout(event.nativeEvent.layout)}>{placeholders}</react_native_1.View>; | ||
+ return <react_native_1.View onLayout={(event) => setLayout(event.nativeEvent.layout)} testID={testID}>{placeholders}</react_native_1.View>; | ||
// https://github.com/react-native-linear-gradient/react-native-linear-gradient/issues/358 | ||
// to make transparent gradient we need to use original color with alpha | ||
- return (<masked_view_1.default style={{ height: layout.height, width: layout.width }} maskElement={placeholders}> | ||
+ return (<masked_view_1.default style={{ height: layout.height, width: layout.width }} maskElement={placeholders} testID={testID}> | ||
<react_native_1.View style={[react_native_1.StyleSheet.absoluteFill, { backgroundColor }]}/> | ||
|
||
{isAnimationReady && highlightColor !== undefined && transparentColor !== undefined && (<react_native_1.Animated.View style={animatedGradientStyle}> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import SkeletonPlaceholder from 'react-native-skeleton-placeholder' | ||
|
||
// Just re-export for now | ||
// We may want to customize this component in the future | ||
// But at least this way we can use the same import. | ||
// | ||
// For instance one future improvement would be to synchronize the animation | ||
// across all instances displayed at the same time. | ||
// Right now if the components are not rendered at the same time, you'll see the animation | ||
// be at a different progress for each one. | ||
// | ||
// Important: The children of the component are used as a mask and SkeletonPlaceholder | ||
// tries to determine the width / height of the leaf nodes and use a solid background for them. | ||
// So don't be surprised if it doesn't behave like standard React Native styles. | ||
// You may need to provide explicit width / height props to the leaf nodes to get the desired effect. | ||
// See https://github.com/chramos/react-native-skeleton-placeholder/blob/3c0ebcf3f99f9f0d0708c12f7f8e7fdc8bac843c/src/skeleton-placeholder.tsx#L166 | ||
export default SkeletonPlaceholder |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I broke our rule of not using inline styles here because I thought it made more sense to have them directly there.
But let me know if you think I should really not do this.