Skip to content

Commit f8a7f98

Browse files
authored
Merge pull request #192 from carbonplan/katamartin/avatar-safari
Update `Avatar` for more reliable Safari rendering
2 parents 00ea6da + 902f31f commit f8a7f98

File tree

2 files changed

+15
-4
lines changed

2 files changed

+15
-4
lines changed

.github/workflows/main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,4 @@ jobs:
2424
steps:
2525
- uses: actions/checkout@v1
2626
- uses: actions/setup-python@v2.3.1
27-
- uses: pre-commit/action@v2.0.3
27+
- uses: pre-commit/action@v3.0.1

src/avatar.js

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,10 @@ const Avatar = ({
3737
maxWidth: maxWidth,
3838
height: 'auto',
3939
borderRadius: '50%',
40+
overflow: 'hidden',
4041
position: 'relative',
4142
display: 'inline-block',
4243
verticalAlign: 'top',
43-
bg: color,
4444
...sx,
4545
}}
4646
{...props}
@@ -49,16 +49,27 @@ const Avatar = ({
4949
alt={altProp}
5050
src={srcProp}
5151
sx={{
52-
opacity: color && color !== 'transparent' ? 0.25 : 1,
5352
filter:
5453
color && color !== 'transparent'
5554
? 'grayscale(100%) contrast(200%) brightness(100%)'
5655
: 'none',
5756
width: '100%',
58-
borderRadius: '50%',
5957
display: 'block',
6058
}}
6159
/>
60+
{color && color !== 'transparent' && (
61+
<Box
62+
sx={{
63+
position: 'absolute',
64+
top: 0,
65+
bg: color,
66+
width: '100%',
67+
height: '100%',
68+
opacity: 0.75,
69+
pointerEvents: 'none',
70+
}}
71+
/>
72+
)}
6273
</Box>
6374
)
6475
}

0 commit comments

Comments
 (0)