-
Notifications
You must be signed in to change notification settings - Fork 99
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(AvatarStack): correctly display more than 9 remaining avatars (#1882
- Loading branch information
Showing
15 changed files
with
141 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import React from 'react'; | ||
|
||
import {DEFAULT_AVATAR_SIZE} from '../Avatar'; | ||
import {block} from '../utils/cn'; | ||
|
||
import i18n from './i18n'; | ||
import type {AvatarStackMoreProps} from './types'; | ||
|
||
const b = block('avatar-stack'); | ||
|
||
/** | ||
* Badge for displaying count of remaining avatars | ||
*/ | ||
export const AvatarStackMore = React.forwardRef<HTMLDivElement, AvatarStackMoreProps>( | ||
( | ||
{ | ||
className, | ||
count, | ||
'aria-label': ariaLabel, | ||
borderColor = 'var(--g-color-line-generic-solid)', | ||
size = DEFAULT_AVATAR_SIZE, | ||
}, | ||
ref, | ||
) => ( | ||
<div | ||
ref={ref} | ||
className={b('more', {size, 'has-border': Boolean(borderColor)}, className)} | ||
aria-label={ariaLabel || i18n('more', {count})} | ||
style={{borderColor}} | ||
> | ||
+{count} | ||
</div> | ||
), | ||
); | ||
|
||
AvatarStackMore.displayName = 'AvatarStack.More'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,46 @@ | ||
import React from 'react'; | ||
|
||
import type {AvatarSize} from '../Avatar'; | ||
import {Avatar, DEFAULT_AVATAR_SIZE} from '../Avatar'; | ||
import {DEFAULT_AVATAR_SIZE} from '../Avatar'; | ||
import {block} from '../utils/cn'; | ||
|
||
import i18n from './i18n'; | ||
import {AvatarStackMore} from './AvatarStackMore'; | ||
import type {AvatarStackMoreButtonProps} from './types'; | ||
|
||
const b = block('avatar-stack'); | ||
|
||
export type AvatarStackMoreButtonProps = Pick< | ||
React.HTMLProps<HTMLButtonElement>, | ||
'className' | 'onClick' | 'aria-label' | ||
> & { | ||
size?: AvatarSize; | ||
count: number; | ||
}; | ||
|
||
export const AvatarStackMoreButton = React.forwardRef< | ||
HTMLButtonElement, | ||
AvatarStackMoreButtonProps | ||
>(({className, size = DEFAULT_AVATAR_SIZE, onClick, count, 'aria-label': ariaLabel}, ref) => { | ||
return ( | ||
<button | ||
ref={ref} | ||
type="button" | ||
className={b('more-button', {size}, className)} | ||
onClick={onClick} | ||
> | ||
<Avatar | ||
text={`+${count}`} | ||
size={size} | ||
aria-label={ariaLabel || i18n('more', {count})} | ||
/> | ||
</button> | ||
); | ||
}); | ||
>( | ||
( | ||
{ | ||
className, | ||
badgeClassName, | ||
size = DEFAULT_AVATAR_SIZE, | ||
onClick, | ||
count, | ||
'aria-label': ariaLabel, | ||
borderColor, | ||
}, | ||
ref, | ||
) => { | ||
return ( | ||
<button | ||
ref={ref} | ||
type="button" | ||
className={b('more-button', {size}, className)} | ||
onClick={onClick} | ||
> | ||
<AvatarStackMore | ||
className={badgeClassName} | ||
size={size} | ||
count={count} | ||
aria-label={ariaLabel} | ||
borderColor={borderColor} | ||
/> | ||
</button> | ||
); | ||
}, | ||
); | ||
|
||
AvatarStackMoreButton.displayName = 'AvatarStack.MoreButton'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file modified
BIN
-469 Bytes
(95%)
....test.tsx-snapshots/AvatarStack-render-story-MoreButton-dark-chromium-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+497 Bytes
(110%)
...al.test.tsx-snapshots/AvatarStack-render-story-MoreButton-dark-webkit-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-655 Bytes
(93%)
...test.tsx-snapshots/AvatarStack-render-story-MoreButton-light-chromium-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+200 Bytes
(100%)
...l.test.tsx-snapshots/AvatarStack-render-story-MoreButton-light-webkit-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+461 Bytes
(110%)
...isual.test.tsx-snapshots/AvatarStack-render-story-Total-dark-chromium-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+534 Bytes
(110%)
....visual.test.tsx-snapshots/AvatarStack-render-story-Total-dark-webkit-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+189 Bytes
(100%)
...sual.test.tsx-snapshots/AvatarStack-render-story-Total-light-chromium-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+243 Bytes
(100%)
...visual.test.tsx-snapshots/AvatarStack-render-story-Total-light-webkit-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,7 @@ | ||
export {AvatarStack} from './AvatarStack'; | ||
export type {AvatarStackProps, AvatarStackOverlapSize} from './types'; | ||
export type { | ||
AvatarStackProps, | ||
AvatarStackOverlapSize, | ||
AvatarStackMoreProps, | ||
AvatarStackMoreButtonProps, | ||
} from './types'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters