-
Notifications
You must be signed in to change notification settings - Fork 259
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: new pill component (#1222)
- Loading branch information
Showing
6 changed files
with
199 additions
and
67 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 { MarkGithubIcon } from '@primer/octicons-react'; | ||
import { render } from '@testing-library/react'; | ||
import { IconColor } from '../../types'; | ||
import { type IPillButton, PillButton } from './PillButton'; | ||
|
||
describe('components/buttons/PillButton.tsx', () => { | ||
it('should render', () => { | ||
const props: IPillButton = { | ||
title: 'Mock Pill', | ||
metric: 1, | ||
icon: MarkGithubIcon, | ||
color: IconColor.GREEN, | ||
}; | ||
const tree = render(<PillButton {...props} />); | ||
expect(tree).toMatchSnapshot(); | ||
}); | ||
}); |
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,29 @@ | ||
import type { Icon } from '@primer/octicons-react'; | ||
import type { FC } from 'react'; | ||
import type { IconColor } from '../../types'; | ||
|
||
export interface IPillButton { | ||
key?: string; | ||
title: string; | ||
metric?: number; | ||
icon: Icon; | ||
color: IconColor; | ||
} | ||
|
||
export const PillButton: FC<IPillButton> = (props: IPillButton) => { | ||
return ( | ||
<span title={props.title}> | ||
<button | ||
type="button" | ||
className="rounded-full text-xss px-1 m-0.5 bg-gray-100 hover:bg-gray-200 dark:bg-gray-800 dark:hover:bg-gray-700" | ||
> | ||
<props.icon | ||
size={12} | ||
className={`mr-1 ${props.color}`} | ||
aria-label={props.title} | ||
/> | ||
{props.metric} | ||
</button> | ||
</span> | ||
); | ||
}; |
114 changes: 114 additions & 0 deletions
114
src/components/buttons/__snapshots__/PillButton.test.tsx.snap
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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