UNPKG

react95-native

Version:

Refreshed Windows 95 style UI components for your React Native app

65 lines (63 loc) 2.1 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, { useState } from 'react'; import { StyleSheet, View, TouchableHighlight } from 'react-native'; import { withTheme } from '../../core/theming'; import { blockSizes, builtTextStyles } from '../../styles/styles'; import { Text } from '../..'; // TODO: add icon prop export const Item = ({ disabled, onPress, primary = false, size = 'md', style, theme, title, ...rest }) => { const [isPressed, setIsPressed] = useState(false); const textStyles = builtTextStyles(theme); return /*#__PURE__*/React.createElement(View, _extends({}, rest, { style: [styles.item, { height: blockSizes[size] }, { backgroundColor: isPressed ? theme.hoverBackground : theme.material }, style] }), /*#__PURE__*/React.createElement(TouchableHighlight, { style: [styles.button], onPress: onPress, disabled: disabled, onHideUnderlay: () => setIsPressed(false), onShowUnderlay: () => setIsPressed(true), underlayColor: "none" // TODO: which accessibilityRole put in here? , accessibilityRole: "menuitem", accessibilityState: { disabled } }, /*#__PURE__*/React.createElement(View, { pointerEvents: "none", style: [styles.content] }, /*#__PURE__*/React.createElement(Text, { theme: theme, bold: primary, style: [disabled ? textStyles.disabled : textStyles.default, !disabled && { color: isPressed ? theme.materialTextInvert : theme.materialText }] }, title)))); }; const styles = StyleSheet.create({ item: { position: 'relative' }, button: { flex: 1, justifyContent: 'center', alignItems: 'center', paddingHorizontal: 8 }, content: { alignSelf: 'flex-start' } }); export default withTheme(Item); //# sourceMappingURL=MenuItem.js.map