-
Notifications
You must be signed in to change notification settings - Fork 89
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2506 from anuradha9712/feat-avatar-selection-stat…
…us-presence-support feat(avatarSelection): add status & presence support in avatar selection
- Loading branch information
Showing
9 changed files
with
532 additions
and
36 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
173 changes: 173 additions & 0 deletions
173
core/components/atoms/avatarSelection/__stories__/withPresence.story.jsx
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,173 @@ | ||
import * as React from 'react'; | ||
import { action } from '@/utils/action'; | ||
import { AvatarSelection, Avatar, Input } from '@/index'; | ||
|
||
export const withPresence = () => { | ||
const list = [ | ||
{ | ||
firstName: 'John', | ||
lastName: 'Doe', | ||
selected: true, | ||
}, | ||
{ | ||
firstName: 'Anuradha', | ||
lastName: 'Aggarwal', | ||
image: <Avatar.Image src="https://design.innovaccer.com/images/avatar2.jpeg" />, | ||
presence: 'active', | ||
}, | ||
{ | ||
firstName: 'Nancy', | ||
lastName: 'Wheeler', | ||
}, | ||
{ | ||
firstName: 'Monica', | ||
lastName: 'Geller', | ||
presence: 'away', | ||
}, | ||
{ | ||
firstName: 'Arya', | ||
lastName: 'Stark', | ||
}, | ||
{ | ||
firstName: 'Rachel', | ||
lastName: 'Green', | ||
icon: <Avatar.Icon name="person" />, | ||
}, | ||
{ | ||
firstName: 'Satyam', | ||
lastName: 'Yadav', | ||
selected: true, | ||
presence: 'away', | ||
image: <Avatar.Image src="https://design.innovaccer.com/images/avatar1.png" />, | ||
}, | ||
{ | ||
firstName: 'Walter', | ||
lastName: 'Wheeler', | ||
selected: true, | ||
}, | ||
{ | ||
firstName: 'Monica', | ||
lastName: 'Geller', | ||
}, | ||
{ | ||
firstName: 'Arya', | ||
lastName: 'Stark', | ||
presence: 'away', | ||
}, | ||
]; | ||
|
||
const onSelectHandler = (props) => { | ||
action('props', props)(); | ||
}; | ||
|
||
const searchComparator = (searchValue, data) => { | ||
if (searchValue === '') { | ||
return true; | ||
} | ||
return data.firstName.toLowerCase().includes(searchValue.toLowerCase()); | ||
}; | ||
|
||
return ( | ||
<AvatarSelection | ||
list={list} | ||
withSearch={true} | ||
onSelect={onSelectHandler} | ||
searchPlaceholder="Search User" | ||
searchComparator={searchComparator} | ||
/> | ||
); | ||
}; | ||
|
||
const customCode = `() => { | ||
const list = [ | ||
{ | ||
firstName: 'John', | ||
lastName: 'Doe', | ||
selected: true, | ||
}, | ||
{ | ||
firstName: 'Anuradha', | ||
lastName: 'Aggarwal', | ||
image: <Avatar.Image src="https://design.innovaccer.com/images/avatar2.jpeg" />, | ||
presence: 'active', | ||
}, | ||
{ | ||
firstName: 'Nancy', | ||
lastName: 'Wheeler', | ||
}, | ||
{ | ||
firstName: 'Monica', | ||
lastName: 'Geller', | ||
presence: 'away', | ||
}, | ||
{ | ||
firstName: 'Arya', | ||
lastName: 'Stark', | ||
}, | ||
{ | ||
firstName: 'Rachel', | ||
lastName: 'Green', | ||
icon: <Avatar.Icon name="person" />, | ||
}, | ||
{ | ||
firstName: 'Satyam', | ||
lastName: 'Yadav', | ||
selected: true, | ||
presence: 'away', | ||
image: <Avatar.Image src="https://design.innovaccer.com/images/avatar1.png" />, | ||
}, | ||
{ | ||
firstName: 'Walter', | ||
lastName: 'Wheeler', | ||
selected: true, | ||
}, | ||
{ | ||
firstName: 'Monica', | ||
lastName: 'Geller', | ||
}, | ||
{ | ||
firstName: 'Arya', | ||
lastName: 'Stark', | ||
presence: 'away', | ||
}, | ||
]; | ||
const onSelectHandler = (props) => { | ||
console.log('props', props); | ||
}; | ||
const searchComparator = (searchValue, data) => { | ||
if (searchValue === '') { | ||
return true; | ||
} | ||
return data.firstName.toLowerCase().includes(searchValue.toLowerCase()); | ||
}; | ||
return ( | ||
<AvatarSelection | ||
list={list} | ||
withSearch={true} | ||
onSelect={onSelectHandler} | ||
searchPlaceholder="Search User" | ||
searchComparator={searchComparator} | ||
/> | ||
); | ||
}`; | ||
|
||
export default { | ||
title: 'Components/Avatar/AvatarSelection/With Presence', | ||
component: AvatarSelection, | ||
subcomponents: { | ||
'AvatarSelection.Input': Input, | ||
'AvatarSelection.List': AvatarSelection.List, | ||
'AvatarSelection.Option': AvatarSelection.Option, | ||
'AvatarSelection.EmptyState': AvatarSelection.EmptyState, | ||
}, | ||
parameters: { | ||
docs: { | ||
docPage: { | ||
customCode, | ||
}, | ||
}, | ||
}, | ||
}; |
Oops, something went wrong.