Skip to content

Commit

Permalink
fix: add doc description to Description
Browse files Browse the repository at this point in the history
  • Loading branch information
atanasster committed Aug 9, 2020
1 parent 13f3765 commit bee5777
Showing 1 changed file with 19 additions and 9 deletions.
28 changes: 19 additions & 9 deletions ui/blocks/src/Description/Description.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
import React, { FC } from 'react';
import { Markdown, MarkdownProps } from '@component-controls/components';
import { ComponentsContainer } from '../BlockContainer/components/ComponentsContainer';
import { useComponents, ComponentInputProps } from '@component-controls/store';
import {
useComponents,
ComponentInputProps,
useCurrentDocument,
} from '@component-controls/store';

export type DescriptionProps = Omit<MarkdownProps, 'children'> &
ComponentInputProps;
Expand All @@ -12,14 +16,20 @@ export type DescriptionProps = Omit<MarkdownProps, 'children'> &
*/
export const Description: FC<DescriptionProps> = ({ of, ...rest }) => {
const components = useComponents({ of });
const doc = useCurrentDocument();
return (
<ComponentsContainer components={components}>
{component => {
if (!component || !component.info || !component.info.description) {
return null;
}
return <Markdown {...rest}>{component.info.description}</Markdown>;
}}
</ComponentsContainer>
<>
<ComponentsContainer components={components}>
{component => {
if (!component || !component.info || !component.info.description) {
return null;
}
return <Markdown {...rest}>{component.info.description}</Markdown>;
}}
</ComponentsContainer>
{doc && doc.description && (
<Markdown {...rest}>{doc.description}</Markdown>
)}
</>
);
};

0 comments on commit bee5777

Please sign in to comment.