Breadcrumb.tsx 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. import React, { Fragment } from "react";
  2. import styled from "styled-components";
  3. type Props = {
  4. currentStep: string;
  5. steps: Array<{ value: string; label: string }>;
  6. onClickStep?: (step: string) => void;
  7. };
  8. const Breadcrumb: React.FC<Props> = ({ currentStep, steps, onClickStep }) => {
  9. return (
  10. <StyledBreadcrumb>
  11. {steps.map((step: { value: string; label: string }, i: number) => {
  12. return (
  13. <Fragment key={i}>
  14. <Crumb
  15. bold={currentStep === step.value}
  16. onClick={() => {
  17. onClickStep && onClickStep(step.value);
  18. }}
  19. >
  20. {step.label}
  21. </Crumb>
  22. {i !== steps.length - 1 && " > "}
  23. </Fragment>
  24. );
  25. })}
  26. </StyledBreadcrumb>
  27. );
  28. };
  29. export default Breadcrumb;
  30. const StyledBreadcrumb = styled.div`
  31. color: #aaaabb;
  32. `;
  33. const Crumb = styled.span<{ bold: boolean }>`
  34. font-weight: ${(props) => (props.bold ? "600" : "normal")};
  35. color: ${(props) => (props.bold ? "#ffffff" : "#aaaabb")};
  36. font-size: 13px;
  37. `;