Skip to content

Commit

Permalink
fix: hide blocks that have no content
Browse files Browse the repository at this point in the history
  • Loading branch information
atanasster committed Apr 16, 2020
1 parent 9dc671c commit 7885080
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export const ComponentsBlockContainer: FC<ComponentsBlockContainerProps> = ({
{(component, props, otherProps) => children(component, props, otherProps)}
</ComponentsContainer>
);
return (
return block ? (
<BlockContainer
title={title}
collapsible={collapsible}
Expand All @@ -57,5 +57,5 @@ export const ComponentsBlockContainer: FC<ComponentsBlockContainerProps> = ({
>
{block}
</BlockContainer>
);
) : null;
};
4 changes: 2 additions & 2 deletions ui/blocks/src/BlockContainer/story/StoryBlockContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export const StoryBlockContainer: FC<StoryBlockContainerProps> = ({
title: userTitle,
});
const block = children(context, rest);
return (
return block ? (
<BlockContainer
title={title}
collapsible={collapsible}
Expand All @@ -48,5 +48,5 @@ export const StoryBlockContainer: FC<StoryBlockContainerProps> = ({
>
{block}
</BlockContainer>
);
) : null;
};
6 changes: 5 additions & 1 deletion ui/blocks/src/PropsTable/PropsTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,12 @@ export const PropsTable: FC<PropsTableProps> = ({
if (!info) {
return null;
}
const keys = Object.keys(info.props);
if (!keys.length) {
return null;
}
const parents = new Set();
const rows = Object.keys(info.props).map(key => {
const rows = keys.map(key => {
const prop = info.props[key];
const parentName = prop.parentName ?? '-';
parents.add(parentName);
Expand Down

0 comments on commit 7885080

Please sign in to comment.