-
Notifications
You must be signed in to change notification settings - Fork 2.9k
react-avatar: Adding initial implementation of AvatarGroup. #22736
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
Changes from 22 commits
33c8028
11be710
9a6f9b4
5fe2af0
155cdde
6a42db5
d1a04b9
69625b5
f5583b2
c8bb4c4
f3bfd1d
ffe8b41
575d8c6
cfeea42
2467069
edbfe66
f3bcb81
6fb6258
cd74a0e
5a6bced
2bd144d
9761bab
136b2ea
539f419
f802a98
98c7dd5
43b2213
e8e42a6
4fee5ba
2118864
8da8f1f
bd3ae84
7501379
7801453
42cc81a
7f1f741
8d932f2
6b38759
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| { | ||
| "type": "none", | ||
| "comment": "Adding initial implementation of AvatarGroup", | ||
| "packageName": "@fluentui/react-avatar", | ||
| "email": "email not defined", | ||
| "dependentChangeType": "none" | ||
| } | ||
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,6 +2,7 @@ import * as React from 'react'; | |
| import { render } from '@testing-library/react'; | ||
| import { AvatarGroup } from './AvatarGroup'; | ||
| import { isConformant } from '../../common/isConformant'; | ||
| import { Avatar } from '../Avatar'; | ||
|
|
||
| describe('AvatarGroup', () => { | ||
| // TODO: Remove component-has-static-classnames-object from disabled tests. | ||
|
|
@@ -18,7 +19,19 @@ describe('AvatarGroup', () => { | |
| // TODO add more tests here, and create visual regression tests in /apps/vr-tests | ||
|
|
||
| it('renders a default state', () => { | ||
| const result = render(<AvatarGroup>Default AvatarGroup</AvatarGroup>); | ||
| const result = render( | ||
| <AvatarGroup> | ||
| <Avatar name="Katri Athokas" /> | ||
| <Avatar name="Elvia Atkins" /> | ||
| <Avatar name="Cameron Evans" /> | ||
| <Avatar name="Wanda Howard" /> | ||
| <Avatar name="Mona Kane" /> | ||
| <Avatar name="Allan Munger" /> | ||
| <Avatar name="Daisy Phillips" /> | ||
| <Avatar name="Robert Tolbert" /> | ||
| <Avatar name="Kevin Sturgis" /> | ||
| </AvatarGroup>, | ||
| ); | ||
|
Comment on lines
+22
to
+34
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This can be changed in a future PR, but ideally we wouldn't be using snapshots in any tests. Instead, use testing-library queries to check specific aspects of the rendered tree in different scenarios. See Avatar.test.tsx for some examples of that. (The tests should be testing the specific functions and features AvatarGroup itself; e.g. the logic in |
||
| expect(result.container).toMatchSnapshot(); | ||
| }); | ||
| }); | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,13 +1,31 @@ | ||
| import * as React from 'react'; | ||
| import { Popover, PopoverTrigger } from '@fluentui/react-popover'; | ||
| import { Tooltip } from '@fluentui/react-tooltip'; | ||
| import { getSlots } from '@fluentui/react-utilities'; | ||
| import type { AvatarGroupState, AvatarGroupSlots } from './AvatarGroup.types'; | ||
| import type { AvatarGroupState, AvatarGroupSlots, AvatarGroupContextValues } from './AvatarGroup.types'; | ||
| import { AvatarGroupContext } from '../../contexts/AvatarGroupContext'; | ||
|
|
||
| /** | ||
| * Render the final JSX of AvatarGroup | ||
| */ | ||
| export const renderAvatarGroup_unstable = (state: AvatarGroupState) => { | ||
| export const renderAvatarGroup_unstable = (state: AvatarGroupState, contextValues: AvatarGroupContextValues) => { | ||
| const { slots, slotProps } = getSlots<AvatarGroupSlots>(state); | ||
|
|
||
| // TODO Add additional slots in the appropriate place | ||
| return <slots.root {...slotProps.root} />; | ||
| return ( | ||
| <AvatarGroupContext.Provider value={contextValues.avatarGroup}> | ||
| <slots.root {...slotProps.root}> | ||
| {state.root.children} | ||
| {state.hasOverflow && ( | ||
| <Popover trapFocus size="small"> | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We might also need a slot for this
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since |
||
| <PopoverTrigger> | ||
| <Tooltip content={state.tooltipContent} relationship="description" appearance="inverted"> | ||
|
sopranopillow marked this conversation as resolved.
Outdated
|
||
| <slots.popoverTrigger {...slotProps.popoverTrigger} /> | ||
| </Tooltip> | ||
| </PopoverTrigger> | ||
| <slots.popoverSurface {...slotProps.popoverSurface} /> | ||
| </Popover> | ||
| )} | ||
| </slots.root> | ||
| </AvatarGroupContext.Provider> | ||
| ); | ||
| }; | ||
Uh oh!
There was an error while loading. Please reload this page.