Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
0e8b547
Convert AvatarStack to CSS modules behind primer_react_css_modules_te…
jonrohan Sep 23, 2024
6f6fbd1
Updating the tests to run with the feature flag on
jonrohan Sep 24, 2024
4f1c263
Create hot-chicken-tickle.md
jonrohan Sep 24, 2024
53f29df
Fix tests
jonrohan Sep 24, 2024
57feba3
Update hot-chicken-tickle.md
jonrohan Sep 24, 2024
8858370
Quiet warnings
jonrohan Sep 24, 2024
056bdc7
Merge branch 'main' into css_modules_avatar_stack
jonrohan Sep 24, 2024
c34264f
Update CSS disables
jonrohan Sep 24, 2024
260dbba
Merge branch 'main' into css_modules_avatar_stack
jonrohan Oct 8, 2024
70f83e3
Remove feature flag change
jonrohan Oct 8, 2024
cdd6c79
Revert package changes
jonrohan Oct 8, 2024
6d02573
Revert module changes
jonrohan Oct 8, 2024
9e2ce13
Merge branch 'main' into css_modules_avatar_stack
jonrohan Oct 8, 2024
dbf6800
Add span element to AvatarStackWrapper
jonrohan Oct 8, 2024
ba9b70a
Update snapshot
jonrohan Oct 8, 2024
928cb31
Merge branch 'main' into css_modules_avatar_stack
jonrohan Oct 15, 2024
6e92067
Merge branch 'main' into css_modules_avatar_stack
jonrohan Oct 17, 2024
af045d9
Merge branch 'main' into css_modules_avatar_stack
jonrohan Oct 21, 2024
620365d
Merge branch 'main' into css_modules_avatar_stack
jonrohan Oct 28, 2024
b564ae7
Fix weird merge problem
jonrohan Oct 28, 2024
3c77e04
important on the box shadow until avatar removes sx
jonrohan Oct 28, 2024
62725ce
Update snapshot
jonrohan Oct 28, 2024
48b4ca3
Reduce diff
jonrohan Oct 28, 2024
dcb115d
Move AvatarStackBody out of AvatarStack
jonrohan Oct 30, 2024
8c2fcb5
Merge branch 'main' into css_modules_avatar_stack
jonrohan Nov 14, 2024
bc1aa20
Merge branch 'main' into css_modules_avatar_stack
jonrohan Nov 19, 2024
81665ea
Move space
jonrohan Nov 19, 2024
9892c11
Fix to make sure sx prop is being passed in
jonrohan Nov 19, 2024
dcedeec
Not important
jonrohan Nov 19, 2024
ad8621a
Merge branch 'main' into css_modules_avatar_stack
jonrohan Nov 19, 2024
b1ce61b
Add a link wrapper test
jonrohan Nov 19, 2024
5ba219d
Adjust css for when link wrapper occurs
jonrohan Nov 19, 2024
1c7c261
test(vrt): update snapshots
jonrohan Nov 19, 2024
49cbad3
Update snap
jonrohan Nov 19, 2024
f7f982a
Remove box-shadow
jonrohan Nov 19, 2024
276bd5f
Apply suggestions from code review
jonrohan Nov 25, 2024
7235818
Merge branch 'main' into css_modules_avatar_stack
jonrohan Nov 25, 2024
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/hot-chicken-tickle.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@primer/react": minor
---

Update `AvatarStack` component to use CSS modules behind the feature flag primer_react_css_modules_team
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.
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.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions e2e/components/AvatarStack.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ const stories: Array<{title: string; id: string}> = [
title: 'SX Prop',
id: 'components-avatarstack-dev--sx-prop',
},
{
title: 'With Link Wrappers',
id: 'components-avatarstack-dev--with-link-wrappers',
},
]

