11import { useEffect , useRef , useState } from 'react' ;
2- import {
3- AvatarGroup ,
4- Box ,
5- Flex ,
6- Layer ,
7- Popover ,
8- SearchField ,
9- Text ,
10- useDangerouslyInGestaltExperiment ,
11- } from 'gestalt' ;
2+ import { AvatarGroup , Box , Flex , Layer , Popover , SearchField , Text } from 'gestalt' ;
123
13- function SearchCollaboratorsField ( ) {
4+ export default function Example ( ) {
5+ const [ open , setOpen ] = useState ( false ) ;
6+ const anchorRef = useRef < null | HTMLAnchorElement | HTMLDivElement > ( null ) ;
147 const ref = useRef < null | HTMLInputElement > ( null ) ;
158
169 useEffect ( ( ) => {
1710 if ( ref . current ) ref . current . focus ( ) ;
1811 } , [ ] ) ;
1912
2013 return (
21- < SearchField
22- ref = { ref }
23- accessibilityLabel = "Search other users"
24- id = "searchField"
25- onChange = { ( ) => { } }
26- placeholder = "Search by name or email"
27- size = "lg"
28- />
29- ) ;
30- }
31-
32- export default function Example ( ) {
33- const [ open , setOpen ] = useState ( false ) ;
34- const anchorRef = useRef < null | HTMLAnchorElement | HTMLDivElement > ( null ) ;
35- const isInVRExperiment = useDangerouslyInGestaltExperiment ( {
36- webExperimentName : 'web_gestalt_visualrefresh' ,
37- mwebExperimentName : 'web_gestalt_visualrefresh' ,
38- } ) ;
39-
40- const collaborators = [
41- {
42- name : 'Keerthi' ,
43- src : 'https://i.ibb.co/ZfCZrY8/keerthi.jpg' ,
44- } ,
45- {
46- name : 'Alberto' ,
47- src : 'https://i.ibb.co/NsK2w5y/Alberto.jpg' ,
48- } ,
49- ...new Array ( 10 ) ,
50- ] ;
51-
52- const collaboratorsVR = [
53- {
54- name : 'Fatima' ,
55- src : 'https://i.pinimg.com/originals/bf/bc/27/bfbc27685d81eb9a8f65c201ea661f0e.jpg' ,
56- } ,
57- {
58- name : 'Ayesha' ,
59- src : 'https://i.pinimg.com/originals/c5/5c/ac/c55caca43a7c16766215ec165b649c1c.jpg' ,
60- } ,
61- ...new Array ( 10 ) ,
62- ] ;
63-
64- const names = isInVRExperiment ? 'Fatima, Ayesha,' : 'Keerthi, Alberto,' ;
65-
66- return isInVRExperiment ? (
6714 < Flex height = "100%" width = "100%" >
6815 < Box height = "200" marginTop = { 6 } padding = { 2 } >
6916 < AvatarGroup
7017 ref = { anchorRef }
7118 accessibilityExpanded = { open }
72- accessibilityLabel = { `Collaborators: ${ names } and 10 more. Add collaborators to this board.` }
19+ accessibilityLabel = { `Collaborators: 'Fatima, Ayesha,' and 10 more. Add collaborators to this board.` }
7320 addCollaborators
74- collaborators = { collaboratorsVR }
21+ collaborators = { [
22+ {
23+ name : 'Fatima' ,
24+ src : 'https://i.pinimg.com/originals/bf/bc/27/bfbc27685d81eb9a8f65c201ea661f0e.jpg' ,
25+ } ,
26+ {
27+ name : 'Ayesha' ,
28+ src : 'https://i.pinimg.com/originals/c5/5c/ac/c55caca43a7c16766215ec165b649c1c.jpg' ,
29+ } ,
30+ ...new Array ( 10 ) ,
31+ ] }
7532 onClick = { ( ) => setOpen ( ( value ) => ! value ) }
7633 role = "button"
7734 size = "md"
@@ -98,49 +55,14 @@ export default function Example() {
9855 < Text align = "center" color = "default" weight = "bold" >
9956 Invite collaborators
10057 </ Text >
101- < SearchCollaboratorsField />
102- </ Flex >
103- </ Box >
104- </ Popover >
105- </ Layer >
106- ) }
107- </ Flex >
108- ) : (
109- < Flex height = "100%" width = "100%" >
110- < Box height = "200" marginTop = { 6 } padding = { 2 } >
111- < AvatarGroup
112- ref = { anchorRef }
113- accessibilityExpanded = { open }
114- accessibilityLabel = { `Collaborators: ${ names } and 10 more. Add collaborators to this board.` }
115- addCollaborators
116- collaborators = { isInVRExperiment ? collaboratorsVR : collaborators }
117- onClick = { ( ) => setOpen ( ( value ) => ! value ) }
118- role = "button"
119- size = "md"
120- />
121- </ Box >
122- { open && (
123- < Layer >
124- < Popover
125- anchor = { anchorRef . current }
126- idealDirection = "down"
127- onDismiss = { ( ) => setOpen ( false ) }
128- positionRelativeToAnchor = { false }
129- size = "xl"
130- >
131- < Box
132- flex = "grow"
133- marginBottom = { 8 }
134- marginEnd = { 4 }
135- marginStart = { 4 }
136- marginTop = { 6 }
137- width = { 360 }
138- >
139- < Flex direction = "column" gap = { { column : 6 , row : 0 } } >
140- < Text align = "center" color = "default" weight = "bold" >
141- Invite collaborators
142- </ Text >
143- < SearchCollaboratorsField />
58+ < SearchField
59+ ref = { ref }
60+ accessibilityLabel = "Search other users"
61+ id = "searchField"
62+ onChange = { ( ) => { } }
63+ placeholder = "Search by name or email"
64+ size = "lg"
65+ />
14466 </ Flex >
14567 </ Box >
14668 </ Popover >
0 commit comments