Created
May 30, 2018 15:36
-
-
Save slorber/c107a36c5345cfd16a4c28a7e27d4f85 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { Component } from 'react'; | |
import {View} from "glamorous-native"; | |
import * as Colors from "colors"; | |
import {getColor} from "colors"; | |
import { greyD } from "colors"; | |
const Separator = ({ | |
spacing = 10, | |
vertical = false, | |
borderWidth = 1, | |
...props, | |
}) => { | |
const color = getColor(props,greyD); | |
const sizeProps = vertical ? | |
{height: '100%'} : | |
{width: '100%'}; | |
const spacingProps = vertical ? | |
{marginRight: spacing, marginLeft: spacing} : | |
{marginTop: spacing, marginBottom: spacing}; | |
return ( | |
<View | |
{...sizeProps} | |
{...spacingProps} | |
{...props} | |
borderWidth={borderWidth} | |
borderColor={color} | |
/> | |
); | |
}; | |
export const WithSeparators = ({children, ...props}) => React.Children.toArray(children) | |
.map((childrenItem,i) => ( | |
<React.Fragment key={`${i}`}> | |
{i > 0 && <Separator {...props}/>} | |
{childrenItem} | |
</React.Fragment> | |
)); | |
export default Separator; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment