react95-native
Version:
Refreshed Windows 95 style UI components for your React Native app
56 lines (51 loc) • 1.21 kB
JavaScript
import React from 'react';
import { StyleSheet, View } from 'react-native';
import { withTheme } from '../../core/theming';
import { Divider } from '../..';
import Text from './Text';
const Title = ({
align = 'center',
children,
theme,
...rest
}) => {
const getAlignment = () => {
switch (align) {
case 'left':
return 'flex-start';
case 'right':
return 'flex-end';
default:
return 'center';
}
};
return /*#__PURE__*/React.createElement(View, {
style: [styles.wrapper]
}, /*#__PURE__*/React.createElement(Divider, {
style: [styles.divider]
}), /*#__PURE__*/React.createElement(View, {
style: {
paddingLeft: align !== 'left' ? 8 : 0,
paddingRight: align !== 'right' ? 8 : 0,
backgroundColor: theme.material,
alignSelf: getAlignment()
}
}, /*#__PURE__*/React.createElement(Text, rest, children)));
};
const styles = StyleSheet.create({
wrapper: {
position: 'relative',
width: '100%'
},
divider: {
position: 'absolute',
left: 0,
right: 0,
top: '50%',
transform: [{
translateY: -1
}]
}
});
export default withTheme(Title);
//# sourceMappingURL=Title.js.map