Chevron.jsx 1.0 KB

1234567891011121314151617181920212223242526272829303132333435
  1. import React from "react";
  2. import styled from "styled-components";
  3. const StyledChevron = styled.span`
  4. position: relative;
  5. display: inline-block;
  6. ${({ orientation, color }) => {
  7. switch (orientation) {
  8. case "top":
  9. case "bottom":
  10. return `border-color: ${color} transparent;`;
  11. default:
  12. return `border-color: transparent ${color};`;
  13. }
  14. }}
  15. border-style: solid;
  16. ${({ orientation, size }) => {
  17. switch (orientation) {
  18. case "top":
  19. return `border-width: 0 ${size / 2}px ${size}px ${size / 2}px;`;
  20. case "bottom":
  21. return `border-width: ${size}px ${size / 2}px 0 ${size / 2}px;`;
  22. case "left":
  23. return `border-width: ${size / 2}px ${size}px ${size / 2}px 0;`;
  24. default:
  25. return `border-width: ${size / 2}px 0 ${size / 2}px ${size}px;`;
  26. }
  27. }}
  28. `;
  29. const Spinner = ({ size = 14, orientation = "right", color = "#fff" }) => (
  30. <StyledChevron size={size} orientation={orientation} color={color} />
  31. );
  32. export default Spinner;