Skip to content

Commit

Permalink
use react-is for checking valid element type, update primer/octicons-…
Browse files Browse the repository at this point in the history
…react (#3437)

* use react-is for checking valid element type

* update primer

* update primer

* update octicon

* changeset

* loosen react-is types

* update some types

* test(vrt): update snapshots

---------

Co-authored-by: broccolinisoup <broccolinisoup@users.noreply.github.com>
  • Loading branch information
mattcosta7 and broccolinisoup committed Jun 22, 2023
1 parent cc235fd commit b298c32
Show file tree
Hide file tree
Showing 36 changed files with 1,957 additions and 1,136 deletions.
5 changes: 5 additions & 0 deletions .changeset/lovely-planes-pull.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@primer/react': patch
---

update icon types and primer octicons
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
139 changes: 35 additions & 104 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -100,12 +100,13 @@
"@github/relative-time-element": "^4.1.2",
"@lit-labs/react": "1.1.1",
"@primer/behaviors": "1.3.4",
"@primer/octicons-react": "18.3.0",
"@primer/octicons-react": "^19.3.0",
"@primer/primitives": "7.11.11",
"@react-aria/ssr": "^3.1.0",
"@styled-system/css": "^5.1.5",
"@styled-system/props": "^5.1.5",
"@styled-system/theme-get": "^5.1.2",
"@types/react-is": "^18.2.1",
"@types/styled-components": "^5.1.11",
"@types/styled-system": "^5.1.12",
"@types/styled-system__css": "^5.0.16",
Expand All @@ -119,6 +120,7 @@
"lodash.isempty": "4.4.0",
"lodash.isobject": "3.0.2",
"react-intersection-observer": "9.4.3",
"react-is": "^18.2.0",
"styled-system": "^5.1.5"
},
"devDependencies": {
Expand Down
10 changes: 5 additions & 5 deletions src/Button/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,19 +42,19 @@ export type ButtonProps = {
/**
* The icon for the IconButton
*/
icon?: React.ComponentType | null | undefined
icon?: React.ElementType | null | undefined
/**
* The leading icon comes before button content
*/
leadingIcon?: React.ComponentType | null | undefined
leadingIcon?: React.ElementType | null | undefined
/**
* The trailing icon comes after button content
*/
trailingIcon?: React.ComponentType | null | undefined
trailingIcon?: React.ElementType | null | undefined
/**
* Trailing action appears to the right of the trailing visual and is always locked to the end
*/
trailingAction?: React.ComponentType | null | undefined
trailingAction?: React.ElementType | null | undefined
children: React.ReactNode
/**
* Content alignment for when visuals are present
Expand All @@ -63,7 +63,7 @@ export type ButtonProps = {
} & ButtonBaseProps

export type IconButtonProps = ButtonA11yProps & {
icon: React.ComponentType
icon: React.ElementType
} & Omit<ButtonBaseProps, 'aria-label' | 'aria-labelledby'>

// adopted from React.AnchorHTMLAttributes
Expand Down
7 changes: 4 additions & 3 deletions src/Octicon/Octicon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@ import {ComponentProps} from '../utils/types'

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

function Icon({icon: IconComponent, ...rest}: StyledOcticonProps) {
return <IconComponent {...rest} />
}
const Icon = React.forwardRef((props: StyledOcticonProps, ref: React.Ref<SVGSVGElement>) => {
const {icon: IconComponent, ...rest} = props
return <IconComponent {...rest} ref={ref} />
})

const Octicon = styled(Icon)<SxProp>`
${({color, sx: sxProp}) => sx({sx: {color, ...sxProp}})}
Expand Down
Loading

0 comments on commit b298c32

Please sign in to comment.