Skip to content

Commit

Permalink
fix(ChecklistCard): Ensure divider doesn’t cover error border (#92)
Browse files Browse the repository at this point in the history
  • Loading branch information
markdalgleish authored Feb 13, 2019
1 parent bdb75fb commit fc3c4a5
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 21 deletions.
16 changes: 3 additions & 13 deletions lib/components/ChecklistCard/ChecklistCard.docs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,16 +78,15 @@ const docs: ComponentDocs = {
id={`${id}_1`}
label="This is a checkbox"
checked={false}
tone="critical"
message="This is a critical message"
message={false}
onChange={handleChange}
>
<Text>This text is visible when the checkbox is checked.</Text>
</Checkbox>
<Checkbox
id={`${id}_2`}
label="This is a checkbox"
checked={true}
checked={false}
tone="critical"
message="This is a critical message"
onChange={handleChange}
Expand All @@ -97,7 +96,7 @@ const docs: ComponentDocs = {
<Checkbox
id={`${id}_3`}
label="This is a checkbox"
checked={false}
checked={true}
tone="critical"
message="This is a critical message"
onChange={handleChange}
Expand All @@ -107,15 +106,6 @@ const docs: ComponentDocs = {
<Checkbox
id={`${id}_4`}
label="This is a checkbox"
checked={true}
message={false}
onChange={handleChange}
>
<Text>This text is visible when the checkbox is checked.</Text>
</Checkbox>
<Checkbox
id={`${id}_5`}
label="This is a checkbox"
checked={false}
message={false}
onChange={handleChange}
Expand Down
26 changes: 18 additions & 8 deletions lib/components/ChecklistCard/ChecklistCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,24 @@ export default class ChecklistCard extends Component<ChecklistCardProps> {
const { children, ...restProps } = this.props;
return (
<Card {...restProps}>
{React.Children.map(children, (child, i) => (
<Fragment>
{i > 0 && <Divider />}
{React.cloneElement(child as ReactElement<CheckboxProps>, {
variant: 'inChecklistCard'
})}
</Fragment>
))}
{React.Children.map(children, (child, i) => {
if (typeof child !== 'object') {
return null;
}

const checkboxChild = child as ReactElement<CheckboxProps>;

return (
<Fragment>
{i > 0 && checkboxChild.props.tone !== 'critical' ? (
<Divider />
) : null}
{React.cloneElement(child, {
variant: 'inChecklistCard'
})}
</Fragment>
);
})}
</Card>
);
}
Expand Down

0 comments on commit fc3c4a5

Please sign in to comment.