From 9f33845adb88cfdd12512bc397756da62889eec1 Mon Sep 17 00:00:00 2001 From: matheusps Date: Thu, 18 Apr 2024 16:40:56 -0300 Subject: [PATCH] refactor(site): improve component summary usage --- .../component-summary/component-summary.tsx | 45 ++++++++++++------- packages/docs/pages/components/index.mdx | 13 ------ 2 files changed, 28 insertions(+), 30 deletions(-) diff --git a/packages/docs/components/component-summary/component-summary.tsx b/packages/docs/components/component-summary/component-summary.tsx index ff4b6be102..6eb9722c0f 100644 --- a/packages/docs/components/component-summary/component-summary.tsx +++ b/packages/docs/components/component-summary/component-summary.tsx @@ -1,26 +1,35 @@ import type { ComponentPropsWithoutRef, ReactNode } from 'react' import React from 'react' import NextLink from 'next/link' +import Image from 'next/image' import styles from './component-summary.module.css' import { getComponentProps } from '../../utils/get-component-props' +const imageEstimatedWidth = 370 +const imageEstimatedHeight = 218 + +/** + * Renders a component summary + */ export function ComponentSummary(props: ComponentSummaryProps) { - const { - children, - title, - description, - icon, - href, - image, - name, - ...restProps - } = props + const { href, image, name, ...restProps } = props const componentProps = getComponentProps(name) return ( - -
{image}
+ +
+ {name} +

{componentProps?.name}

{componentProps?.description}

@@ -30,11 +39,13 @@ export function ComponentSummary(props: ComponentSummaryProps) { } interface ComponentSummaryProps extends ComponentPropsWithoutRef<'a'> { - children: ReactNode - title: string - href: string - icon: ReactNode - description?: string + /** + * Link href + */ + href?: string + /** + * Component image + */ image?: ReactNode /** * Component name diff --git a/packages/docs/pages/components/index.mdx b/packages/docs/pages/components/index.mdx index efb5ddcbdb..1348420d3a 100644 --- a/packages/docs/pages/components/index.mdx +++ b/packages/docs/pages/components/index.mdx @@ -1,6 +1,5 @@ # Components -import Image from 'next/image' import { allComponentsList, allLayoutsList, allPrimitivesList } from '../../utils/all-components-list' import { pascalCase } from '@vtex/shoreline' @@ -9,10 +8,6 @@ import { pascalCase } from '@vtex/shoreline' - } - href={`/components/${component}`} /> ))} @@ -24,10 +19,6 @@ import { pascalCase } from '@vtex/shoreline' - } - href={`/components/${component}`} /> ))} @@ -39,10 +30,6 @@ import { pascalCase } from '@vtex/shoreline' - } - href={`/components/${component}`} /> ))} \ No newline at end of file