Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: avatar list accessibility #14

Merged
merged 2 commits into from
Jun 14, 2019
Merged
Changes from all commits
Commits
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
40 changes: 25 additions & 15 deletions src/components/AvatarList.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ import WithTooltip from './tooltip/WithTooltip';
import { TooltipNote } from './tooltip/TooltipNote';
import { color, typography } from './shared/styles';

const User = styled(Avatar)`
const UserAvatar = styled(Avatar)`
box-shadow: ${color.lightest} 0 0 0 2px;
display: block;
`;

const UserWrapper = styled(WithTooltip)``;
const UserTooltipWrapper = styled(WithTooltip)``;

const UserEllipses = styled.div`
font-size: ${typography.size.s1}px;
Expand All @@ -21,15 +21,22 @@ const UserEllipses = styled.div`
white-space: nowrap;
`;

const Users = styled.div`
const User = styled.li`
display: inline-flex;
`;

const Users = styled.ul`
display: inline-flex;
flex-wrap: nowrap;
flex-direction: row;
align-items: center;
justify-content: flex-end;
vertical-align: top;
margin: 0;
padding: 0;
list-style: none;

${UserWrapper} {
${User} {
position: relative;

&:not(:first-child) {
Expand All @@ -51,19 +58,22 @@ const Users = styled.div`
export function AvatarList({ loading, users, userCount, size, ...props }) {
const count = userCount || users.length;
return (
<Users {...props}>
<Users aria-label="users" {...props}>
{users.slice(0, 3).map(({ id, name, avatarUrl }) => (
<UserWrapper
key={id}
hasChrome={false}
placement="bottom"
mode="hover"
tooltip={<TooltipNote note={name} />}
>
<User size={size} username={name} src={avatarUrl} loading={loading} />
</UserWrapper>
<User key={id}>
<UserTooltipWrapper
hasChrome={false}
placement="bottom"
mode="hover"
tooltip={<TooltipNote note={name} />}
>
<UserAvatar size={size} username={name} src={avatarUrl} loading={loading} />
</UserTooltipWrapper>
</User>
))}
{count > 3 && <UserEllipses> &#43; {count - 3} </UserEllipses>}
{count > 3 && (
<UserEllipses aria-label={`${count - 3} more user(s)`}> &#43; {count - 3} </UserEllipses>
)}
</Users>
);
}
Expand Down