2021-08-03 18:13:07 +00:00
|
|
|
import React from 'react';
|
2021-08-12 21:05:18 +00:00
|
|
|
import { Text } from 'react-native';
|
|
|
|
import PropTypes from 'prop-types';
|
2021-08-03 18:13:07 +00:00
|
|
|
import { themes } from '../../../constants/colors';
|
|
|
|
import { useTheme } from '../../../theme';
|
|
|
|
|
|
|
|
const Code = ({
|
|
|
|
type, styles, style, literal
|
|
|
|
}) => {
|
|
|
|
const theme = useTheme();
|
|
|
|
return (
|
|
|
|
<Text
|
|
|
|
style={[
|
|
|
|
{
|
2021-08-12 21:05:18 +00:00
|
|
|
...(type === 'INLINE_CODE' ? styles.codeInline : styles.codeBlock),
|
2021-08-03 18:13:07 +00:00
|
|
|
color: themes[theme].bodyText,
|
|
|
|
backgroundColor: themes[theme].bannerBackground,
|
|
|
|
borderColor: themes[theme].bannerBackground
|
|
|
|
},
|
|
|
|
...style
|
|
|
|
]}
|
|
|
|
>
|
|
|
|
{literal}
|
|
|
|
</Text>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
Code.propTypes = {
|
|
|
|
type: PropTypes.string,
|
|
|
|
literal: PropTypes.string,
|
|
|
|
styles: PropTypes.object,
|
|
|
|
style: PropTypes.object
|
|
|
|
};
|
|
|
|
|
|
|
|
export default Code;
|