crane-cloud/frontend

View on GitHub
src/components/Tabs/Tab.jsx

Summary

Maintainability
A
0 mins
Test Coverage
B
80%
import React from "react";
import PropTypes from "prop-types";

const Tab = ({ index, onClick, label, activeTab }) => {
  const handleOnClick = () => {
    onClick(index);
  };

  return (
    <li
      className={`TabHeadingListItem ${
        activeTab === index && "TabHeadingListItemActive"
      }`}
      onClick={handleOnClick}
      role="presentation"
    >
      {label}
    </li>
  );
};

Tab.propTypes = {
  index: PropTypes.number.isRequired,
  onClick: PropTypes.func.isRequired,
  label: PropTypes.oneOfType([PropTypes.string, PropTypes.shape({})])
    .isRequired,
  activeTab: PropTypes.number.isRequired,
};

export default Tab;