-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Use distinct icons for "status dot" (#38)
- Loading branch information
Showing
2 changed files
with
21 additions
and
12 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,34 @@ | ||
import { FunctionComponent } from 'react' | ||
import clsx from 'clsx' | ||
import Icon from './Icon.js' | ||
import { faCircleCheck, faXmark } from '@fortawesome/free-solid-svg-icons' | ||
|
||
export const StatusDot: FunctionComponent<{ | ||
status: 'success' | 'failure' | 'active' | undefined | ||
}> = (props) => { | ||
if (props.status === 'active') { | ||
}> = ({ status }) => { | ||
if (status === 'active') { | ||
return ( | ||
<span className='relative inline-block h-3 w-3'> | ||
<span className='relative inline-block h-4 w-4'> | ||
<span className='absolute h-full w-full rounded-full bg-sky-400 opacity-75 animate-ping' /> | ||
<span className='absolute h-full w-full rounded-full bg-blue-500' /> | ||
</span> | ||
) | ||
} | ||
|
||
// Distinguish by shape and not just color to be accessible to colorblind users | ||
|
||
if (status === 'success') { | ||
return ( | ||
<Icon icon={faCircleCheck} className='text-green-500 text-base' /> | ||
) | ||
} | ||
|
||
if (status === 'failure') { | ||
return ( | ||
<Icon icon={faXmark} className='text-red-500 text-base' /> | ||
) | ||
} | ||
|
||
return ( | ||
<span className={clsx( | ||
'inline-block rounded-full h-3 w-3', | ||
props.status === 'success' && 'bg-green-500', | ||
props.status === 'failure' && 'bg-red-500', | ||
props.status == null && 'bg-gray-500 animate-pulse' | ||
)} | ||
/> | ||
<span className='inline-block rounded-full h-4 w-4 bg-gray-500 animate-pulse' /> | ||
) | ||
} |
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