Skip to content

Commit

Permalink
61 add insetLeft
Browse files Browse the repository at this point in the history
  • Loading branch information
codypearce committed Sep 9, 2019
1 parent 6262dfc commit 3bcf245
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 3 deletions.
6 changes: 6 additions & 0 deletions src/Components/Divider/Divider.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ class Divider extends Component {
marginVertical: PropTypes.number,
subheader: PropTypes.string,
insetHeader: PropTypes.number,
insetLeft: PropTypes.number,
testID: PropTypes.string,
};

Expand All @@ -37,10 +38,13 @@ class Divider extends Component {
marginVertical,
subheader,
testID,
insetLeft,
...rest
} = this.props;
let marginVerticalImplemented = marginVertical ? marginVertical : 8;
if (subheader) marginVerticalImplemented = 0;
let width = insetLeft > 0 ? `calc(100% - ${insetLeft}px)` : '100%';
let marginLeft = insetLeft > 0 ? insetLeft : 0;

return (
<View
Expand All @@ -49,6 +53,8 @@ class Divider extends Component {
{
height: Platform.OS == 'web' ? 1 : StyleSheet.hairlineWidth,
marginVertical: marginVerticalImplemented,
width,
marginLeft,
},
style,
]}
Expand Down
31 changes: 28 additions & 3 deletions src/Components/Divider/Divider.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ export default storiesOf('Components|Divider', module)
</Container>
))

.add('inset', () => (
.add('insetLeft', () => (
<Container>
<Header title={'Inset'} />
<Header title={'Inset Left'} />

<List subheader={'Favorites'} style={{ width: 300 }}>
<ListItem
Expand Down Expand Up @@ -56,7 +56,7 @@ export default storiesOf('Components|Divider', module)
/>
}
/>
<Divider insetHeader={40} />
<Divider insetLeft={20} />
<ListItem
text={'Peter Carlsson'}
media={
Expand All @@ -81,6 +81,31 @@ export default storiesOf('Components|Divider', module)
/>
}
/>
<Divider insetLeft={20} />
<ListItem
text={'Person McPerson'}
media={
<Avatar
type="icon"
content="person"
contentColor={'#ececec'}
color={'#a3a3a3'}
size={40}
/>
}
/>
<ListItem
text={'Wendy'}
media={
<Avatar
type="icon"
content="person"
contentColor={'#ececec'}
color={'#a3a3a3'}
size={40}
/>
}
/>
</List>
</Container>
));

0 comments on commit 3bcf245

Please sign in to comment.