Skip to content

Conversation

@oddvernes
Copy link
Collaborator

@oddvernes oddvernes commented Dec 16, 2025

resolves #2306

Also adds asChild support to Avatar

@changeset-bot
Copy link

changeset-bot bot commented Dec 16, 2025

🦋 Changeset detected

Latest commit: 2c8b905

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 5 packages
Name Type
@digdir/designsystemet-react Minor
@digdir/designsystemet-css Minor
@digdir/designsystemet Minor
@digdir/designsystemet-theme Minor
@digdir/designsystemet-types Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions
Copy link
Contributor

github-actions bot commented Dec 16, 2025

Preview deployments for this pull request:

storybook - 9. Jan 2026 - 09:13

@oddvernes oddvernes marked this pull request as ready for review January 6, 2026 12:10
@oddvernes
Copy link
Collaborator Author

Needs feedback/approval before creating documentation on www


.ds-avatar-stack {
--dsc-avatar-stack-size: var(--ds-size-12);
--dsc-avatar-stack-gap: 2;
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggestion: can we specify unit here?

Suggested change
--dsc-avatar-stack-gap: 2;
--dsc-avatar-stack-gap: 2px;

as this gives more flexibility? ☺️

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Do you feel like the react prop should then specify unit as well or keep that as number converted to px?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I made it so react prop has to specify "2px" as well for now. Lets see

.ds-avatar-stack {
--dsc-avatar-stack-size: var(--ds-size-12);
--dsc-avatar-stack-gap: 2;
--dsc-avatar-stack-overlap: 50;
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggestion: can we specify unit here too?

Suggested change
--dsc-avatar-stack-overlap: 50;
--dsc-avatar-stack-overlap: 50px;

It seems like this would not be problematic, as the rest of the equations are +/- ☺️

Copy link
Collaborator Author

@oddvernes oddvernes Jan 8, 2026

Choose a reason for hiding this comment

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

This needs to be a unitless number. it is used in a calculation to create the overlap as a percentage of the avatar size automatically

--_gap: calc(var(--dsc-avatar-stack-gap) * 1px);
--_overlap: calc(((var(--dsc-avatar-stack-size) / 100) * var(--dsc-avatar-stack-overlap)) * -1);

--captured-length: var(--_overlap);
Copy link
Contributor

Choose a reason for hiding this comment

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

could we skip this, a just use --_overlap directly in the rest of the file? ☺️

Copy link
Collaborator Author

@oddvernes oddvernes Jan 8, 2026

Choose a reason for hiding this comment

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

The registered property is needed to be able to animate the optional expand action. We could rename that to --_overlap or something else instead, but since they have to be declared in global scope, I am in favour of generically named reusable registered custom properties

&:not(:first-child) {
margin-left: var(--captured-length);
}
&:nth-last-child(1 of .ds-avatar) {
Copy link
Contributor

@eirikbacker eirikbacker Jan 7, 2026

Choose a reason for hiding this comment

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

Could this instead be .ds-avatar:not(:has(+ .ds-avatar)) for even better browser support? ☺️

Copy link
Collaborator Author

@oddvernes oddvernes Jan 8, 2026

Choose a reason for hiding this comment

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

looks like :has came out a year earlier than :nth-last-child(1 of ...) for chrome (2022 vs 2023), while :has came after nth-last-child in the other browsers. I can use both i suppose
https://caniuse.com/css-nth-child-of
https://caniuse.com/css-has

Copy link
Collaborator Author

@oddvernes oddvernes Jan 8, 2026

Choose a reason for hiding this comment

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

this :has selector will remove mask on all avatars if there are tooltips in between, so i am adding it inside @supports not selector(:nth-last-child(1 of .ds-avatar)). Should be very obscure to encounter a chromium build older than 2023 anyway surely..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add group of avatars to React

4 participants