-
Notifications
You must be signed in to change notification settings - Fork 135
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: List known identities in connections view
- Loading branch information
Jason Healy
committed
Jan 29, 2020
1 parent
2b098df
commit 784c29b
Showing
6 changed files
with
95 additions
and
17 deletions.
There are no files selected for viewing
41 changes: 36 additions & 5 deletions
41
examples/react-graphql/client/src/components/Avatar/Avatar.tsx
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,11 +1,42 @@ | ||
import React from 'react' | ||
import { Box, Heading, Avatar } from 'rimble-ui' | ||
import Page from '../../layout/Page' | ||
import { Image } from 'rimble-ui' | ||
import md5 from 'md5' | ||
|
||
interface AvatarProps {} | ||
interface AvatarProps { | ||
did: string | ||
source?: string | ||
size?: number | ||
type?: 'square' | 'rounded' | 'circle' | ||
highlight?: boolean | ||
} | ||
|
||
const Component: React.FC<AvatarProps> = ({ did, type, size, source, highlight }) => { | ||
const avatarSize = size || 40 | ||
const avatarType = type || 'rounded' | ||
const radius = { | ||
square: 0, | ||
rounded: 5, | ||
circle: avatarSize / 2, | ||
} | ||
|
||
const gravatarType = 'identicon' | ||
const GRAVATAR_URI = 'https://www.gravatar.com/avatar/' | ||
const uri = GRAVATAR_URI + md5(did) + '?s=' + avatarSize * 2 + '&d=' + gravatarType | ||
const src = source || uri | ||
|
||
const highlighted = highlight ? { border: 1, padding: 1 } : {} | ||
|
||
const Component: React.FC<AvatarProps> = () => { | ||
return <Box></Box> | ||
return ( | ||
<Image | ||
{...highlighted} | ||
borderColor={'#4a4a4a'} | ||
alt={`Avatar image for ${did}`} | ||
borderRadius={radius[avatarType]} | ||
height={avatarSize} | ||
width={avatarSize} | ||
src={src} | ||
/> | ||
) | ||
} | ||
|
||
export default Component |
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
42 changes: 41 additions & 1 deletion
42
examples/react-graphql/client/src/views/Connections/Connections.tsx
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,9 +1,49 @@ | ||
import React from 'react' | ||
import { Box, Heading } from 'rimble-ui' | ||
import Page from '../../layout/Page' | ||
import Avatar from '../../components/Avatar/Avatar' | ||
import * as queries from '../../gql/queries' | ||
import { useQuery, useLazyQuery } from 'react-apollo' | ||
import * as Types from '../../types' | ||
import Panel from '../../components/Panel/Panel' | ||
|
||
const Component = () => { | ||
return <Page title={'Connections'}></Page> | ||
const { loading, data } = useQuery(queries.allIdentities) | ||
|
||
console.log(data?.identities) | ||
|
||
return ( | ||
<Page title={'Connections'}> | ||
{/* <Avatar did={'ethr:did:0x145'} type={'circle'} size={60} /> */} | ||
|
||
<Box p={3}> | ||
<Panel heading={'Known identities'}> | ||
<Box> | ||
{data?.identities?.map((id: Types.Identity) => { | ||
return ( | ||
<Box | ||
className={'identity_row'} | ||
key={id.did} | ||
mb={2} | ||
py={2} | ||
flexDirection={'row'} | ||
flex={1} | ||
display={'flex'} | ||
alignItems={'center'} | ||
> | ||
<Box ml={3}> | ||
<Avatar did={id.did} source={id.profileImage} type={'circle'} highlight={id.isManaged} /> | ||
</Box> | ||
<Box ml={3}>{id.shortId}</Box> | ||
<Box ml={3}>{id.isManaged && '(You manage this identity)'}</Box> | ||
</Box> | ||
) | ||
})} | ||
</Box> | ||
</Panel> | ||
</Box> | ||
</Page> | ||
) | ||
} | ||
|
||
export default Component |
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