1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-23 09:52:26 +01:00
metamask-extension/ui/app/components/ui/list-item/list-item.component.js
Erik Marks e18deda0da
@metamask/eslint-config*@6.0.0 (#10858)
* @metamask/eslint-config*@6.0.0

* Minor eslintrc reorg
2021-04-08 14:34:55 -07:00

65 lines
1.7 KiB
JavaScript

import React from 'react';
import PropTypes from 'prop-types';
import classnames from 'classnames';
export default function ListItem({
title,
subtitle,
onClick,
children,
titleIcon,
icon,
rightContent,
midContent,
className,
'data-testid': dataTestId,
}) {
const primaryClassName = classnames('list-item', className);
return (
<div
className={primaryClassName}
onClick={onClick}
data-testid={dataTestId}
role="button"
tabIndex={0}
onKeyPress={(event) => {
if (event.key === 'Enter') {
onClick();
}
}}
>
{icon && <div className="list-item__icon">{icon}</div>}
<div className="list-item__heading">
{React.isValidElement(title) ? (
title
) : (
<h2 className="list-item__title">{title}</h2>
)}
{titleIcon && (
<div className="list-item__heading-wrap">{titleIcon}</div>
)}
</div>
{subtitle && <div className="list-item__subheading">{subtitle}</div>}
{children && <div className="list-item__actions">{children}</div>}
{midContent && <div className="list-item__mid-content">{midContent}</div>}
{rightContent && (
<div className="list-item__right-content">{rightContent}</div>
)}
</div>
);
}
ListItem.propTypes = {
'title': PropTypes.oneOfType([PropTypes.string, PropTypes.node]),
'titleIcon': PropTypes.node,
'subtitle': PropTypes.node,
'children': PropTypes.node,
'icon': PropTypes.node,
'rightContent': PropTypes.node,
'midContent': PropTypes.node,
'className': PropTypes.string,
'onClick': PropTypes.func,
'data-testid': PropTypes.string,
};