Skip to content

Commit

Permalink
Update component docs (AnchoredOverlay, Avatar, AvatarStack, Box, Bra…
Browse files Browse the repository at this point in the history
…nchName, Breadcrumbs) (#1702)

* Update AnchoredOverlay docs

* Allow preformatted types in prop table

* Add Link and InlineCode to global mdx scope

* Update Avatar docs

* Update AvatarStack docs

* Update Box props

* Update branchname docs

* Update breadcrumbs docs

* Update branchname snapshot

* Create polite-trees-wink.md

* Add AvatarPair docs
  • Loading branch information
colebemis authored and pksjce committed Dec 19, 2021
1 parent 34f190c commit 2902124
Show file tree
Hide file tree
Showing 14 changed files with 316 additions and 88 deletions.
5 changes: 5 additions & 0 deletions .changeset/polite-trees-wink.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@primer/components": patch
---

Update `BranchName` styles to match github.com
122 changes: 121 additions & 1 deletion docs/content/AnchoredOverlay.mdx
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
---
title: AnchoredOverlay
status: Alpha
source: https://github.com/primer/react/blob/main/src/AnchoredOverlay/AnchoredOverlay.tsx
storybook: https://primer.style/react/storybook?path=/story/generic-behaviors-anchoredoverlay--default-portal
---

An `AnchoredOverlay` provides an anchor that will open a floating overlay positioned relative to the anchor.
The overlay can be opened and navigated using keyboard or mouse.

See also [Overlay positioning](/Overlay#positioning).

## Example
## Examples

```jsx live
<State default={false}>
Expand All @@ -35,3 +37,121 @@ See also [Overlay positioning](/Overlay#positioning).
}}
</State>
```

## Props

<PropsTable>
<PropsTableRow
name="open"
type="boolean"
defaultValue="false"
description="Determines whether the overlay portion of the component should be shown or not."
/>
<PropsTableRow
name="onOpen"
type="(gesture: 'anchor-click' | 'anchor-key-press') => unknown"
description='A callback that is called whenever the overlay is currently closed and an "open gesture" is detected.'
/>
<PropsTableRow
name="onClose"
type="(gesture: 'anchor-click' | 'click-outside' | 'escape') => unknown"
description='A callback that is called whenever the overlay is currently open and a "close gesture" is detected.'
/>
<PropsTableRow
name="renderAnchor"
type="<T extends React.HTMLAttributes<HTMLElement>>(props: T) => JSX.Element"
description={
<>
A custom function component used to render the anchor element. When renderAnchor is null, an anchorRef is
required.
</>
}
/>
<PropsTableRow
name="anchorRef"
type="React.RefObject<HTMLElement>"
description={
<>
An override to the internal <InlineCode>renderAnchor</InlineCode> ref that will be used to position the overlay.
When <InlineCode>renderAnchor</InlineCode> is
<InlineCode>null</InlineCode>, this can be used to make an anchor that is detached from <InlineCode>
AnchoredOverlay
</InlineCode>.
</>
}
/>
<PropsTableRow
name="side"
type={`| 'inside-top'
| 'inside-bottom'
| 'inside-left'
| 'inside-right'
| 'inside-center'
| 'outside-top'
| 'outside-bottom'
| 'outside-left'
| 'outside-right'`}
defaultValue="'outside-bottom'"
/>
<PropsTableRow name="align" type="'start' | 'center' | 'end'" defaultValue="'start'" />
<PropsTableRow
name="overlayProps"
type={
<>
Partial&lt;<Link href="/Overlay#props">OverlayProps</Link>&gt;
</>
}
description={
<>
Props to be spread on the internal <InlineCode>Overlay</InlineCode> component.
</>
}
/>
<PropsTableRow
name="focusTrapSettings"
type={
<>
Partial&lt;<Link href="/focusTrap#focustraphooksettings-interface">FocusTrapHookSettings</Link>&gt;
</>
}
description={
<>
Settings to apply to the focus trap on the internal <InlineCode>Overlay</InlineCode> component.
</>
}
/>
<PropsTableRow
name="focusZoneSettings"
type={
<>
Partial&lt;<Link href="/focusZone#focuszonehooksettings-interface">FocusZoneHookSettings</Link>&gt;
</>
}
description={
<>
Settings to apply to the focus zone on the internal <InlineCode>Overlay</InlineCode> component.
</>
}
/>
</PropsTable>

## Status

<ComponentChecklist
items={{
propsDocumented: true,
noUnnecessaryDeps: true,
adaptsToThemes: true,
adaptsToScreenSizes: true,
fullTestCoverage: false,
usedInProduction: true,
usageExamplesDocumented: false,
hasStorybookStories: true,
designReviewed: false,
a11yReviewed: false,
stableApi: false,
addressedApiFeedback: false,
hasDesignGuidelines: false,
hasFigmaComponent: false
}}
/>
43 changes: 29 additions & 14 deletions docs/content/Avatar.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -5,34 +5,49 @@ componentId: avatar
source: https://github.com/primer/react/blob/main/src/Avatar.tsx
---

import {Avatar} from '@primer/components'
import {Avatar, Box} from '@primer/components'

```jsx live
<Avatar src="https://avatars.githubusercontent.com/primer" />
```js
import {Avatar} from '@primer/components'
```

## Props
## Examples

<Props of={Avatar} />
### Default

## Examples
```jsx live
<Avatar src="https://avatars.githubusercontent.com/primer" />
```

### Square

```jsx live
<Avatar square src="https://avatars.githubusercontent.com/primer" />
```

### AvatarPair
## Props

```jsx live
<AvatarPair>
<Avatar src="https://avatars.githubusercontent.com/github" />
<Avatar src="https://avatars.githubusercontent.com/primer" />
</AvatarPair>
```
### Avatar

<PropsTable>
<PropsTableRow name="src" type="string" required description="URL of the avatar image." />{' '}
<PropsTableRow
name="alt"
type="string"
defaultValue="''"
description="Provide alt text when the avatar is used without a name next to it."
/>
<PropsTableRow name="size" type="number" defaultValue="20" description="The size of the avatar in pixels." />
<PropsTableRow
name="square"
type="boolean"
defaultValue="false"
description="If true, the avatar will be square instead of circular."
/>
<PropsTableSxRow />
</PropsTable>

## Component status
## Status

<ComponentChecklist
items={{
Expand Down
47 changes: 47 additions & 0 deletions docs/content/AvatarPair.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
---
title: AvatarPair
status: Alpha
source: https://github.com/primer/react/blob/main/src/AvatarPair.tsx
---

```js
import {AvatarPair} from '@primer/components'
```

## Examples

```jsx live
<AvatarPair>
<Avatar src="https://avatars.githubusercontent.com/github" />
<Avatar src="https://avatars.githubusercontent.com/primer" />
</AvatarPair>
```

## Props

### AvatarPair

<PropsTable>
<PropsTableRow name="children" type="Avatar[]" />
<PropsTableSxRow />
</PropsTable>

## Status

<ComponentChecklist
items={{
propsDocumented: true,
noUnnecessaryDeps: true,
adaptsToThemes: true,
adaptsToScreenSizes: true,
fullTestCoverage: false,
usedInProduction: false,
usageExamplesDocumented: true,
designReviewed: false,
a11yReviewed: false,
stableApi: false,
addressedApiFeedback: false,
hasDesignGuidelines: false,
hasFigmaComponent: false
}}
/>
20 changes: 14 additions & 6 deletions docs/content/AvatarStack.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,13 @@ source: https://github.com/primer/react/blob/main/src/AvatarStack.tsx

import {AvatarStack} from '@primer/components'

### Default example
```js
import {AvatarStack} from '@primer/components'
```

## Examples

### Default

```jsx live
<AvatarStack>
Expand All @@ -31,12 +37,14 @@ import {AvatarStack} from '@primer/components'

## Props

| Name | Type | Default | Description |
| :--------- | :---------------- | :-----: | :----------------------------------- |
| alignRight | Boolean | | Creates right aligned AvatarStack |
| sx | SystemStyleObject | {} | Style to be applied to the component |
### AvatarStack

<PropsTable>
<PropsTableRow name="alignRight" type="boolean" defaultValue="false" description="Align the avatars to the right" />
<PropsTableSxRow />
</PropsTable>

## Component status
## Status

<ComponentChecklist
items={{
Expand Down
24 changes: 13 additions & 11 deletions docs/content/Box.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,10 @@ import {Props} from '../src/props'
import {ComponentChecklist} from '../src/component-checklist'
import {Box} from '@primer/components'

```jsx live
<Box color="fg.muted" bg="canvas.subtle" p={3}>
Hello
</Box>
```js
import {Box} from '@primer/components'
```

## Props

<Props of={Box} />

Box also accepts all [styled system props](https://styled-system.com/table/).

## Examples

### Border on all sides
Expand Down Expand Up @@ -75,7 +67,17 @@ Use Box to create [grid](https://developer.mozilla.org/en-US/docs/Learn/CSS/CSS_
</Box>
```

## Component status
## Props

### Box

<PropsTable>
<PropsTableBasePropRows elementType="div" isPolymorphic refType="HTMLDivElement" />
</PropsTable>

Box also accepts all [styled system props](https://styled-system.com/table/).

## Status

<ComponentChecklist
items={{
Expand Down
39 changes: 0 additions & 39 deletions docs/content/BranchName.md

This file was deleted.

Loading

0 comments on commit 2902124

Please sign in to comment.