verdnatura-chat/app/containers/markdown/MessageBody/Italic.js

38 lines
791 B
JavaScript
Raw Normal View History

2021-08-12 21:05:18 +00:00
/* eslint-disable react/no-array-index-key */
import React from 'react';
import { StyleSheet, Text } from 'react-native';
import PropTypes from 'prop-types';
import Strike from './Strike';
import Bold from './Bold';
2021-08-20 16:25:30 +00:00
import Plain from './Plain';
2021-08-12 21:05:18 +00:00
const styles = StyleSheet.create({
text: {
fontStyle: 'italic'
}
});
const Italic = ({ value }) => (
<Text style={styles.text}>
{value.map((block, index) => {
switch (block.type) {
case 'PLAIN_TEXT':
return <Plain key={index} value={block.value} />;
case 'STRIKE':
return <Strike key={index} value={block.value} />;
case 'BOLD':
return <Bold key={index} value={block.value} />;
default:
return null;
}
})}
</Text>
);
Italic.propTypes = {
value: PropTypes.string
};
export default Italic;