Skip to content
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/twenty-spoons-give.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@primer/react": minor
---

chore(AvatarPair): Convert AvatarPair to CSS modules
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.
20 changes: 20 additions & 0 deletions packages/react/src/AvatarPair/AvatarPair.module.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
.AvatarPair {
position: relative;
display: inline-flex;

[data-component='Avatar']:last-child,
[data-component='SkeletonAvatar']:last-child {
position: absolute;
right: -15%;
bottom: -9%;
box-shadow: var(--avatar-shadow);
}

[data-component='SkeletonAvatar']:last-child {
box-shadow: inset var(--avatar-shadow);
}
}

.AvatarChild {
background-color: var(--bgColor-default);
}
37 changes: 11 additions & 26 deletions packages/react/src/AvatarPair/AvatarPair.tsx
Original file line number Diff line number Diff line change
@@ -1,31 +1,13 @@
import React from 'react'
import styled from 'styled-components'
import React, {type HTMLProps} from 'react'
import type {AvatarProps} from '../Avatar'
import Avatar from '../Avatar'
import {get} from '../constants'
import Box, {type BoxProps} from '../Box'
import {SkeletonAvatar} from '../experimental/Skeleton/SkeletonAvatar'
import classes from './AvatarPair.module.css'
import {clsx} from 'clsx'

const StyledAvatarPair = styled(Box)`
position: relative;
display: inline-flex;
export type AvatarPairProps = HTMLProps<HTMLDivElement>

[data-component='Avatar']:last-child,
[data-component='SkeletonAvatar']:last-child {
position: absolute;
right: -15%;
bottom: -9%;
box-shadow: ${get('shadows.avatar.childShadow')};
}

[data-component='SkeletonAvatar']:last-child {
box-shadow: inset ${get('shadows.avatar.childShadow')};
}
`

export type AvatarPairProps = BoxProps

const AvatarPair = ({children, ...rest}: AvatarPairProps) => {
const AvatarPair = ({children, className, ...rest}: AvatarPairProps) => {
const avatars = React.Children.map(children, (child, i) => {
if (!React.isValidElement(child)) {
return child
Expand All @@ -39,13 +21,16 @@ const AvatarPair = ({children, ...rest}: AvatarPairProps) => {
return <SkeletonAvatar {...child.props} size={20} />
}

return <Avatar bg="canvas.default" {...child.props} size={20} />
return <Avatar className={clsx(child.props.className, classes.AvatarChild)} {...child.props} size={20} />
})

return <StyledAvatarPair {...rest}>{avatars}</StyledAvatarPair>
return (
<div className={clsx(className, classes.AvatarPair)} {...rest}>
{avatars}
</div>
)
}

// styled() changes this
AvatarPair.displayName = 'AvatarPair'

export default AvatarPair
Loading