Update Code component and add it to storybooks

This commit is contained in:
Gerzon Z 2021-08-21 01:59:45 -04:00
parent c2dd2dbc48
commit 8f26301428
3 changed files with 55 additions and 3 deletions

View File

@ -8,7 +8,7 @@ import { useTheme } from '../../../theme';
const InlineCode = ({ value, style }) => { const InlineCode = ({ value, style }) => {
const { theme } = useTheme(); const { theme } = useTheme();
console.log({ value: value.value });
return ( return (
<Text style={[ <Text style={[
{ {
@ -20,7 +20,14 @@ const InlineCode = ({ value, style }) => {
...style ...style
]} ]}
> >
{value.type === 'PLAIN_TEXT' && value.value} {((block) => {
switch (block.type) {
case 'PLAIN_TEXT':
return block.value;
default:
return null;
}
})(value)}
</Text> </Text>
); );
}; };

View File

@ -31,7 +31,6 @@ const Body = ({
case 'TASK': case 'TASK':
return <OrderedList key={index} value={block.value} />; return <OrderedList key={index} value={block.value} />;
case 'QUOTE': case 'QUOTE':
console.log({ block });
return <Quote key={index} value={block.value} />; return <Quote key={index} value={block.value} />;
case 'PARAGRAPH': case 'PARAGRAPH':
return ( return (

View File

@ -476,6 +476,52 @@ stories.add('Headers', () => (
</View> </View>
)); ));
const inlineCodeToken = [
{
type: 'PARAGRAPH',
value: [
{
type: 'INLINE_CODE',
value: {
type: 'PLAIN_TEXT',
value: 'inline code'
}
}
]
}
];
const multilineCodeToken = [
{
type: 'CODE',
language: 'none',
value: [
{
type: 'CODE_LINE',
value: {
type: 'PLAIN_TEXT',
value: 'Multi line '
}
},
{
type: 'CODE_LINE',
value: {
type: 'PLAIN_TEXT',
value: 'Code'
}
}
]
}
];
stories.add('Code', () => (
<View style={styles.container}>
<MessageBody tokens={inlineCodeToken} style={[]} />
<MessageBody tokens={multilineCodeToken} style={[]} />
</View>
));
const unorederedListToken = [ const unorederedListToken = [
{ {
type: 'UNORDERED_LIST', type: 'UNORDERED_LIST',