Scrollable.js 882 B

12345678910111213141516171819202122232425262728293031323334353637
  1. // SLIMSCROLL
  2. // -----------------------------------
  3. import React, { Component } from 'react';
  4. import PropTypes from 'prop-types';
  5. // Perfect Scrollbar
  6. import PerfectScrollbar from 'react-perfect-scrollbar';
  7. // ensure rails are shown over the rest
  8. const fixRailsZIndex = '.ps__rail-y, ps__rail-x {z-index: 999999; }';
  9. const Scrollable = props => {
  10. const scrollStyle = {
  11. position: 'relative'
  12. };
  13. if (props.height !== null) {
  14. scrollStyle.height = props.height;
  15. }
  16. return (
  17. <>
  18. <style>{fixRailsZIndex}</style>
  19. <PerfectScrollbar {...props} style={scrollStyle}>
  20. {props.children}
  21. </PerfectScrollbar>
  22. </>
  23. );
  24. };
  25. Scrollable.propTypes = {
  26. /** height of the element */
  27. height: PropTypes.string
  28. };
  29. Scrollable.defaultProps = {
  30. height: '250px'
  31. };
  32. export default Scrollable;