File size: 1,979 Bytes
1e92f2d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
// @flow
import styled, { css } from 'styled-components';
import theme from 'shared/theme';
import { tint } from 'src/components/globals';
import { MEDIA_BREAK } from 'src/components/layout';

export const StyledSegmentedControl = styled.div`
  display: flex;
  width: 100%;
  box-shadow: inset 0 -1px ${theme.bg.border};
  background: ${theme.bg.default};
  overflow: hidden;
  overflow-x: scroll;
  position: ${props => (props.sticky ? 'sticky' : 'relative')};
  z-index: ${props => (props.sticky ? '13' : '1')};

  ${props =>
    props.sticky &&
    css`
      top: ${props => (props.stickyOffset ? `${props.stickyOffset}px` : '0')};
    `};

  &::-webkit-scrollbar {
    width: 0px;
    height: 0px;
    background: transparent; /* make scrollbar transparent */
  }

  @media (max-width: ${MEDIA_BREAK}px) {
    max-width: 100vw;
    position: ${props => (props.mobileSticky ? 'sticky' : 'relative')};
    top: ${props =>
      props.mobileStickyOffset ? `${props.mobileStickyOffset}px` : '0'};
  }
`;

export const StyledSegment = styled.div`
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  flex: 1 0 auto;
  font-weight: 600;
  color: ${props => (props.isActive ? theme.text.default : theme.text.alt)};
  box-shadow: ${props =>
    props.isActive ? `inset 0 -2px 0 ${theme.text.default}` : 'none'};
  text-align: center;

  &:hover {
    background: ${theme.bg.wash};
    box-shadow: ${props =>
      props.isActive
        ? `inset 0 -2px 0 ${theme.text.default}`
        : `inset 0 -2px 0 ${tint(theme.bg.wash, -16)}`};
    color: ${props =>
      props.isActive ? theme.text.default : theme.text.secondary};
    cursor: pointer;
  }

  @media (max-width: ${MEDIA_BREAK}px) {
    &:hover {
      background: ${theme.bg.default};
    }

    &:active {
      background: ${theme.bg.wash};
    }
  }

  @media (min-width: ${MEDIA_BREAK}px) {
    ${props =>
      props.hideOnDesktop &&
      css`
        display: none;
      `}
  }
`;