All files / app/components RevSelector.tsx

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                                  3x   3x         3x           3x           3x       3x 8x                             3x  
import React from 'react';
import { style } from 'app/styles';
 
import { CaretLeftIcon } from 'app/components/CaretLeftIcon';
import { CaretRightIcon } from 'app/components/CaretRightIcon';
import { Selectable } from 'app/components/Selectable';
 
export interface RevSelectorProps {
  // This is the text or JSX that gets wrapped in stacked label
  children: string | JSX.Element | JSX.Element[];
  onPreviousRevClick: (evt) => void;
  onNextRevClick: (evt) => void;
  style?: string | object;
  disablePrevious?: boolean;
  disableNext?: boolean;
}
 
const ICON_SIZE = 16;
 
const defaultContainerStyle = {
  _extends: ['flexRow', 'normalText'],
  alignSelf: 'baseline',
};
 
const iconStyle = {
  _extends: 'flexRow',
  color: '@colors.altForeground',
  marginBottom: '5px',
};
 
const labelStyle = {
  _extends: 'flexColumn',
  flexGrow: 0,
  alignItems: 'center',
};
 
const grower = {
  flexGrow: 1,
};
 
export const RevSelector = (props: RevSelectorProps): JSX.Element => {
  return (
    <div style={style(defaultContainerStyle, props.style)}>
      <div style={style(grower)} />
      <Selectable style={style(iconStyle)} onClick={props.onPreviousRevClick}>
        <CaretLeftIcon height={ICON_SIZE} width={ICON_SIZE} />
      </Selectable>
      <div style={style(labelStyle)}>{props.children}</div>
      <Selectable style={style(iconStyle)} onClick={props.onNextRevClick}>
        <CaretRightIcon height={ICON_SIZE} width={ICON_SIZE} />
      </Selectable>
      <div style={style(grower)} />
    </div>
  );
};
 
RevSelector.displayName = 'RevSelector';