From 4be8169d5119135e89303091daa8707de787b5e5 Mon Sep 17 00:00:00 2001 From: Eric Mika Date: Thu, 7 Mar 2024 12:10:23 -0500 Subject: [PATCH] Docs: Pass dynamic prop condition description to PropTable component. --- docs/src/components/docs/PropTable.astro | 6 ++++-- docs/src/utils/prop-utils.ts | 12 ++++++++---- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/docs/src/components/docs/PropTable.astro b/docs/src/components/docs/PropTable.astro index 485e7f1..d489e0c 100644 --- a/docs/src/components/docs/PropTable.astro +++ b/docs/src/components/docs/PropTable.astro @@ -145,8 +145,10 @@ const { Available when {/* set:text below works around prettier */} {Object.values(conditionData[prop.name]) - .map((value) => ( - + .map(({ condition }) => ( + )) .reduce((previous, current) => [previous, ' or ', current])} diff --git a/docs/src/utils/prop-utils.ts b/docs/src/utils/prop-utils.ts index 9c490c8..b0f17b2 100644 --- a/docs/src/utils/prop-utils.ts +++ b/docs/src/utils/prop-utils.ts @@ -2,9 +2,10 @@ import type { Props as StarlightProps } from '@astrojs/starlight/props'; export type ComponentData = StarlightProps['entry']['data']['componentData']; export type ComponentProp = NonNullable['props'][number]; -export type Condition = NonNullable< - NonNullable['dynamicProps'] ->[number]['condition']; +export type Condition = Omit< + NonNullable['dynamicProps']>[number], + 'props' +>; export type ConditionsRecord = Record; export function uniqueProps( @@ -31,7 +32,10 @@ export function allPropConditions(data: ComponentData): ConditionsRecord { conditionsRecord[prop.name] = []; } - conditionsRecord[prop.name].push(dynamicProp.condition); + conditionsRecord[prop.name].push({ + condition: dynamicProp.condition, + description: dynamicProp.description + }); } }