1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-01 21:57:06 +01:00
metamask-extension/ui/components/multichain/activity-list-item/activity-list-item.js
vthomas13 4dcde1e216
Multichain Activity Screen (#19557)
* layout wip

* Icon changes, add badgewrapped icons to smart tx

* grouping by date wip

* typo fix

* group txs by date, button styling

* removing queue/history division, adding datestamp for pending tx, minor styling changes

* adding tests, updating snap

* font size fix

* e2e fixes

* Remove unnecessary tabIndex and keypress handler

* Fix typo for fontWeight

* Fix nesting warning by removing unnecessary Text

* Fix tests

* Fix import and exports

* Remove unused verbiage

* Update E2E selectors

* More E2E

* More E2Es

* More test fixes

* awaiting find instead of click

* adding regularDelayMs to flaky test

* removing delay

* increasing delay outside of wait

* adding back first-child to selector

* test fixes

* using datatestid for primary currency

* sorting date txgroups

* wip alignment for big numbers

* alignment issues fix

* lintfix

* adding tabindex, cursor pointer, updating snap

* unit test fix

* storybook additions

* snaphot update

* update snap

---------

Co-authored-by: David Walsh <davidwalsh83@gmail.com>
2023-07-17 13:48:15 -04:00

138 lines
3.5 KiB
JavaScript

import React from 'react';
import PropTypes from 'prop-types';
import classnames from 'classnames';
import {
AlignItems,
BackgroundColor,
BlockSize,
Display,
FlexDirection,
FlexWrap,
FontWeight,
TextAlign,
TextColor,
TextVariant,
} from '../../../helpers/constants/design-system';
import { Box, Text } from '../../component-library';
export const ActivityListItem = ({
topContent,
icon,
title,
subtitle,
midContent,
children,
rightContent,
onClick,
className,
'data-testid': dataTestId,
}) => {
const primaryClassName = classnames('activity-list-item', className, {
'activity-list-item--single-content-row': !(subtitle || children),
});
return (
<Box
tabIndex={0}
backgroundColor={BackgroundColor.backgroundDefault}
className={primaryClassName}
onClick={onClick}
onKeyPress={(event) => {
if (event.key === 'Enter') {
onClick();
}
}}
data-testid={dataTestId}
padding={4}
display={Display.Flex}
width={BlockSize.Full}
flexWrap={FlexWrap.Wrap}
gap={4}
>
{topContent && (
<Text
variant={TextVariant.bodyMd}
color={TextColor.textDefault}
display={Display.Flex}
width={BlockSize.Full}
>
{topContent}
</Text>
)}
<Box
display={Display.Flex}
width={BlockSize.Full}
flexDirection={FlexDirection.Row}
gap={4}
>
{icon && <Box display={Display.InlineFlex}>{icon}</Box>}
<Box display={Display.InlineFlex} width={BlockSize.Full}>
<Box
display={Display.InlineFlex}
width={[BlockSize.OneThird, BlockSize.SevenTwelfths]}
flexDirection={FlexDirection.Column}
className="activity-list-item__detail-container"
>
<Text
ellipsis
textAlign={TextAlign.Left}
variant={TextVariant.bodyLgMedium}
fontWeight={FontWeight.Medium}
data-testid="activity-list-item-action"
>
{title}
</Text>
{subtitle && (
<Text
as="div"
ellipsis
textAlign={TextAlign.Left}
variant={TextVariant.bodyMd}
fontWeight={FontWeight.Normal}
>
{subtitle}
</Text>
)}
{children && (
<Box className="activity-list-item__children">{children}</Box>
)}
</Box>
{midContent && (
<Box
display={Display.InlineFlex}
className="activity-list-item__mid-content"
>
{midContent}
</Box>
)}
{rightContent && (
<Box
display={Display.InlineFlex}
width={BlockSize.Full}
flexDirection={FlexDirection.Column}
alignItems={AlignItems.flexEnd}
className="activity-list-item__right-content"
>
{rightContent}
</Box>
)}
</Box>
</Box>
</Box>
);
};
ActivityListItem.propTypes = {
topContent: PropTypes.node,
icon: PropTypes.node,
title: PropTypes.oneOfType([PropTypes.string, PropTypes.node]),
subtitle: PropTypes.node,
midContent: PropTypes.node,
children: PropTypes.node,
rightContent: PropTypes.node,
onClick: PropTypes.func,
className: PropTypes.string,
'data-testid': PropTypes.string,
};