Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update component docs (AnchoredOverlay, Avatar, AvatarStack, Box, BranchName, Breadcrumbs) #1702

Merged
merged 12 commits into from
Dec 7, 2021
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>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This wording is tricky — unlike most ref props, there's an expectation that the AnchoredOverlay isn't responsible for setting the value of the ref, right? only that it will use the ref's current value for positioning logic?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, this one is tricky. I mostly copied this description from the code comments but I agree that it's a bit confusing.

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;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

</>
}
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="''"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❗ I'm surprised this is '' and not undefined.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is intentional. alt='' is treated differently than an undefined alt. From https://davidwalsh.name/accessibility-tip-empty-alt-attributes:

Images with only visual value should have an empty alt attribute set on them. Omitting the alt attribute makes most screen readers read out the entire image URL and providing an alt attribute when the image is for visual purposes only is just as useless.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TIL, thanks!

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