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

View File

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

View File

@ -476,6 +476,52 @@ stories.add('Headers', () => (
</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 = [
{
type: 'UNORDERED_LIST',