-
Notifications
You must be signed in to change notification settings - Fork 73
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: Extract tag count component as generic
- Loading branch information
Showing
6 changed files
with
44 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
.generic-tag-count.zero-count { | ||
opacity: .4; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import React from 'react'; | ||
import { render, screen } from '@testing-library/react'; | ||
import TagCount from '.'; | ||
|
||
describe('<TagCount>', () => { | ||
it('should render the component', () => { | ||
const count = 17; | ||
render(<TagCount count={count} />); | ||
expect(screen.getByText('17')).toBeInTheDocument(); | ||
}); | ||
|
||
it('should render the component with zero', () => { | ||
const count = 0; | ||
render(<TagCount count={count} />); | ||
expect(screen.getByText('0')).toBeInTheDocument(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import PropTypes from 'prop-types'; | ||
import { Icon } from '@openedx/paragon'; | ||
import { Tag } from '@openedx/paragon/icons'; | ||
import classNames from 'classnames'; | ||
|
||
const TagCount = ({ count }) => ( | ||
<div className={ | ||
classNames('generic-tag-count d-flex', { 'zero-count': count === 0 }) | ||
} | ||
> | ||
<Icon className="mr-1 pt-1" src={Tag} /> | ||
{count} | ||
</div> | ||
); | ||
|
||
TagCount.propTypes = { | ||
count: PropTypes.number.isRequired, | ||
}; | ||
|
||
export default TagCount; |