Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

style(infoCard): add prop to pass custom styles #54

Merged
merged 1 commit into from
Feb 15, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions src/components/InfoCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -88,13 +88,17 @@ class InfoCard extends React.Component<InfoCardProps, InfoCardState> {
title,
description,
image,
content,
topRightElement,
expandable
expandable,
children,
style,
content
} = this.props;

const _children = content || children;

return (
<View style={styles.container}>
<View style={[styles.container, style.container]}>
<View style={styles.topSection}>
<View style={styles.row}>
<Text size={13} color={colors.gray.dark}>
Expand All @@ -103,13 +107,13 @@ class InfoCard extends React.Component<InfoCardProps, InfoCardState> {

{topRightElement}
</View>
{content ? (
{_children ? (
<View
style={
expandable && !this.state.isOpen ? styles.content : undefined
}
>
{content}
{_children}
</View>
) : (
<View>
Expand Down
6 changes: 6 additions & 0 deletions src/components/typings/InfoCard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,15 @@ export interface InfoCardProps {
linkText?: string;
onPress?: () => void;
image?: ImageSourcePropType;
/**
* @deprecated Use children instead of content.
*/
content?: JSX.Element;
topRightElement?: JSX.Element;
expandable?: boolean;
style?: {
container?: any;
};
}

export interface InfoCardState {
Expand Down
98 changes: 48 additions & 50 deletions storybook/stories/infoCard.story.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,30 +25,6 @@ storiesOf("InfoCard", module)
<View style={{ width: "100%" }}>
<InfoCard
title="Additional Client Info"
content={
<View style={{ marginTop: 8 }}>
<List
style={{ paddingVertical: 8 }}
title="Age"
description="Below 25"
/>
<List
style={{ paddingVertical: 8 }}
title="Age"
description="Below 25"
/>
<List
style={{ paddingVertical: 8 }}
title="Age"
description="Below 25"
/>
<List
style={{ paddingVertical: 8 }}
title="Age"
description="Below 25"
/>
</View>
}
linkText="Hellllooooo"
topRightElement={
<Touchable>
Expand All @@ -57,7 +33,30 @@ storiesOf("InfoCard", module)
</Text>
</Touchable>
}
/>
>
<View style={{ marginTop: 8 }}>
<List
style={{ paddingVertical: 8 }}
title="Age"
description="Below 25"
/>
<List
style={{ paddingVertical: 8 }}
title="Age"
description="Below 25"
/>
<List
style={{ paddingVertical: 8 }}
title="Age"
description="Below 25"
/>
<List
style={{ paddingVertical: 8 }}
title="Age"
description="Below 25"
/>
</View>
</InfoCard>
</View>
</CenterView>
))
Expand All @@ -67,30 +66,6 @@ storiesOf("InfoCard", module)
<View style={{ width: "100%" }}>
<InfoCard
title="Additional Client Info"
content={
<View style={{ marginTop: 8 }}>
<List
style={{ paddingVertical: 8 }}
title="Age"
description="Below 25"
/>
<List
style={{ paddingVertical: 8 }}
title="Ethnicity"
description="Marathi"
/>
<List
style={{ paddingVertical: 8 }}
title="Residential Address"
description="B-303, Piramal Ananya, Ambedkar Road, Worli"
/>
<List
style={{ paddingVertical: 8 }}
title="Residential Address"
description="B-303, Piramal Ananya, Ambedkar Road, Worli"
/>
</View>
}
linkText="View More"
topRightElement={
<Touchable>
Expand All @@ -100,7 +75,30 @@ storiesOf("InfoCard", module)
</Touchable>
}
expandable
/>
>
<View style={{ marginTop: 8 }}>
<List
style={{ paddingVertical: 8 }}
title="Age"
description="Below 25"
/>
<List
style={{ paddingVertical: 8 }}
title="Ethnicity"
description="Marathi"
/>
<List
style={{ paddingVertical: 8 }}
title="Residential Address"
description="B-303, Piramal Ananya, Ambedkar Road, Worli"
/>
<List
style={{ paddingVertical: 8 }}
title="Residential Address"
description="B-303, Piramal Ananya, Ambedkar Road, Worli"
/>
</View>
</InfoCard>
</View>
</CenterView>
));