verdnatura-chat/app/containers/markdown/new/Code.tsx

39 lines
754 B
TypeScript
Raw Normal View History

2021-10-28 17:48:53 +00:00
import React from 'react';
import { View } from 'react-native';
2021-10-28 17:48:53 +00:00
import { Code as CodeProps } from '@rocket.chat/message-parser';
import styles from '../styles';
import { useTheme } from '../../../theme';
import CodeLine from './CodeLine';
interface ICodeProps {
value: CodeProps['value'];
}
const Code = ({ value }: ICodeProps): React.ReactElement => {
const { colors } = useTheme();
2021-10-28 17:48:53 +00:00
return (
<View
2021-10-28 17:48:53 +00:00
style={[
styles.codeBlock,
{
backgroundColor: colors.bannerBackground,
borderColor: colors.borderColor
2021-10-28 17:48:53 +00:00
}
]}
>
2021-10-28 17:48:53 +00:00
{value.map(block => {
switch (block.type) {
case 'CODE_LINE':
return <CodeLine value={block.value} />;
default:
return null;
}
})}
</View>
2021-10-28 17:48:53 +00:00
);
};
export default Code;