test.describe('AvatarStack', () => {
Expand Down
18 changes: 18 additions & 0 deletions packages/react/src/AvatarStack/AvatarStack.dev.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import React from 'react'
import type {Meta} from '@storybook/react'
import AvatarStack from './AvatarStack'
import Avatar from '../Avatar'
import Link from '../Link'

export default {
title: 'Components/AvatarStack/Dev',
Expand All @@ -21,3 +22,20 @@ export const SxProp = () => (
<Avatar alt="GitHub Desktop logo" src="https://avatars.githubusercontent.com/desktop" />
</AvatarStack>
)

export const WithLinkWrappers = () => (
<AvatarStack>
<Link aria-label="Primer is assigned" href="#" className="pc-AvatarItem" data-hovercard-url="/primer">
<Avatar alt="Primer logo" src="https://avatars.githubusercontent.com/primer" />
</Link>
<Link aria-label="GitHub is assigned" href="#" className="pc-AvatarItem" data-hovercard-url="/primer">
<Avatar alt="GitHub logo" src="https://avatars.githubusercontent.com/github" />
</Link>
<Link aria-label="Atom is assigned" href="#" className="pc-AvatarItem" data-hovercard-url="/primer">
<Avatar alt="Atom logo" src="https://avatars.githubusercontent.com/atom" />
</Link>
<Link aria-label="GitHub Desktop is assigned" href="#" className="pc-AvatarItem" data-hovercard-url="/primer">
<Avatar alt="GitHub Desktop logo" src="https://avatars.githubusercontent.com/desktop" />
</Link>
</AvatarStack>
)
190 changes: 190 additions & 0 deletions packages/react/src/AvatarStack/AvatarStack.module.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,190 @@
/* stylelint-disable max-nesting-depth */
/* stylelint-disable selector-max-specificity */
.AvatarStack {
--avatar-border-width: 1px;
--avatar-two-margin: calc(var(--avatar-stack-size) * -0.55);
--avatar-three-margin: calc(var(--avatar-stack-size) * -0.85);

position: relative;
display: flex;
min-width: var(--avatar-stack-size);
height: var(--avatar-stack-size);

&:where([data-responsive]) {
@media screen and (--viewportRange-narrow) {
--avatar-stack-size: var(--stackSize-narrow);
}

@media screen and (--viewportRange-regular) {
--avatar-stack-size: var(--stackSize-regular);
}

@media screen and (--viewportRange-wide) {
--avatar-stack-size: var(--stackSize-wide);
}
}

&:where([data-avatar-count='1']) {
.AvatarItem {
/* stylelint-disable-next-line primer/box-shadow */
box-shadow: 0 0 0 var(--avatar-border-width) var(--avatar-borderColor);
}
}

&:where([data-avatar-count='2']) {
/* this calc explained: */

/* 1. avatar size + the non-overlapping part of the second avatar */

/* 2. + the border widths of the first two avatars */
min-width: calc(
var(--avatar-stack-size) + calc(var(--avatar-stack-size) + var(--avatar-two-margin)) + var(--avatar-border-width)
);
}

&:where([data-avatar-count='3']) {
/* this calc explained: */

/* 1. avatar size + the non-overlapping part of the second avatar */

/* 2. + the non-overlapping part of the third avatar */
min-width: calc(
var(--avatar-stack-size) +
calc(
calc(var(--avatar-stack-size) + var(--avatar-two-margin)) +
calc(var(--avatar-stack-size) + var(--avatar-three-margin))
)
);
}

&:where([data-avatar-count='3+']) {
/* this calc explained: */

/* 1. avatar size + the non-overlapping part of the second avatar */

/* 2. + the non-overlapping part of the third and fourth avatar */
min-width: calc(
var(--avatar-stack-size) +
calc(
calc(var(--avatar-stack-size) + var(--avatar-two-margin)) +
calc(var(--avatar-stack-size) + var(--avatar-three-margin)) * 2
)
);
}

&:where([data-align-right]) {
justify-content: flex-end;

.AvatarItem {
margin-left: 0 !important;

&:first-child {
margin-right: 0;
}

&:nth-child(n + 2) {
/* stylelint-disable-next-line primer/spacing */
margin-right: var(--avatar-two-margin);
}

&:nth-child(n + 3) {
/* stylelint-disable-next-line primer/spacing */
margin-right: var(--avatar-three-margin);
}
}

.AvatarStackBody {
flex-direction: row-reverse;

&:not([data-disable-expand]):hover,
&:not([data-disable-expand]):focus-within {
.AvatarItem {
margin-right: var(--base-size-4) !important;
margin-left: 0 !important;

&:first-child {
margin-right: 0 !important;
}
}
}
}
}
}

.AvatarStackBody {
position: absolute;
display: flex;

&:where([data-disable-expand]) {
position: relative;
}
}

.AvatarItem {
--avatarSize-regular: var(--avatar-stack-size);

position: relative;
display: flex;
width: var(--avatar-stack-size);
height: var(--avatar-stack-size);
overflow: hidden;
flex-shrink: 0;

&:is(img) {
/* stylelint-disable-next-line primer/box-shadow */
box-shadow: 0 0 0 var(--avatar-border-width) var(--bgColor-default);
}

&:first-child {
z-index: 10;
margin-left: 0;
}

&:nth-child(n + 2) {
z-index: 9;
/* stylelint-disable-next-line primer/spacing */
margin-left: var(--avatar-two-margin);
}

&:nth-child(n + 3) {
z-index: 8;
/* stylelint-disable-next-line primer/spacing */
margin-left: var(--avatar-three-margin);
opacity: 0.55;
}

&:nth-child(n + 4) {
z-index: 7;
opacity: 0.4;
}

&:nth-child(n + 5) {
z-index: 6;
opacity: 0.25;
}

&:nth-child(n + 6) {
visibility: hidden;
opacity: 0;
}
}

.AvatarStackBody:not([data-disable-expand]):hover,
.AvatarStackBody:not([data-disable-expand]):focus-within {
width: auto;

.AvatarItem {
margin-left: var(--base-size-4);
visibility: visible;
opacity: 1;
transition:
margin 0.2s ease-in-out,
opacity 0.2s ease-in-out,
visibility 0.2s ease-in-out,
box-shadow 0.1s ease-in-out;

&:first-child {
margin-left: 0;
}
}
}
Loading
Loading