Skip to content

Instantly share code, notes, and snippets.

@slorber
Created May 30, 2018 15:36
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save slorber/c107a36c5345cfd16a4c28a7e27d4f85 to your computer and use it in GitHub Desktop.
Save slorber/c107a36c5345cfd16a4c28a7e27d4f85 to your computer and use it in GitHub Desktop.
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