UNPKG

react95-native

Version:

Refreshed Windows 95 style UI components for your React Native app

63 lines (56 loc) 2.19 kB
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } import React from 'react'; import { StyleSheet, View } from 'react-native'; import { withTheme } from '../../core/theming'; const pixelSize = 2; const ChevronIcon = ({ color, direction = 'down', disabled = false, segments = 5, style = {}, theme, ...rest }) => { const baseColor = color || theme.materialText; let segmentSizes = new Array(segments).fill(null).map((_, i) => 1 + i * 2); if (['right', 'down'].includes(direction)) { segmentSizes = segmentSizes.reverse(); } const isHorizontal = ['left', 'right'].includes(direction); const SegmentPixel = () => /*#__PURE__*/React.createElement(View, { style: { [isHorizontal ? 'width' : 'height']: pixelSize * 2, [isHorizontal ? 'height' : 'width']: pixelSize, backgroundColor: disabled ? theme.materialTextDisabled : baseColor, shadowColor: disabled ? theme.materialTextDisabledShadow : 'transparent', shadowOffset: { width: pixelSize, height: pixelSize }, shadowOpacity: 1, shadowRadius: 0 } }); return /*#__PURE__*/React.createElement(View, _extends({ style: [styles.wrapper, { flexDirection: isHorizontal ? 'row' : 'column' }, style] }, rest), segmentSizes.map((segmentSize, i) => /*#__PURE__*/React.createElement(View, { key: i, style: [{ [isHorizontal ? 'height' : 'width']: pixelSize * segmentSize, [isHorizontal ? 'width' : 'height']: pixelSize, flexDirection: isHorizontal ? 'column' : 'row', justifyContent: 'space-between' }] }, segmentSize !== 1 && /*#__PURE__*/React.createElement(SegmentPixel, null), /*#__PURE__*/React.createElement(SegmentPixel, null)))); }; const styles = StyleSheet.create({ wrapper: { position: 'relative', alignItems: 'center' } }); export default withTheme(ChevronIcon); //# sourceMappingURL=ChevronIcon.js.map