-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Credentials list and single page (#41)
* update metadata interaction * credentials list, item and card * upd credentials pages design, add rm vc method * add interactions, handlers and ui components * add issuer details and vc formatting * load credentials via store
- Loading branch information
Showing
32 changed files
with
804 additions
and
149 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
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
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,120 @@ | ||
import { alpha, Box, Divider, Stack, StackProps, Typography, useTheme } from '@mui/material' | ||
import { W3CCredential } from '@rarimo/rarime-connector' | ||
import startCase from 'lodash/startCase' | ||
|
||
import { formatCredentialType, getCredentialViewProperty, IssuerDetails } from '@/api/modules/zkp' | ||
import { formatDateMY } from '@/helpers' | ||
import { UiIcon } from '@/ui' | ||
|
||
function DotsDecoration({ ...rest }: StackProps) { | ||
const { palette } = useTheme() | ||
|
||
const rowsCount = 3 | ||
const maxDots = 5 | ||
const betweenDotsSpacing = 2 | ||
|
||
// TODO: alpha(palette.common.white, ...) should be configured together with bg | ||
return ( | ||
<Stack {...rest} alignItems={'flex-end'} spacing={betweenDotsSpacing}> | ||
{Array.from({ length: rowsCount }, (v, i) => i).map(rowIdx => ( | ||
<Stack key={rowIdx} direction='row' spacing={betweenDotsSpacing}> | ||
{Array.from({ length: maxDots - rowIdx }, (v, i) => i).map(boxIdx => ( | ||
<Box | ||
key={boxIdx} | ||
width={8} | ||
height={8} | ||
borderRadius={'50%'} | ||
bgcolor={alpha(palette.common.white, 0.16)} | ||
/> | ||
))} | ||
</Stack> | ||
))} | ||
</Stack> | ||
) | ||
} | ||
|
||
type Props = StackProps & { | ||
vc: W3CCredential | ||
issuerDetails: IssuerDetails | ||
} | ||
|
||
export default function CredentialCard({ vc, issuerDetails, ...rest }: Props) { | ||
const { palette, spacing } = useTheme() | ||
|
||
return ( | ||
<Stack | ||
{...rest} | ||
spacing={6} | ||
p={6} | ||
borderRadius={4} | ||
sx={{ | ||
position: 'relative', | ||
width: '100%', | ||
// TODO: use background from vc metadata or predefined bg map | ||
background: 'linear-gradient(#252C3B 100%, #0F1218 100%)', | ||
}} | ||
> | ||
<DotsDecoration | ||
sx={{ | ||
position: 'absolute', | ||
top: spacing(6), | ||
right: spacing(6), | ||
}} | ||
/> | ||
<Box | ||
width={40} | ||
height={40} | ||
color={palette.common.white} | ||
bgcolor={alpha(palette.common.white, 0.1)} | ||
borderRadius={'50%'} | ||
p={2} | ||
> | ||
{/*TODO: define map for credential types*/} | ||
<UiIcon componentName='fingerprint' /> | ||
</Box> | ||
|
||
<Stack spacing={2}> | ||
<Typography variant='h6' color={palette.common.white}> | ||
{formatCredentialType(vc.type)} | ||
</Typography> | ||
|
||
<Box | ||
sx={{ | ||
overflow: 'hidden', | ||
textOverflow: 'ellipsis', | ||
maxWidth: '50%', | ||
color: alpha(palette.common.white, 0.6), | ||
}} | ||
> | ||
<Typography variant='body3'>{issuerDetails.name}</Typography> | ||
</Box> | ||
</Stack> | ||
|
||
<Divider | ||
sx={{ | ||
backgroundColor: alpha(palette.common.white, 0.1), | ||
}} | ||
/> | ||
<Stack spacing={2} direction='row' alignItems='center' justifyContent='space-between'> | ||
<Typography variant='body4' color={alpha(palette.common.white, 0.6)}> | ||
<Stack direction='row' alignItems='center' spacing={2}> | ||
{vc.expirationDate ? ( | ||
<> | ||
<UiIcon componentName='calendarTodayOutlinedIcon' size={4} /> | ||
<Typography>{formatDateMY(vc.expirationDate)}</Typography> | ||
</> | ||
) : ( | ||
<UiIcon componentName='allInclusiveOutlinedIcon' size={4} /> | ||
)} | ||
</Stack> | ||
</Typography> | ||
|
||
<Typography variant='body4' color={alpha(palette.common.white, 0.6)}> | ||
<Stack direction='row' alignItems='center' spacing={2}> | ||
<Typography>{startCase(getCredentialViewProperty(vc))}</Typography> | ||
</Stack> | ||
</Typography> | ||
</Stack> | ||
</Stack> | ||
) | ||
} |
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
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 |
---|---|---|
@@ -1,5 +1,11 @@ | ||
import { time } from '@distributedlab/tools' | ||
|
||
const FORMATTED_DID_MAX_LENGTH = 12 | ||
|
||
export function formatDid(did: string) { | ||
return did.length > FORMATTED_DID_MAX_LENGTH ? did.slice(0, 8) + '...' + did.slice(-4) : did | ||
} | ||
|
||
export function formatDateMY(date: string) { | ||
return time(date).format('MM / YYYY') | ||
} |
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
Oops, something went wrong.