Skip to content

Commit df01049

Browse files
kaja-osojniklukaw3d
authored andcommitted
Update Status Icons
1 parent 619ea28 commit df01049

1 file changed

Lines changed: 28 additions & 39 deletions

File tree

src/app/components/StatusIcon/index.tsx

Lines changed: 28 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,36 @@
11
import { FC, ReactNode } from 'react'
22
import { useTranslation } from 'react-i18next'
3-
import CheckCircleIcon from '@mui/icons-material/CheckCircle'
4-
import CancelIcon from '@mui/icons-material/Cancel'
53
import { COLORS } from '../../../styles/theme/colors'
6-
import HelpIcon from '@mui/icons-material/Help'
7-
import LockIcon from '@mui/icons-material/Lock'
84
import { TxError } from '../../../oasis-nexus/api'
95
import { Tooltip } from '@oasisprotocol/ui-library/src/components/tooltip'
106
import { useTxErrorMessage } from '../../hooks/useTxErrorMessage'
117
import { TFunction } from 'i18next'
128
import { cn } from '@oasisprotocol/ui-library/src/lib/utils'
9+
import { CircleCheck, CircleX, CircleHelp, Clock } from 'lucide-react'
1310

14-
type TxStatus = 'unknown' | 'success' | 'partialsuccess' | 'failure' | 'pending'
11+
type TxStatus = 'unknown' | 'success' | 'failure' | 'pending'
1512

1613
const statusBgColor: Record<TxStatus, string> = {
17-
unknown: COLORS.grayMediumLight,
18-
success: COLORS.eucalyptus,
19-
partialsuccess: COLORS.honeydew,
20-
failure: COLORS.linen,
21-
pending: COLORS.warningLight,
14+
unknown: 'bg-zinc-500',
15+
success: 'bg-success',
16+
failure: 'bg-destructive',
17+
pending: 'bg-zinc-500',
2218
}
2319

24-
const statusFgColor: Record<TxStatus, string> = {
25-
unknown: COLORS.grayMedium,
26-
success: COLORS.honeydew,
27-
partialsuccess: COLORS.eucalyptus,
28-
failure: COLORS.errorIndicatorBackground,
29-
pending: COLORS.warningColor,
30-
}
20+
const statusIcon = (status: TxStatus, size: number, withText?: boolean): ReactNode => {
21+
// [&_circle]:stroke-transparent fixes background animation on new transactions
22+
const strokeClass = withText ? 'stroke-background' : '[&_circle]:stroke-transparent'
3123

32-
const statusIcon: Record<TxStatus, ReactNode> = {
33-
unknown: <LockIcon color="inherit" fontSize="inherit" />,
34-
success: <CheckCircleIcon color="inherit" fontSize="inherit" />,
35-
partialsuccess: <CheckCircleIcon color="success" fontSize="inherit" />,
36-
failure: <CancelIcon color="error" fontSize="inherit" />,
37-
pending: <HelpIcon color="inherit" fontSize="inherit" />,
24+
switch (status) {
25+
case 'unknown':
26+
return <CircleHelp size={size} className={cn('fill-zinc-500', strokeClass)} />
27+
case 'success':
28+
return <CircleCheck size={size} className={cn('fill-success', strokeClass)} />
29+
case 'failure':
30+
return <CircleX size={size} className={cn('fill-destructive', strokeClass)} />
31+
case 'pending':
32+
return <Clock size={size} className={cn('fill-zinc-500', strokeClass)} />
33+
}
3834
}
3935

4036
interface StatusBadgeProps {
@@ -46,13 +42,10 @@ interface StatusBadgeProps {
4642
export const StatusBadge: FC<StatusBadgeProps> = ({ status, children, withText }) => (
4743
<div
4844
className={cn(
49-
'flex justify-center items-center text-sm rounded-lg',
50-
withText ? 'px-3 py-1' : 'w-7 min-h-7 p-1',
45+
'flex justify-center items-center text-sm rounded-lg text-background',
46+
withText ? 'px-3 py-1' : 'p-0',
47+
withText && statusBgColor[status],
5148
)}
52-
style={{
53-
backgroundColor: statusBgColor[status],
54-
color: statusFgColor[status],
55-
}}
5649
>
5750
{children}
5851
</div>
@@ -119,28 +112,24 @@ export const StatusIcon: FC<StatusIconProps> = ({ success, error, withText, meth
119112
const statusLabel: Record<TxStatus, string> = {
120113
unknown: t('common.unknown'),
121114
success: t('common.success'),
122-
partialsuccess: t('common.partial_success'),
123115
failure: t('common.failed'),
124116
pending: getPendingLabel(t, method, withText),
125117
}
126118
const errorMessage = useTxErrorMessage(error)
119+
const iconSize = withText ? 16 : 20
127120

128121
if (withText) {
129122
return (
130123
<>
131124
<div
132125
className={cn(
133-
'flex justify-center items-center text-sm rounded-lg',
134-
withText ? 'px-3 py-1' : 'w-7 min-h-7 p-1',
126+
'flex justify-center items-center text-sm rounded-full text-background gap-2',
127+
withText ? 'px-4 py-0.5' : 'w-7 min-h-7 p-1',
128+
withText && statusBgColor[status],
135129
)}
136-
style={{
137-
backgroundColor: statusBgColor[status],
138-
color: statusFgColor[status],
139-
}}
140130
>
141131
{statusLabel[status]}
142-
&nbsp;
143-
{statusIcon[status]}
132+
{statusIcon(status, iconSize, withText)}
144133
</div>
145134
{errorMessage && <StatusDetails error>{errorMessage}</StatusDetails>}
146135
{!errorMessage && status === 'pending' && <StatusDetails>{getPendingLabel(t, method)}</StatusDetails>}
@@ -150,7 +139,7 @@ export const StatusIcon: FC<StatusIconProps> = ({ success, error, withText, meth
150139
return (
151140
<Tooltip title={errorMessage ? `${statusLabel[status]}: ${errorMessage}` : statusLabel[status]}>
152141
<StatusBadge status={status} withText={withText}>
153-
{statusIcon[status]}
142+
{statusIcon(status, iconSize, withText)}
154143
</StatusBadge>
155144
</Tooltip>
156145
)

0 commit comments

Comments
 (0)