TableNav.tsx 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. import React, { FC } from 'react';
  2. import styled, { css } from 'styled-components';
  3. import { ifProp } from 'styled-tools';
  4. import { Flex } from 'reflexbox/styled-components';
  5. interface Props {
  6. handleNav: any; // TODO: types
  7. next: boolean;
  8. prev: boolean;
  9. }
  10. const Nav = styled.button<{ disabled: boolean }>`
  11. margin-left: 12px;
  12. padding: 5px 8px 3px;
  13. border-radius: 4px;
  14. border: 1px solid #eee;
  15. background-color: transparent;
  16. box-shadow: 0 0px 10px rgba(100, 100, 100, 0.1);
  17. transition: all 0.2s ease-out;
  18. ${ifProp(
  19. 'disabled',
  20. css`
  21. background-color: white;
  22. cursor: pointer;
  23. `
  24. )}
  25. ${ifProp(
  26. { disabled: false },
  27. css`
  28. :hover {
  29. transform: translateY(-2px);
  30. box-shadow: 0 5px 25px rgba(50, 50, 50, 0.1);
  31. }
  32. `
  33. )}
  34. @media only screen and (max-width: 768px) {
  35. padding: 4px 6px 2px;
  36. }
  37. `;
  38. const Icon = styled.img`
  39. width: 14px;
  40. height: 14px;
  41. @media only screen and (max-width: 768px) {
  42. width: 12px;
  43. height: 12px;
  44. }
  45. `;
  46. const TableNav: FC<Props> = ({ handleNav, next, prev }) => (
  47. <Flex alignItems="center">
  48. <Nav disabled={!prev} onClick={handleNav(-1)}>
  49. <Icon src="/images/nav-left.svg" />
  50. </Nav>
  51. <Nav disabled={!next} onClick={handleNav(1)}>
  52. <Icon src="/images/nav-right.svg" />
  53. </Nav>
  54. </Flex>
  55. );
  56. export default TableNav;