Skip to content

Commit

Permalink
replace 'width: 100%' with 'marginHorizontal' to make style of line a…
Browse files Browse the repository at this point in the history
…nd placeholder component more flexible.
  • Loading branch information
ryan-yuan-dev committed Jun 10, 2019
1 parent c8275fe commit 657f686
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
4 changes: 1 addition & 3 deletions src/line/line.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { View } from "react-native";
export const Line = ({
textSize = 12,
color = "#efefef",
useDefaultWidth,
style,
noMargin = false,
...props
Expand All @@ -14,14 +13,13 @@ export const Line = ({
const backgroundColor = color;
const borderRadius = textSize / 4;
const marginBottom = noMargin ? 0 : textSize;
const lineWidth = useDefaultWidth ? { width: "100%" } : {};
const computedStyle = {
height,
alignSelf,
backgroundColor,
borderRadius,
marginBottom,
...lineWidth
marginHorizontal: 0
};

return <View style={[computedStyle, style]} {...props} />;
Expand Down
7 changes: 3 additions & 4 deletions src/placeholder/placeholder.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ import Animations from "../animation/animations";
const styles = StyleSheet.create({
container: {
flexDirection: "row",
flex: 1
flex: 1,
marginHorizontal: 0
},
centerElement: {
flex: 1
Expand Down Expand Up @@ -42,7 +43,6 @@ export const Placeholder = ({
whenReadyRender: WhenReadyRender,
renderLeft,
renderRight,
useDefaultWidth = true,
...props
}) => {
const Root = customAnimation || makeRoot(animation);
Expand All @@ -53,10 +53,9 @@ export const Placeholder = ({

const childrenArray = React.Children.toArray(children);
const sizeOfChildren = childrenArray.length;
const containerWidth = useDefaultWidth ? { width: "100%" } : {};
const userStyle = props.style;
return (
<Root {...props} style={[styles.container, userStyle, containerWidth]}>
<Root {...props} style={[styles.container, userStyle]}>
{renderLeft && withView(renderLeft, { style: styles.leftSide })}
<View style={styles.centerElement}>
{childrenArray.map((element, index) =>
Expand Down

0 comments on commit 657f686

Please sign in to comment.