-
Notifications
You must be signed in to change notification settings - Fork 734
Feat/skeleton view full width #1950
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
Changes from all commits
8722278
ccb5507
bbb83cd
89c118d
8f53f35
8ed3aa8
7b996f6
f5144af
b7b97b9
fd9430f
564946b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,9 +29,10 @@ const NUMBER_OF_ITEMS_TO_SHOW = 10; | |
|
||
const DATA_TYPE = { | ||
List: 'list', | ||
Content: 'content', | ||
Images: 'images', | ||
Avatars: 'avatars', | ||
Content: 'content' | ||
Custom: 'custom' | ||
}; | ||
|
||
const LIST_TYPE = { | ||
|
@@ -317,6 +318,40 @@ export default class SkeletonViewScreen extends Component { | |
); | ||
}; | ||
|
||
renderCustom = () => { | ||
const {isDataAvailable} = this.state; | ||
|
||
return ( | ||
<View margin-20> | ||
<View row spread marginB-8> | ||
<SkeletonView | ||
width={120} | ||
height={20} | ||
borderRadius={5} | ||
showContent={isDataAvailable} | ||
renderContent={() => <Text text60BO>Lorem Ipsum</Text>} | ||
/> | ||
<SkeletonView | ||
width={40} | ||
height={10} | ||
borderRadius={5} | ||
style={{marginTop: 5}} | ||
showContent={isDataAvailable} | ||
renderContent={() => <Button label='Info' size={'small'} link/>} | ||
/> | ||
</View> | ||
<SkeletonView | ||
shimmerStyle={{width: '100%'/* , height: 30 */}} | ||
height={10} | ||
borderRadius={5} | ||
showContent={isDataAvailable} | ||
renderContent={() => <Text>Lorem Ipsum is simply dummy text of the industry.</Text>} | ||
colors={[Colors.red70, Colors.red50, Colors.red70]} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not sure if you left this on purpose, I don't like it too much. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I did. To remove it? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think so, but it might be a matter of taste, so it's up to you There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's leave it since it a "custom" example |
||
/> | ||
</View> | ||
); | ||
} | ||
|
||
renderContent = () => { | ||
const {isDataAvailable} = this.state; | ||
return ( | ||
|
@@ -345,12 +380,14 @@ export default class SkeletonViewScreen extends Component { | |
case LIST_TYPE.Thumbnail: | ||
return this.renderListItemsWithThumbnail(); | ||
} | ||
case DATA_TYPE.Content: | ||
return this.renderContent(); | ||
case DATA_TYPE.Images: | ||
return this.renderImages(); | ||
case DATA_TYPE.Avatars: | ||
return this.renderAvatarStrip(); | ||
case DATA_TYPE.Content: | ||
return this.renderContent(); | ||
case DATA_TYPE.Custom: | ||
return this.renderCustom(); | ||
} | ||
}; | ||
|
||
|
@@ -385,7 +422,7 @@ const styles = StyleSheet.create({ | |
paddingLeft: Spacings.s5 | ||
}, | ||
avatar: { | ||
marginHorizontal: 14 | ||
marginVertical: 8 | ||
}, | ||
image: { | ||
flex: 1, | ||
|
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -141,6 +141,10 @@ export interface SkeletonViewProps extends AccessibilityProps, MarginModifiers { | |
* Whether the skeleton is a circle (will override the borderRadius) | ||
*/ | ||
circle?: boolean; | ||
/** | ||
* Additional style to the skeleton view | ||
*/ | ||
shimmerStyle?: StyleProp<ViewStyle>; | ||
/** | ||
* Override container styles | ||
*/ | ||
|
@@ -234,20 +238,22 @@ class SkeletonView extends Component<InternalSkeletonViewProps, SkeletonState> { | |
|
||
getDefaultSkeletonProps = (input?: {circleOverride: boolean; style: StyleProp<ViewStyle>}) => { | ||
const {circleOverride, style} = input || {}; | ||
const {circle, colors, width = 0, height = 0} = this.props; | ||
const {circle, colors, width, height = 0, shimmerStyle} = this.props; | ||
let {borderRadius} = this.props; | ||
let size; | ||
|
||
if (circle || circleOverride) { | ||
borderRadius = BorderRadiuses.br100; | ||
size = Math.max(width, height); | ||
} | ||
size = Math.max(width || 0, height); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nice fix! |
||
} | ||
|
||
return { | ||
shimmerColors: colors || [Colors.grey70, Colors.grey60, Colors.grey70], | ||
isReversed: Constants.isRTL, | ||
style: [{borderRadius}, style], | ||
width: size || width, | ||
height: size || height | ||
height: size || height, | ||
shimmerStyle | ||
}; | ||
}; | ||
|
||
|
@@ -360,6 +366,7 @@ class SkeletonView extends Component<InternalSkeletonViewProps, SkeletonState> { | |
renderAdvanced = () => { | ||
const {children, renderContent, showContent, style, ...others} = this.props; | ||
const data = showContent && _.isFunction(renderContent) ? renderContent(this.props) : children; | ||
|
||
return ( | ||
<View style={style} {...this.getAccessibilityProps('Loading content')}> | ||
<ShimmerPlaceholder {...this.getDefaultSkeletonProps()} {...others}> | ||
|
Uh oh!
There was an error while loading. Please reload this page.