Scrollable.js 936 B

1234567891011121314151617181920212223242526272829303132333435363738
  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. import 'react-perfect-scrollbar/dist/css/styles.css';
  8. // ensure rails are shown over the rest
  9. const fixRailsZIndex = '.ps__rail-y, ps__rail-x {z-index: 999999; }';
  10. const Scrollable = props => {
  11. const scrollStyle = {
  12. position: 'relative'
  13. };
  14. if (props.height !== null) {
  15. scrollStyle.height = props.height;
  16. }
  17. return (
  18. <>
  19. <style>{fixRailsZIndex}</style>
  20. <PerfectScrollbar {...props} style={scrollStyle}>
  21. {props.children}
  22. </PerfectScrollbar>
  23. </>
  24. );
  25. };
  26. Scrollable.propTypes = {
  27. /** height of the element */
  28. height: PropTypes.string
  29. };
  30. Scrollable.defaultProps = {
  31. height: '250px'
  32. };
  33. export default Scrollable;