File size: 1,023 Bytes
f5071ca
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import React from 'react';
import styled from 'styled-components';

// The parent of ScrollableArea should have "position" set to "relative"
// otherwise the scrollable area will overflow the content
const StyledScrollableArea = styled.div`
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  right: 0;

  display: flex;
  flex-direction: column;

  .scroller {
    flex: 1 1 auto;
    overflow-y: auto;
    flex-grow: 1;

    /* Firefox fix */
    min-height: 0;
  }

  .scroller.force-vertical {
    overflow-y: scroll;
  }
`;

const ScrollableArea = ({ children, forceVertical, tinyStyle, autoHide, invisible }) => (
  <StyledScrollableArea>
    <div
      className={[
        'scroller',
        forceVertical && 'force-vertical',
        !tinyStyle && 'scrollbar-default',
        tinyStyle && 'scrollbar-tiny',
        autoHide && 'scrollbar-autoHide',
        invisible && 'scrollbar-invisible'
      ].join(' ')}
    >
      {children}
    </div>
  </StyledScrollableArea>
);

export default ScrollableArea;