Skip to content

Commit 0b471f1

Browse files
committed
Revert Avatar and Flash
1 parent 5b21ebe commit 0b471f1

File tree

2 files changed

+18
-16
lines changed

2 files changed

+18
-16
lines changed

src/Avatar.tsx

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import React from 'react'
21
import styled from 'styled-components'
32
import {get} from './constants'
43
import sx, {SxProp} from './sx'
4+
import {ComponentProps} from './utils/types'
55

66
type StyledAvatarProps = {
77
/** Sets the width and height of the avatar. */
@@ -22,7 +22,7 @@ function getBorderRadius({size, square}: StyledAvatarProps) {
2222
}
2323
}
2424

25-
const StyledAvatar = styled.img.attrs<StyledAvatarProps>(props => ({
25+
const Avatar = styled.img.attrs<StyledAvatarProps>(props => ({
2626
height: props.size,
2727
width: props.size,
2828
}))<StyledAvatarProps>`
@@ -35,11 +35,13 @@ const StyledAvatar = styled.img.attrs<StyledAvatarProps>(props => ({
3535
${sx}
3636
`
3737

38-
export type AvatarProps = StyledAvatarProps & React.ComponentPropsWithoutRef<'img'>
39-
const Avatar = React.forwardRef<HTMLImageElement, AvatarProps>(({size = 20, alt = '', ...rest}, ref) => (
40-
<StyledAvatar ref={ref} alt={alt} size={size} {...rest} />
41-
))
42-
43-
Avatar.displayName = 'Avatar'
38+
// TODO: Remove defaultProps to be compatible with the next major version of React
39+
// Reference: https://github.com/primer/react/issues/2758
40+
Avatar.defaultProps = {
41+
size: 20,
42+
alt: '',
43+
square: false,
44+
}
4445

46+
export type AvatarProps = ComponentProps<typeof Avatar>
4547
export default Avatar

src/Flash.tsx

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import React from 'react'
21
import styled from 'styled-components'
32
import {variant} from 'styled-system'
43
import {get} from './constants'
54
import sx, {SxProp} from './sx'
5+
import {ComponentProps} from './utils/types'
66

77
const variants = variant({
88
variants: {
@@ -46,7 +46,7 @@ type StyledFlashProps = {
4646
full?: boolean
4747
} & SxProp
4848

49-
const StyledFlash = styled.div<StyledFlashProps>`
49+
const Flash = styled.div<StyledFlashProps>`
5050
position: relative;
5151
color: ${get('colors.fg.default')};
5252
padding: ${get('space.3')};
@@ -67,11 +67,11 @@ const StyledFlash = styled.div<StyledFlashProps>`
6767
${sx};
6868
`
6969

70-
export type FlashProps = StyledFlashProps & React.ComponentPropsWithoutRef<'div'>
71-
const Flash = React.forwardRef<HTMLDivElement, FlashProps>(({variant = 'default', ...rest}, ref) => (
72-
<StyledFlash ref={ref} variant={variant} {...rest} />
73-
))
74-
75-
Flash.displayName = 'Flash'
70+
// TODO: Remove defaultProps to be compatible with the next major version of React
71+
// Reference: https://github.com/primer/react/issues/2758
72+
Flash.defaultProps = {
73+
variant: 'default',
74+
}
7675

76+
export type FlashProps = ComponentProps<typeof Flash>
7777
export default Flash

0 commit comments

Comments
 (0)