-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
587da6f
commit a57393b
Showing
16 changed files
with
144 additions
and
91 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
99 changes: 51 additions & 48 deletions
99
apps/site/src/components/component-props-table/component-props-table.component.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,61 +1,64 @@ | ||
import { Badge, Table } from '@westpac/ui'; | ||
import { clsx } from 'clsx'; | ||
import React from 'react'; | ||
|
||
import { type ComponentPropsTableProps } from './component-props-table.types'; | ||
|
||
export function ComponentPropsTable({ className, componentProps, ...props }: ComponentPropsTableProps) { | ||
console.dir(componentProps, { depth: null }); | ||
return ( | ||
<Table bordered striped {...props}> | ||
<Table.Caption className="text-left">{componentProps.displayName} props</Table.Caption> | ||
<Table.Header> | ||
<Table.Row> | ||
{[ | ||
{ label: 'Property', className: 'w-1/12' }, | ||
{ label: 'Type', className: 'w-1/12' }, | ||
{ label: 'Default', className: 'w-1/12' }, | ||
{ label: 'Required', className: 'w-1/12' }, | ||
{ label: 'Description', className: 'w-3/12' }, | ||
].map(({ label, className }) => ( | ||
<Table.HeaderCell key={label} className={`text-left ${className}`}> | ||
{label} | ||
</Table.HeaderCell> | ||
))} | ||
</Table.Row> | ||
</Table.Header> | ||
<Table.Body> | ||
{Object.entries(componentProps.props || {}).map(([key, value]) => { | ||
const type = value.type.name; | ||
const defaultValue = value.defaultValue?.value; | ||
const required = value.required ? 'true' : 'false'; | ||
<div className="-mx-2 overflow-x-auto px-2 xsl:-mx-5 xsl:px-5 sm:-mx-6 sm:px-6 md:-mx-8 md:px-8 lg:-mx-10 lg:px-10"> | ||
<Table bordered striped {...props} className={clsx('min-w-[800px]', className)}> | ||
<Table.Caption className="text-left">{componentProps.displayName} props</Table.Caption> | ||
<Table.Header> | ||
<Table.Row> | ||
{[ | ||
{ label: 'Property', className: 'w-1/12' }, | ||
{ label: 'Type', className: 'w-1/12' }, | ||
{ label: 'Default', className: 'w-1/12' }, | ||
{ label: 'Required', className: 'w-1/12' }, | ||
{ label: 'Description', className: 'w-3/12' }, | ||
].map(({ label, className }) => ( | ||
<Table.HeaderCell key={label} className={`text-left ${className}`}> | ||
{label} | ||
</Table.HeaderCell> | ||
))} | ||
</Table.Row> | ||
</Table.Header> | ||
<Table.Body> | ||
{Object.entries(componentProps.props || {}).map(([key, value]) => { | ||
const type = value.type.name; | ||
const defaultValue = value.defaultValue?.value; | ||
const required = value.required ? 'true' : 'false'; | ||
|
||
return ( | ||
<Table.Row key={key}> | ||
<Table.Cell className="w-1/12">{key}</Table.Cell> | ||
<Table.Cell className="w-1/12"> | ||
{type && ( | ||
<Badge color="faint" className="whitespace-normal bg-background text-left"> | ||
{type} | ||
</Badge> | ||
)} | ||
</Table.Cell> | ||
<Table.Cell className="w-1/12"> | ||
{defaultValue && ( | ||
return ( | ||
<Table.Row key={key}> | ||
<Table.Cell className="w-1/12">{key}</Table.Cell> | ||
<Table.Cell className="w-1/12"> | ||
{type && ( | ||
<Badge color="faint" className="whitespace-normal bg-background text-left"> | ||
{type} | ||
</Badge> | ||
)} | ||
</Table.Cell> | ||
<Table.Cell className="w-1/12"> | ||
{defaultValue && ( | ||
<Badge color="faint" className="bg-background"> | ||
{defaultValue} | ||
</Badge> | ||
)} | ||
</Table.Cell> | ||
<Table.Cell className="w-1/12"> | ||
<Badge color="faint" className="bg-background"> | ||
{defaultValue} | ||
{required} | ||
</Badge> | ||
)} | ||
</Table.Cell> | ||
<Table.Cell className="w-1/12"> | ||
<Badge color="faint" className="bg-background"> | ||
{required} | ||
</Badge> | ||
</Table.Cell> | ||
<Table.Cell className="w-3/12">{value.description}</Table.Cell> | ||
</Table.Row> | ||
); | ||
})} | ||
</Table.Body> | ||
</Table> | ||
</Table.Cell> | ||
<Table.Cell className="w-3/12">{value.description}</Table.Cell> | ||
</Table.Row> | ||
); | ||
})} | ||
</Table.Body> | ||
</Table> | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.