Skip to content

Commit

Permalink
fix contentplaceholder
Browse files Browse the repository at this point in the history
  • Loading branch information
Carlo Bernardini committed Jun 23, 2021
1 parent d019db1 commit 324eb96
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
6 changes: 6 additions & 0 deletions src/components/WeightedResultBar/WeightedResultBar.scss
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,11 @@
margin-bottom: var(--spacing-2x);
display: flex;
justify-content: space-between;
align-items: center;
}

&__placeholder {
margin-bottom: 0;
flex-grow: 2;
}
}
10 changes: 7 additions & 3 deletions src/components/WeightedResultBar/WeightedResultBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,19 @@ export const WeightedResultBar: React.FC<Props> = (props) => {
<div {...rest} {...block(props)}>
<div {...elem('details', props)}>
{isLoading ? (
<ContentPlaceholder height={15} width={Math.floor(Math.random() * 60) + 25} />
<ContentPlaceholder
{...elem('placeholder', props)}
height={17}
width={Math.floor(Math.random() * 60) + 25}
/>
) : (
<Text inline>{children}</Text>
)}
{['number', 'string'].includes(typeof count) ? <Text inline>{count}</Text> : count}
</div>
<ProgressBar
percentage={isLoading ? 0 : percentage}
context={isLoading ? undefined : context}
percentage={isLoading ? 100 : percentage}
context={isLoading ? 'neutral' : context}
small
/>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ describe('WeightedResultBar', () => {
const wrapper = shallow(<WeightedResultBar isLoading />);

expect(wrapper.find('ContentPlaceholder').length).toBe(1);
expect(wrapper.find('ProgressBar').prop('percentage')).toBe(0);
expect(wrapper.find('ProgressBar').prop('percentage')).toBe(100);
expect(wrapper.find('ProgressBar').prop('context')).toBe('neutral');
});
});

0 comments on commit 324eb96

Please sign in to comment.