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

Fix: restore color prop functionality for StyledOcticon #1781

Merged
merged 2 commits into from
Jan 10, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/gold-fireants-switch.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@primer/react': patch
---

restores color prop functionality to StyledOcticon
28 changes: 0 additions & 28 deletions docs/content/StyledOcticon.md

This file was deleted.

78 changes: 78 additions & 0 deletions docs/content/StyledOcticon.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
---
description: Use StyledOcticon to render an Octicon as a component.
title: StyledOcticon
status: Alpha
source: https://github.com/primer/react/blob/main/src/StyledOcticon.tsx
componentId: styled_octicon
---

## Example

```jsx live
<>
<StyledOcticon icon={CheckIcon} size={32} color="success.fg" sx={{mr: 2}} />
<StyledOcticon icon={XIcon} size={32} color="danger.fg" />
</>
```

## Props

<PropsTable>
<PropsTableRow
name="ariaLabel"
type="string"
description="Specifies the aria-label attribute, which is read verbatim by screen readers "
/>
<PropsTableRow
name="icon"
type="Component"
description={
<>
Checks the input by default in uncontrolled modeName of the <Link href="https://primer.style/octicons/">Octicon component</Link> used in the
</>
}
/>
<PropsTableRow
name="color"
type="string"
description={
<>
Sets an override color for the Octicon. Compatible with colors from the <Link href="https://primer.style/primitives/colors">Primer color system</Link>."
</>
}
/>
<PropsTableRow
name="size"
defaultValue="16"
type="number"
description="Sets the uniform `width` and `height` of the SVG element"
/>
<PropsTableRow
name="verticalAlign"
defaultValue="text-bottom"
type="string"
description="Sets the `vertical-align` CSS property"
/>
<PropsTableSxRow />

</PropsTable>

## Status

<ComponentChecklist
items={{
propsDocumented: true,
noUnnecessaryDeps: true,
adaptsToThemes: true,
adaptsToScreenSizes: false,
fullTestCoverage: false,
usedInProduction: true,
usageExamplesDocumented: true,
designReviewed: false,
a11yReviewed: false,
stableApi: false,
addressedApiFeedback: false,
hasDesignGuidelines: false,
hasFigmaComponent: false
}}
/>
4 changes: 2 additions & 2 deletions src/StyledOcticon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ import styled from 'styled-components'
import sx, {SxProp} from './sx'
import {ComponentProps} from './utils/types'

type OcticonProps = {icon: React.ElementType} & IconProps
type OcticonProps = {icon: React.ElementType; color?: string} & IconProps

function Octicon({icon: IconComponent, ...rest}: OcticonProps) {
return <IconComponent {...rest} />
}

const StyledOcticon = styled(Octicon)<SxProp>`
${sx}
${({color, sx: sxProp}) => sx({sx: {color, ...sxProp}})}
`

StyledOcticon.defaultProps = {
Expand Down