Skip to content

Commit 463b7b3

Browse files
authored
Feat/ support passing colors to skeletonView (#1905)
* support passing colors to skeletonView * fix description * add prop to api file * update description * description fix
1 parent fc3d793 commit 463b7b3

File tree

3 files changed

+20
-2
lines changed

3 files changed

+20
-2
lines changed

generatedTypes/src/components/skeletonView/index.d.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,11 @@ export interface SkeletonViewProps extends AccessibilityProps, MarginModifiers {
112112
* The width of the skeleton view
113113
*/
114114
width?: number;
115+
/**
116+
* The colors of the skeleton view, the array length has to be >=2
117+
* default: [Colors.grey70, Colors.grey60, Colors.grey70]
118+
*/
119+
colors?: string[];
115120
/**
116121
* The border radius of the skeleton view
117122
*/

src/components/skeletonView/index.tsx

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,11 @@ export interface SkeletonViewProps extends AccessibilityProps, MarginModifiers {
128128
* The width of the skeleton view
129129
*/
130130
width?: number;
131+
/**
132+
* The colors of the skeleton view, the array length has to be >=2
133+
* default: [Colors.grey70, Colors.grey60, Colors.grey70]
134+
*/
135+
colors?: string[]
131136
/**
132137
* The border radius of the skeleton view
133138
*/
@@ -229,7 +234,7 @@ class SkeletonView extends Component<InternalSkeletonViewProps, SkeletonState> {
229234

230235
getDefaultSkeletonProps = (input?: {circleOverride: boolean; style: StyleProp<ViewStyle>}) => {
231236
const {circleOverride, style} = input || {};
232-
const {circle, width = 0, height = 0} = this.props;
237+
const {circle, colors, width = 0, height = 0} = this.props;
233238
let {borderRadius} = this.props;
234239
let size;
235240
if (circle || circleOverride) {
@@ -238,7 +243,7 @@ class SkeletonView extends Component<InternalSkeletonViewProps, SkeletonState> {
238243
}
239244

240245
return {
241-
shimmerColors: [Colors.grey70, Colors.grey60, Colors.grey70],
246+
shimmerColors: colors || [Colors.grey70, Colors.grey60, Colors.grey70],
242247
isReversed: Constants.isRTL,
243248
style: [{borderRadius}, style],
244249
width: size || width,
@@ -425,6 +430,7 @@ class SkeletonView extends Component<InternalSkeletonViewProps, SkeletonState> {
425430
showLastSeparator,
426431
height,
427432
width,
433+
colors,
428434
borderRadius,
429435
circle,
430436
style,
@@ -445,6 +451,7 @@ class SkeletonView extends Component<InternalSkeletonViewProps, SkeletonState> {
445451
showLastSeparator,
446452
height,
447453
width,
454+
colors,
448455
borderRadius,
449456
circle,
450457
style,

src/components/skeletonView/skeletonView.api.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,12 @@
3737
{"name": "timesKey", "type": "string", "description": "A key prefix for the duplicated SkeletonViews"},
3838
{"name": "height", "type": "number", "description": "The height of the skeleton view"},
3939
{"name": "width", "type": "number", "description": "The width of the skeleton view"},
40+
{
41+
"name": "colors",
42+
"type": "string[]",
43+
"description": "The colors of the skeleton view, the array length has to be >=2",
44+
"default": "[Colors.grey70, Colors.grey60, Colors.grey70]"
45+
},
4046
{"name": "borderRadius", "type": "number", "description": "The border radius of the skeleton view"},
4147
{
4248
"name": "circle",

0 commit comments

Comments
 (0)