Skip to content

Commit

Permalink
Merge pull request #1031 from primer/cb/ts-avatar-pair
Browse files Browse the repository at this point in the history
Migrate AvatarPair to TypeScript
  • Loading branch information
colebemis authored Feb 9, 2021
2 parents d757a81 + ef25d01 commit 0f0aa9c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/sharp-lobsters-march.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@primer/components": patch
---

Migrate `AvatarPair` to TypeScript
8 changes: 6 additions & 2 deletions src/AvatarPair.js → src/AvatarPair.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react'
import PropTypes from 'prop-types'
import styled from 'styled-components'
import {Relative} from './Position'
import {Relative, RelativeProps} from './Position'
import Avatar from './Avatar'
import theme from './theme'

Expand All @@ -11,8 +11,12 @@ const ChildAvatar = styled(Avatar)`
bottom: -9%;
box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.8);
`
const AvatarPair = ({children, ...rest}) => {

export type AvatarPairProps = RelativeProps

const AvatarPair = ({children, ...rest}: AvatarPairProps) => {
const avatars = React.Children.map(children, (child, i) => {
if (!React.isValidElement(child)) return child
return i === 0 ? React.cloneElement(child, {size: 40}) : <ChildAvatar bg="white" {...child.props} size={20} />
})
return (
Expand Down

1 comment on commit 0f0aa9c

@vercel
Copy link

@vercel vercel bot commented on 0f0aa9c Feb 9, 2021

Choose a reason for hiding this comment

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

Please sign in to comment.