1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-04 23:14:56 +01:00
metamask-extension/ui/components/app/transaction-activity-log/transaction-activity-log-icon/transaction-activity-log-icon.component.js
2023-04-19 14:16:49 -07:00

52 lines
1.6 KiB
JavaScript

import React, { PureComponent } from 'react';
import PropTypes from 'prop-types';
import classnames from 'classnames';
import {
TRANSACTION_CREATED_EVENT,
TRANSACTION_SUBMITTED_EVENT,
TRANSACTION_RESUBMITTED_EVENT,
TRANSACTION_CONFIRMED_EVENT,
TRANSACTION_DROPPED_EVENT,
TRANSACTION_ERRORED_EVENT,
TRANSACTION_CANCEL_ATTEMPTED_EVENT,
TRANSACTION_CANCEL_SUCCESS_EVENT,
} from '../transaction-activity-log.constants';
import { Icon, IconName, IconSize } from '../../../component-library';
import { Color } from '../../../../helpers/constants/design-system';
export const ACTIVITY_ICONS = {
[TRANSACTION_CREATED_EVENT]: IconName.Add,
[TRANSACTION_SUBMITTED_EVENT]: IconName.ArrowUp,
[TRANSACTION_RESUBMITTED_EVENT]: IconName.ProgrammingArrows,
[TRANSACTION_CONFIRMED_EVENT]: IconName.Check,
[TRANSACTION_DROPPED_EVENT]: IconName.Close,
[TRANSACTION_ERRORED_EVENT]: IconName.Danger,
[TRANSACTION_CANCEL_ATTEMPTED_EVENT]: IconName.Close,
[TRANSACTION_CANCEL_SUCCESS_EVENT]: IconName.Close,
};
export default class TransactionActivityLogIcon extends PureComponent {
static contextTypes = {
t: PropTypes.func,
};
static propTypes = {
className: PropTypes.string,
eventKey: PropTypes.oneOf(Object.keys(ACTIVITY_ICONS)),
};
render() {
const { className, eventKey } = this.props;
const icon = ACTIVITY_ICONS[eventKey];
return (
<div className={classnames('transaction-activity-log-icon', className)}>
{icon ? (
<Icon name={icon} color={Color.iconDefault} size={IconSize.Sm} />
) : null}
</div>
);
}
}