Skip to content

Commit

Permalink
fix: fix listitem icon spacing (#1017)
Browse files Browse the repository at this point in the history
  • Loading branch information
jbinda authored and Trancever committed Apr 24, 2019
1 parent 8a9a6a9 commit 9e30fc9
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 18 deletions.
5 changes: 5 additions & 0 deletions example/src/Examples/ListSectionExample.js
Expand Up @@ -29,6 +29,11 @@ class ListSectionExample extends React.Component<Props> {
left={props => <List.Icon {...props} icon="redeem" />}
title="List item 2"
/>
<List.Item
title="List item 3"
left={props => <List.Icon {...props} icon="folder" />}
right={props => <List.Icon {...props} icon="drag-handle" />}
/>
</List.Section>
<Divider />
<List.Section>
Expand Down
2 changes: 1 addition & 1 deletion src/components/List/ListIcon.js
Expand Up @@ -48,7 +48,7 @@ export default class ListIcon extends React.Component<Props> {

const styles = StyleSheet.create({
item: {
marginRight: 16,
margin: 8,
height: 40,
width: 40,
alignItems: 'center',
Expand Down
12 changes: 9 additions & 3 deletions src/components/List/ListItem.js
Expand Up @@ -121,7 +121,9 @@ class ListItem extends React.Component<Props> {
{left
? left({
color: descriptionColor,
style: description ? styles.iconMargin : null,
style: description
? styles.iconMarginLeft
: { ...styles.iconMarginLeft, ...styles.marginVerticalNone },
})
: null}
<View style={[styles.item, styles.content]} pointerEvents="none">
Expand Down Expand Up @@ -151,7 +153,9 @@ class ListItem extends React.Component<Props> {
{right
? right({
color: descriptionColor,
style: description ? styles.iconMargin : null,
style: description
? styles.iconMarginRight
: { ...styles.iconMarginRight, ...styles.marginVerticalNone },
})
: null}
</View>
Expand All @@ -173,7 +177,9 @@ const styles = StyleSheet.create({
description: {
fontSize: 14,
},
iconMargin: { marginVertical: 8 },
marginVerticalNone: { marginVertical: 0 },
iconMarginLeft: { marginLeft: 0, marginRight: 16 },
iconMarginRight: { marginRight: 0 },
item: {
marginVertical: 6,
paddingLeft: 8,
Expand Down
Expand Up @@ -233,7 +233,7 @@ exports[`renders list accordion with children 1`] = `
"alignItems": "center",
"height": 40,
"justifyContent": "center",
"marginRight": 16,
"margin": 8,
"width": 40,
},
undefined,
Expand Down Expand Up @@ -404,7 +404,7 @@ exports[`renders list accordion with left items 1`] = `
"alignItems": "center",
"height": 40,
"justifyContent": "center",
"marginRight": 16,
"margin": 8,
"width": 40,
},
undefined,
Expand Down
12 changes: 8 additions & 4 deletions src/components/__tests__/__snapshots__/ListItem.test.js.snap
Expand Up @@ -209,11 +209,11 @@ exports[`renders list item with left and right items 1`] = `
"alignItems": "center",
"height": 40,
"justifyContent": "center",
"marginRight": 16,
"margin": 8,
"width": 40,
},
Object {
"marginVertical": 8,
"marginRight": 0,
},
]
}
Expand Down Expand Up @@ -294,10 +294,14 @@ exports[`renders list item with left item 1`] = `
"alignItems": "center",
"height": 40,
"justifyContent": "center",
"marginRight": 16,
"margin": 8,
"width": 40,
},
null,
Object {
"marginLeft": 0,
"marginRight": 16,
"marginVertical": 0,
},
]
}
>
Expand Down
32 changes: 24 additions & 8 deletions src/components/__tests__/__snapshots__/ListSection.test.js.snap
Expand Up @@ -114,10 +114,14 @@ exports[`renders list section with subheader 1`] = `
"alignItems": "center",
"height": 40,
"justifyContent": "center",
"marginRight": 16,
"margin": 8,
"width": 40,
},
null,
Object {
"marginLeft": 0,
"marginRight": 16,
"marginVertical": 0,
},
]
}
>
Expand Down Expand Up @@ -235,10 +239,14 @@ exports[`renders list section with subheader 1`] = `
"alignItems": "center",
"height": 40,
"justifyContent": "center",
"marginRight": 16,
"margin": 8,
"width": 40,
},
null,
Object {
"marginLeft": 0,
"marginRight": 16,
"marginVertical": 0,
},
]
}
>
Expand Down Expand Up @@ -409,10 +417,14 @@ exports[`renders list section without subheader 1`] = `
"alignItems": "center",
"height": 40,
"justifyContent": "center",
"marginRight": 16,
"margin": 8,
"width": 40,
},
null,
Object {
"marginLeft": 0,
"marginRight": 16,
"marginVertical": 0,
},
]
}
>
Expand Down Expand Up @@ -530,10 +542,14 @@ exports[`renders list section without subheader 1`] = `
"alignItems": "center",
"height": 40,
"justifyContent": "center",
"marginRight": 16,
"margin": 8,
"width": 40,
},
null,
Object {
"marginLeft": 0,
"marginRight": 16,
"marginVertical": 0,
},
]
}
>
Expand Down

0 comments on commit 9e30fc9

Please sign in to comment.