From 51bd3ae2cb225e96cc41de99a28ffe639a18092d Mon Sep 17 00:00:00 2001 From: atanasster Date: Mon, 22 Feb 2021 01:36:01 -0500 Subject: [PATCH] fix: component info from story/doc --- .../src/ComponentCard/ComponentCard.tsx | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/plugins/addon-catalog/src/ComponentCard/ComponentCard.tsx b/plugins/addon-catalog/src/ComponentCard/ComponentCard.tsx index 48930b161..20887610e 100644 --- a/plugins/addon-catalog/src/ComponentCard/ComponentCard.tsx +++ b/plugins/addon-catalog/src/ComponentCard/ComponentCard.tsx @@ -8,9 +8,11 @@ import { PackageLink, ComponentContributors, ComponentStats, + getStoryTitle, } from '@component-controls/blocks'; import { useStore, + useStory, useStoryComponent, useStoryPath, } from '@component-controls/store'; @@ -32,14 +34,18 @@ export const ComponentCard: FC = ({ }) => { const href = useStoryPath(id); const store = useStore(); + const story = useStory({ id }); const component = useStoryComponent({ id }); if (!component) { return null; } + const doc = story?.doc ? store.docs[story.doc] : undefined; const pckg = component.package ? store.packages[component.package] : undefined; const { browse } = pckg?.repository || {}; + const title = getStoryTitle(doc, component); + const description = component.info?.description || story?.description; return (
= ({ }} > -
- {component.info?.displayName} -
+
{title}
= ({ )}
- {component.info?.description && ( - {component.info.description} - )} + {description && {description}} {store.stories[id] && (