Files
redash/client/app/components/groups/ListItemAddon.jsx
Rafael Wendel c8df7a1c8a Add jsx/a11y eslint plugin (#5439)
* build: install eslint jsx/a11y

* chore: add ESlint rules for jsx/a11y

* bug: add exceptions
2021-03-24 18:50:21 -03:00

51 lines
1.3 KiB
JavaScript

import React from "react";
import PropTypes from "prop-types";
import Tooltip from "@/components/Tooltip";
export default function ListItemAddon({ isSelected, isStaged, alreadyInGroup, deselectedIcon }) {
if (isStaged) {
return (
<>
<i className="fa fa-remove" aria-hidden="true" />
<span className="sr-only">Remove</span>
</>
);
}
if (alreadyInGroup) {
return (
<Tooltip title="Already selected">
{/* eslint-disable-next-line jsx-a11y/no-noninteractive-tabindex */}
<span tabIndex={0}>
<i className="fa fa-check" aria-hidden="true" />
<span className="sr-only">Already selected</span>
</span>
</Tooltip>
);
}
return isSelected ? (
<>
<i className="fa fa-check" aria-hidden="true" />
<span className="sr-only">Selected</span>
</>
) : (
<>
<i className={`fa ${deselectedIcon}`} aria-hidden="true" />
<span className="sr-only">Select</span>
</>
);
}
ListItemAddon.propTypes = {
isSelected: PropTypes.bool,
isStaged: PropTypes.bool,
alreadyInGroup: PropTypes.bool,
deselectedIcon: PropTypes.string,
};
ListItemAddon.defaultProps = {
isSelected: false,
isStaged: false,
alreadyInGroup: false,
deselectedIcon: "fa-angle-double-right",
};