# All files / components/TimeScrubber/components TimeScrubberViewport.js

0% Statements 0/28
0% Branches 0/12
0% Functions 0/6
0% Lines 0/14

    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
    79
    80
    81

     import React from 'react';
    import styled from 'styled-components';
    import themeGet from 'extensions/themeGet';
    import TimeDisplay from './TimeScrubberTimeDisplay';

    const Indicator = styled.div`
      position: absolute;
      z-index: 1;
      left: 50%;
      transform: translateX(-1px);
      background: ${themeGet('colors.text.default')};
      width: 3px;
      height: 5px;
      bottom: 0;
    `;

    const Overlay = styled.div`
      pointer-events: none;
      position: absolute;
      left: 0;
      right: 0;
      top: 0;
      bottom: 0;
      z-index: 2;
    `;

    const Window = styled.div`
      position: relative;
      overflow-x: hidden;
      overflow-y: hidden;
      width: 100%;
      cursor: ${props => (props.disabled ? 'default' : 'grab')};
      pointer-events: ${props => (props.disabled ? 'none' : 'initial')};
      border: ${themeGet('thicknesses.wide')} solid
        ${props =>
          props.disabled
            ? themeGet('colors.border.disabled')(props)
            : themeGet('colors.border.light')(props)};
      border-left: 0;
      border-right: 0;
      height: 53px;
      background: ${props =>
        props.disabled
          ? themeGet('colors.background.disabled')(props)
          : themeGet('colors.background.default')(props)};
      transition: all 0.2s ease;

      &:focus {
        outline: 0;

        box-shadow: inset 0 -5px 0 ${themeGet('colors.primary.light')};
        border-color: ${themeGet('colors.border.medium')};
      }

      &:active {
        cursor: grabbing;
      }
    `;

    const Centered = styled.div`
      position: absolute;
      left: 50%;
      bottom: 0;
      top: 0;
    `;

    /**
     * A limited viewport area in which the Timeline bar moves. Automatically
     * starts all content at the center of the visible viewport. Use relative
     * offsets on content to move content within the viewport.
     */
    const Viewport = ({ children, time, ...rest }) => (
      <Window {...rest} tabIndex={0}>
        <Centered>{children}</Centered>
        <Indicator />
        <TimeDisplay time={time} />
      </Window>
    );

    export default Viewport;