Skip to content

Commit

Permalink
fix(react): fix Breadcrumb separator using incorrect type; update to …
Browse files Browse the repository at this point in the history
…v2 documentation (#983)
  • Loading branch information
scurker authored Mar 23, 2023
1 parent ce7d629 commit 336beca
Show file tree
Hide file tree
Showing 4 changed files with 85 additions and 90 deletions.
25 changes: 15 additions & 10 deletions docs/components/ComponentProps.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ interface Props {
type?: string | string[];
}
| boolean;
ref?: string;
refType?: string;
props: ComponentProps[];
}

function TableProps({ children, ref, props }: Props) {
function TableProps({ children, refType, props }: Props) {
return (
<Table className="Component__Props">
<TableHead>
Expand Down Expand Up @@ -82,10 +82,10 @@ function TableProps({ children, ref, props }: Props) {
</TableRow>
)
)}
{ref && (
{refType && (
<TableRow>
<TableCell>Ref</TableCell>
<TableCell>{ref}</TableCell>
<TableCell>ref</TableCell>
<TableCell>React.RefObject&lt;{refType}&gt;</TableCell>
<TableCell></TableCell>
<TableCell>
A ref pointed to the element rendered by this component.
Expand All @@ -100,7 +100,7 @@ function TableProps({ children, ref, props }: Props) {
function DescriptionListProps({
children,
props,
ref,
refType,
collapsed
}: Props & { collapsed?: boolean }) {
return (
Expand Down Expand Up @@ -166,7 +166,7 @@ function DescriptionListProps({
</li>
)
)}
{ref && (
{refType && (
<li>
<DescriptionList collapsed={collapsed}>
<DescriptionListItem>
Expand All @@ -175,7 +175,7 @@ function DescriptionListProps({
</DescriptionListItem>
<DescriptionListItem>
<DescriptionTerm>Type</DescriptionTerm>
<DescriptionDetails>{ref}</DescriptionDetails>
<DescriptionDetails>{refType}</DescriptionDetails>
</DescriptionListItem>
<DescriptionListItem>
<DescriptionTerm>Description</DescriptionTerm>
Expand All @@ -190,7 +190,11 @@ function DescriptionListProps({
);
}

export default function ComponentProps({ children, props }: Props) {
export default function ComponentProps({
children,
refType,
props = []
}: Props) {
const [narrow, setNarrow] = useState(false);
const [collapsed, setCollapsed] = useState(false);

Expand Down Expand Up @@ -223,9 +227,10 @@ export default function ComponentProps({ children, props }: Props) {
<DescriptionListProps
children={children}
props={props}
refType={refType}
collapsed={collapsed}
/>
) : (
<TableProps children={children} props={props} />
<TableProps children={children} refType={refType} props={props} />
);
}
69 changes: 69 additions & 0 deletions docs/pages/components/Breadcrumb.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
---
title: Breadcrumb
description: The Breadcrumb component displays a list of links within a hierarchy and allows navigation back through them.
source: https://github.com/dequelabs/cauldron/tree/develop/packages/react/src/components/Breadcrumb/Breadcrumb.tsx
---

import { Icon, Breadcrumb, BreadcrumbLink, BreadcrumbItem } from '@deque/cauldron-react'

```js
import {
Breadcrumb,
BreadcrumbLink,
BreadcrumbItem
} from '@deque/cauldron-react'
```

## Examples

### Basic

```jsx example
<Breadcrumb aria-label="Breadcrumb">
<BreadcrumbLink href="/one">One</BreadcrumbLink>
<BreadcrumbLink href="/two">Two</BreadcrumbLink>
<BreadcrumbLink href="/three">Three</BreadcrumbLink>
<BreadcrumbItem>Four</BreadcrumbItem>
</Breadcrumb>
```

### Custom Separators

```jsx example
<Breadcrumb aria-label="Breadcrumb" separator={<Icon type="chevron-double-right" />}>
<BreadcrumbLink href="#">One</BreadcrumbLink>
<BreadcrumbLink href="#">Two</BreadcrumbLink>
<BreadcrumbLink href="#">Three</BreadcrumbLink>
<BreadcrumbItem>Four</BreadcrumbItem>
</Breadcrumb>
```

## Props

### Breadcrumb

<ComponentProps
children={true}
refType="HTMLElement"
props={[
{
name: 'separator',
type: 'React.ReactNode',
defaultValue: "'/'"
}
]}
/>

### BreadcrumbLink

<ComponentProps
children={true}
refType="HTMLLinkElement"
/>

### BreadcrumbItem

<ComponentProps
children={true}
refType="HTMLSpanElement"
/>
79 changes: 0 additions & 79 deletions docs/patterns/components/Breadcrumb/index.js

This file was deleted.

2 changes: 1 addition & 1 deletion packages/react/src/components/Breadcrumb/Breadcrumb.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import classnames from 'classnames';
import { Cauldron } from '../../types';

type BreadcrumbProps = {
separator?: string;
separator?: React.ReactNode;
} & React.HTMLAttributes<HTMLElement> &
Cauldron.LabelProps;

Expand Down

0 comments on commit 336beca

Please sign in to comment.