Skip to content

Commit

Permalink
fix: component info from story/doc
Browse files Browse the repository at this point in the history
  • Loading branch information
atanasster committed Feb 22, 2021
1 parent 3041b27 commit 51bd3ae
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions plugins/addon-catalog/src/ComponentCard/ComponentCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,11 @@ import {
PackageLink,
ComponentContributors,
ComponentStats,
getStoryTitle,
} from '@component-controls/blocks';
import {
useStore,
useStory,
useStoryComponent,
useStoryPath,
} from '@component-controls/store';
Expand All @@ -32,14 +34,18 @@ export const ComponentCard: FC<ComponentCardProps & BoxProps> = ({
}) => {
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 (
<Card {...rest}>
<div
Expand All @@ -50,9 +56,7 @@ export const ComponentCard: FC<ComponentCardProps & BoxProps> = ({
}}
>
<Link href={href}>
<div sx={{ fontSize: 4, fontWeight: 'bold' }}>
{component.info?.displayName}
</div>
<div sx={{ fontSize: 4, fontWeight: 'bold' }}>{title}</div>
</Link>
<div
sx={{
Expand All @@ -69,9 +73,7 @@ export const ComponentCard: FC<ComponentCardProps & BoxProps> = ({
)}

<div sx={{ borderBottom: '1px solid rgba(0, 0, 0, 0.125)', my: 2 }} />
{component.info?.description && (
<Markdown>{component.info.description}</Markdown>
)}
{description && <Markdown>{description}</Markdown>}
{store.stories[id] && (
<div sx={{ flex: 1 }}>
<StoryRender
Expand Down

0 comments on commit 51bd3ae

Please sign in to comment.