Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 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 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 | 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x | /*
Copyright (c) 2018-2019 Uber Technologies, Inc.
This source code is licensed under the MIT license found in the
LICENSE file in the root directory of this source tree.
*/
// @flow
import {getTrackBackground} from 'react-range';
import {styled} from '../styles/index.js';
import type {StylePropsT} from './types.js';
export const Root = styled('div', {position: 'relative'});
Root.displayName = 'StyledRoot';
export const Track = styled<StylePropsT>('div', props => {
const {$theme, $value, $disabled, $isDragged} = props;
const {sizing} = $theme;
let cursor = 'inherit';
if ($disabled) {
cursor = 'not-allowed';
} else if ($isDragged) {
cursor = 'grabbing';
} else if ($value.length === 1) {
cursor = 'pointer';
}
return {
paddingTop: sizing.scale1000,
paddingBottom: sizing.scale600,
paddingRight: sizing.scale600,
paddingLeft: sizing.scale600,
display: 'flex',
cursor,
};
});
Track.displayName = 'StyledTrack';
export const InnerTrack = styled<StylePropsT>('div', props => {
const {$theme, $value, $min, $max, $disabled} = props;
const {colors, borders, sizing} = $theme;
const borderRadius = $theme.borders.useRoundedCorners ? borders.radius100 : 0;
return {
borderTopLeftRadius: borderRadius,
borderTopRightRadius: borderRadius,
borderBottomRightRadius: borderRadius,
borderBottomLeftRadius: borderRadius,
background: getTrackBackground({
values: $value,
colors:
$value.length === 1
? [colors.primary, colors.mono400]
: [colors.mono400, colors.primary, colors.mono400],
min: $min,
max: $max,
}),
height: sizing.scale100,
width: '100%',
alignSelf: 'center',
cursor: $disabled ? 'not-allowed' : 'inherit',
};
});
InnerTrack.displayName = 'StyledInnerTrack';
export const Tick = styled<StylePropsT>('div', props => {
return {
...props.$theme.typography.font300,
};
});
Tick.displayName = 'StyledTick';
export const TickBar = styled<StylePropsT>('div', props => {
const {$theme} = props;
const {sizing} = $theme;
return {
display: 'flex',
justifyContent: 'space-between',
alignItems: 'center',
paddingRight: sizing.scale600,
paddingLeft: sizing.scale600,
paddingBottom: sizing.scale400,
};
});
TickBar.displayName = 'StyledTickBar';
export const Thumb = styled<StylePropsT>('div', props => {
const {$theme, $value, $thumbIndex, $disabled} = props;
const isLeft = $value.length === 2 && $thumbIndex === 0;
const isRight = $value.length === 2 && $thumbIndex === 1;
return {
height: '24px',
width: isLeft || isRight ? '12px' : '24px',
borderTopLeftRadius: isRight ? '1px' : '4px',
borderTopRightRadius: isLeft ? '1px' : '4px',
borderBottomLeftRadius: isRight ? '1px' : '4px',
borderBottomRightRadius: isLeft ? '1px' : '4px',
backgroundColor: $theme.colors.mono100,
display: 'flex',
justifyContent: 'center',
alignItems: 'center',
borderWidth: '1px',
borderStyle: 'solid',
borderColor: $theme.colors.mono400,
boxShadow: '0 1px 4px rgba(0, 0, 0, 0.12)',
cursor: $disabled ? 'not-allowed' : 'inherit',
};
});
Thumb.displayName = 'StyledThumb';
export const InnerThumb = styled<StylePropsT>('div', props => {
const {$theme, $isDragged} = props;
return {
height: '8px',
width: '2px',
borderTopLeftRadius: '2px',
borderTopRightRadius: '2px',
borderBottomRightRadius: '2px',
borderBottomLeftRadius: '2px',
backgroundColor: $isDragged ? $theme.colors.primary : $theme.colors.mono600,
};
});
InnerThumb.displayName = 'StyledInnerThumb';
export const ThumbValue = styled<StylePropsT>('div', props => {
const {$theme} = props;
return {
position: 'absolute',
top: `-${$theme.sizing.scale800}`,
...$theme.typography.font300,
backgroundColor: 'transparent',
};
});
ThumbValue.displayName = 'StyledThumbValue';
|