Skip to content

Commit 9bd5c89

Browse files
authored
chore(AvatarPair): Convert AvatarPair to CSS modules (#5002)
* Convert to CSS module * Create twenty-spoons-give.md * test(vrt): update snapshots * test(vrt): update snapshots --------- Co-authored-by: jonrohan <jonrohan@users.noreply.github.com>
1 parent 597d285 commit 9bd5c89

File tree

7 files changed

+36
-26
lines changed

7 files changed

+36
-26
lines changed

.changeset/twenty-spoons-give.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@primer/react": minor
3+
---
4+
5+
chore(AvatarPair): Convert AvatarPair to CSS modules
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
.AvatarPair {
2+
position: relative;
3+
display: inline-flex;
4+
5+
[data-component='Avatar']:last-child,
6+
[data-component='SkeletonAvatar']:last-child {
7+
position: absolute;
8+
right: -15%;
9+
bottom: -9%;
10+
box-shadow: var(--avatar-shadow);
11+
}
12+
13+
[data-component='SkeletonAvatar']:last-child {
14+
box-shadow: inset var(--avatar-shadow);
15+
}
16+
}
17+
18+
.AvatarChild {
19+
background-color: var(--bgColor-default);
20+
}
Lines changed: 11 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,13 @@
1-
import React from 'react'
2-
import styled from 'styled-components'
1+
import React, {type HTMLProps} from 'react'
32
import type {AvatarProps} from '../Avatar'
43
import Avatar from '../Avatar'
5-
import {get} from '../constants'
6-
import Box, {type BoxProps} from '../Box'
74
import {SkeletonAvatar} from '../experimental/Skeleton/SkeletonAvatar'
5+
import classes from './AvatarPair.module.css'
6+
import {clsx} from 'clsx'
87

9-
const StyledAvatarPair = styled(Box)`
10-
position: relative;
11-
display: inline-flex;
8+
export type AvatarPairProps = HTMLProps<HTMLDivElement>
129

13-
[data-component='Avatar']:last-child,
14-
[data-component='SkeletonAvatar']:last-child {
15-
position: absolute;
16-
right: -15%;
17-
bottom: -9%;
18-
box-shadow: ${get('shadows.avatar.childShadow')};
19-
}
20-
21-
[data-component='SkeletonAvatar']:last-child {
22-
box-shadow: inset ${get('shadows.avatar.childShadow')};
23-
}
24-
`
25-
26-
export type AvatarPairProps = BoxProps
27-
28-
const AvatarPair = ({children, ...rest}: AvatarPairProps) => {
10+
const AvatarPair = ({children, className, ...rest}: AvatarPairProps) => {
2911
const avatars = React.Children.map(children, (child, i) => {
3012
if (!React.isValidElement(child)) {
3113
return child
@@ -39,13 +21,16 @@ const AvatarPair = ({children, ...rest}: AvatarPairProps) => {
3921
return <SkeletonAvatar {...child.props} size={20} />
4022
}
4123

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

45-
return <StyledAvatarPair {...rest}>{avatars}</StyledAvatarPair>
27+
return (
28+
<div className={clsx(className, classes.AvatarPair)} {...rest}>
29+
{avatars}
30+
</div>
31+
)
4632
}
4733

48-
// styled() changes this
4934
AvatarPair.displayName = 'AvatarPair'
5035

5136
export default AvatarPair

0 commit comments

Comments
 (0)