From 8f2630142887bbee2f3a17f7f6ee9680b62b68ec Mon Sep 17 00:00:00 2001 From: Gerzon Z Date: Sat, 21 Aug 2021 01:59:45 -0400 Subject: [PATCH] Update Code component and add it to storybooks --- .../markdown/MessageBody/InlineCode.js | 11 ++++- app/containers/markdown/MessageBody/index.js | 1 - storybook/stories/MessageBody.js | 46 +++++++++++++++++++ 3 files changed, 55 insertions(+), 3 deletions(-) diff --git a/app/containers/markdown/MessageBody/InlineCode.js b/app/containers/markdown/MessageBody/InlineCode.js index d9e8d940a..051c9dc29 100644 --- a/app/containers/markdown/MessageBody/InlineCode.js +++ b/app/containers/markdown/MessageBody/InlineCode.js @@ -8,7 +8,7 @@ import { useTheme } from '../../../theme'; const InlineCode = ({ value, style }) => { const { theme } = useTheme(); - console.log({ value: value.value }); + return ( { ...style ]} > - {value.type === 'PLAIN_TEXT' && value.value} + {((block) => { + switch (block.type) { + case 'PLAIN_TEXT': + return block.value; + default: + return null; + } + })(value)} ); }; diff --git a/app/containers/markdown/MessageBody/index.js b/app/containers/markdown/MessageBody/index.js index a3ca0d29d..6950c2429 100644 --- a/app/containers/markdown/MessageBody/index.js +++ b/app/containers/markdown/MessageBody/index.js @@ -31,7 +31,6 @@ const Body = ({ case 'TASK': return ; case 'QUOTE': - console.log({ block }); return ; case 'PARAGRAPH': return ( diff --git a/storybook/stories/MessageBody.js b/storybook/stories/MessageBody.js index 23c247c87..b3a4a39f5 100644 --- a/storybook/stories/MessageBody.js +++ b/storybook/stories/MessageBody.js @@ -476,6 +476,52 @@ stories.add('Headers', () => ( )); +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', () => ( + + + + +)); + const unorederedListToken = [ { type: 'UNORDERED_LIST',