@@ -3,10 +3,10 @@ import React, {Component} from 'react';
3
3
import { StyleProp , StyleSheet , ViewStyle } from 'react-native' ;
4
4
import memoize from 'memoize-one' ;
5
5
import * as Modifiers from '../../commons/modifiers' ;
6
- import { Colors , Spacings , Typography } from 'style' ;
6
+ import { Spacings } from 'style' ;
7
7
import View , { ViewProps } from '../view' ;
8
8
import TouchableOpacity , { TouchableOpacityProps } from '../touchableOpacity' ;
9
- import Text from '../text' ;
9
+ import Text , { type TextProps } from '../text' ;
10
10
import Image , { ImageProps } from '../image' ;
11
11
12
12
export enum HorizontalAlignment {
@@ -115,15 +115,6 @@ export interface GridListItemProps {
115
115
children ?: React . ReactElement | React . ReactElement [ ] ;
116
116
}
117
117
118
- interface RenderContentType {
119
- text ?: string | React . ReactElement ;
120
- typography ?: string ;
121
- color ?: string ;
122
- numberOfLines ?: number ;
123
- style ?: StyleProp < ViewStyle > ;
124
- testID ?: string ;
125
- }
126
-
127
118
/**
128
119
* @description : A single grid view/list item component
129
120
* @example : https://github.com/wix/react-native-ui-lib/blob/master/demo/src/screens/componentScreens/GridViewScreen.tsx
@@ -165,23 +156,12 @@ class GridListItem extends Component<GridListItemProps> {
165
156
}
166
157
} ) ;
167
158
168
- renderContent ( { text, typography , color , numberOfLines = 1 , style , testID } : RenderContentType ) {
159
+ renderContent ( text : string | React . ReactElement | undefined , textProps : Partial < TextProps > ) {
169
160
const { alignToStart, horizontalAlignment} = this . props ;
170
161
const textAlign = alignToStart ? 'left' : horizontalAlignment ;
171
162
if ( text ) {
172
163
return (
173
- < Text
174
- testID = { testID }
175
- // @ts -ignore
176
- style = { [
177
- style ,
178
- //@ts -ignore
179
- Typography [ typography ] ,
180
- color && { color} ,
181
- { textAlign}
182
- ] }
183
- numberOfLines = { numberOfLines }
184
- >
164
+ < Text { ...textProps } style = { [ textProps . style , { textAlign} ] } >
185
165
{ text }
186
166
</ Text >
187
167
) ;
@@ -199,18 +179,18 @@ class GridListItem extends Component<GridListItemProps> {
199
179
renderCustomItem,
200
180
children,
201
181
title,
202
- titleTypography,
203
- titleColor = Colors . $textDefault ,
182
+ titleTypography = 'bodySmallBold' ,
183
+ titleColor,
204
184
titleLines,
205
185
overlayText,
206
186
overlayTextContainerStyle,
207
187
subtitle,
208
- subtitleTypography,
209
- subtitleColor = Colors . $textDefault ,
188
+ subtitleTypography = 'subtext' ,
189
+ subtitleColor,
210
190
subtitleLines,
211
191
description,
212
- descriptionTypography,
213
- descriptionColor = Colors . $textDefault ,
192
+ descriptionTypography = 'subtext' ,
193
+ descriptionColor,
214
194
descriptionLines,
215
195
onPress,
216
196
renderOverlay
@@ -237,26 +217,23 @@ class GridListItem extends Component<GridListItemProps> {
237
217
{ ! _ . isNil ( renderCustomItem ) && < View style = { { width} } > { renderCustomItem ( ) } </ View > }
238
218
{ renderOverlay && < View style = { [ styles . overlay , itemSize ] } > { renderOverlay ( ) } </ View > }
239
219
< TextContainer { ...textContainerStyle } >
240
- { this . renderContent ( {
220
+ { this . renderContent ( title , {
241
221
testID : `${ testID } .title` ,
242
- text : title ,
243
- typography : titleTypography ,
222
+ [ titleTypography ] : true ,
244
223
color : titleColor ,
245
224
numberOfLines : titleLines ,
246
225
style : styles . title
247
226
} ) }
248
- { this . renderContent ( {
227
+ { this . renderContent ( subtitle , {
249
228
testID : `${ testID } .subtitle` ,
250
- text : subtitle ,
251
- typography : subtitleTypography ,
229
+ [ subtitleTypography ] : true ,
252
230
color : subtitleColor ,
253
231
numberOfLines : subtitleLines ,
254
232
style : styles . subtitle
255
233
} ) }
256
- { this . renderContent ( {
234
+ { this . renderContent ( description , {
257
235
testID : `${ testID } .description` ,
258
- text : description ,
259
- typography : descriptionTypography ,
236
+ [ descriptionTypography ] : true ,
260
237
color : descriptionColor ,
261
238
numberOfLines : descriptionLines ,
262
239
style : styles . description
@@ -274,16 +251,13 @@ const styles = StyleSheet.create({
274
251
} ,
275
252
title : {
276
253
marginTop : Spacings . s1 ,
277
- textAlign : 'center' ,
278
- ...Typography . bodySmallBold
254
+ textAlign : 'center'
279
255
} ,
280
256
subtitle : {
281
- textAlign : 'center' ,
282
- ...Typography . subtext
257
+ textAlign : 'center'
283
258
} ,
284
259
description : {
285
- textAlign : 'center' ,
286
- ...Typography . subtext
260
+ textAlign : 'center'
287
261
} ,
288
262
overlay : {
289
263
position : 'absolute' ,
0 commit comments