Skip to content

Commit

Permalink
Use CSS class over :has() for Firefox compatibility (#64)
Browse files Browse the repository at this point in the history
  • Loading branch information
germain-gg authored Aug 24, 2023
1 parent b6004b0 commit 1361a4a
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/components/Avatar/Avatar.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ button.avatar:disabled {
overflow: hidden;
}

.avatar:not(:has(.image)) {
.avatar-imageless {
/* In the future we'd prefer to pass the HEX code as the data attr
and use `attr(data-color)` to avoid the style declaration from below
but this is currently not supported in all browsers */
Expand Down
4 changes: 3 additions & 1 deletion src/components/Avatar/Avatar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,9 @@ export const Avatar = forwardRef<
...props,
"data-type": type,
"data-color": useIdColorHash(id),
className: classnames(styles.avatar, className),
className: classnames(styles.avatar, className, {
[styles["avatar-imageless"]]: !src,
}),
style: {
...style,
"--cpd-avatar-size": size,
Expand Down
2 changes: 1 addition & 1 deletion src/components/Avatar/__snapshots__/Avatar.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ exports[`Avatar > renders the image-less avatar 1`] = `
<DocumentFragment>
<span
aria-label=""
class="_avatar_de1988"
class="_avatar_de1988 _avatar-imageless_de1988"
data-color="8"
data-type="round"
role="img"
Expand Down

0 comments on commit 1361a4a

Please sign in to comment.