Banner.tsx 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. import React from "react";
  2. import styled from "styled-components";
  3. import info from "assets/info.svg";
  4. import warning from "assets/warning.png";
  5. interface Props {
  6. type?: string;
  7. children: React.ReactNode;
  8. }
  9. const Banner: React.FC<Props> = ({ type, children }) => {
  10. const renderIcon = () => {
  11. if (type === "error" || type === "warning") {
  12. return <i className="material-icons-round">warning</i>;
  13. }
  14. return <img src={info} />;
  15. };
  16. return (
  17. <StyledBanner
  18. color={type === "error" ? "#ff385d" : type === "warning" && "#f5cb42"}
  19. >
  20. {renderIcon()}
  21. {children}
  22. </StyledBanner>
  23. );
  24. };
  25. export default Banner;
  26. const StyledBanner = styled.div<{ color?: string }>`
  27. height: 40px;
  28. width: 100%;
  29. margin: 5px 0 10px;
  30. font-size: 13px;
  31. font-family: "Work Sans", sans-serif;
  32. display: flex;
  33. border: 1px solid ${(props) => props.color || "#ffffff00"};
  34. border-radius: 8px;
  35. padding-left: 14px;
  36. color: ${(props) => props.color || "#ffffff"};
  37. align-items: center;
  38. background: #ffffff11;
  39. > img {
  40. margin-right: 10px;
  41. width: 20px;
  42. }
  43. > i {
  44. margin-right: 10px;
  45. font-size: 18px;
  46. }
  47. > a {
  48. color: ${(props) => props.color || "#ffffff"};
  49. }
  50. `;