TBodyButton.js 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. import React from 'react';
  2. import PropTypes from 'prop-types';
  3. import styled, { css } from 'styled-components';
  4. const Button = styled.button`
  5. display: flex;
  6. justify-content: center;
  7. align-items: center;
  8. width: 26px;
  9. height: 26px;
  10. margin: 0 12px 0 2px;
  11. padding: 0;
  12. border: none;
  13. outline: none;
  14. border-radius: 100%;
  15. box-shadow: 0 2px 4px rgba(100, 100, 100, 0.1);
  16. background-color: #dedede;
  17. cursor: pointer;
  18. transition: all 0.2s ease-out;
  19. @media only screen and (max-width: 768px) {
  20. height: 22px;
  21. width: 22px;
  22. margin: 0 8px 0 2px;
  23. img {
  24. width: 10px;
  25. height: 10px;
  26. }
  27. }
  28. ${({ withText }) =>
  29. withText &&
  30. css`
  31. width: auto;
  32. padding: 0 12px;
  33. border-radius: 100px;
  34. img {
  35. margin: 4px 6px 0 0;
  36. }
  37. @media only screen and (max-width: 768px) {
  38. width: auto;
  39. }
  40. `};
  41. :active,
  42. :focus {
  43. outline: none;
  44. }
  45. :hover {
  46. transform: translateY(-2px);
  47. }
  48. `;
  49. const TBodyButton = ({ children, withText, ...props }) => (
  50. <Button withText={withText} {...props}>
  51. {children}
  52. </Button>
  53. );
  54. TBodyButton.propTypes = {
  55. children: PropTypes.node.isRequired,
  56. withText: PropTypes.bool,
  57. };
  58. TBodyButton.defaultProps = {
  59. withText: null,
  60. };
  61. export default TBodyButton;