-
Notifications
You must be signed in to change notification settings - Fork 3
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 #84 from animo/feature/SID-123
feat: First implementation of the details screens
- Loading branch information
Showing
13 changed files
with
248 additions
and
133 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
57 changes: 41 additions & 16 deletions
57
packages/siera-ui/src/components/connections/ConnectionDetails.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,29 +1,54 @@ | ||
import type { ConnectionRecord } from '@aries-framework/core' | ||
|
||
import { capitalize } from '@animo/siera-core' | ||
import { Title, Flex } from '@mantine/core' | ||
import { Prism } from '@mantine/prism' | ||
import { createStyles, Group, SimpleGrid, Title } from '@mantine/core' | ||
import React from 'react' | ||
|
||
import { Card } from '../Card' | ||
import { SmartAvatar } from '../SmartAvatar' | ||
import { AttributeValue } from '../generic/information/AttributeValue' | ||
import { RecordCodeBlock } from '../generic/information/RecordCodeBlock' | ||
|
||
interface ConnectionDetailsParams { | ||
connectionRecord: ConnectionRecord | ||
} | ||
|
||
const useStyles = createStyles(() => ({ | ||
attributeName: { | ||
whiteSpace: 'nowrap', | ||
overflow: 'hidden', | ||
textOverflow: 'ellipsis', | ||
}, | ||
})) | ||
|
||
export const ConnectionDetails = ({ connectionRecord }: ConnectionDetailsParams) => { | ||
const { classes } = useStyles() | ||
return ( | ||
<Flex direction="column" gap="md"> | ||
{Object.entries(connectionRecord).map(([key, value]) => ( | ||
<Flex direction="column" key={key} gap="xs"> | ||
<Title size="h5">{capitalize(key)}</Title> | ||
{value ? ( | ||
<Prism language="json" noCopy> | ||
{JSON.stringify(value, null, 2)} | ||
</Prism> | ||
) : ( | ||
<Prism language="javascript">{value == null ? 'null' : 'undefined'}</Prism> | ||
)} | ||
</Flex> | ||
))} | ||
</Flex> | ||
<Card withPadding> | ||
<Group spacing="xs" my="xs"> | ||
<SmartAvatar src={connectionRecord.imageUrl} size={32} radius="xl"> | ||
{connectionRecord.theirLabel} | ||
</SmartAvatar> | ||
<Title size="h3">{connectionRecord.theirLabel ?? 'No label'}</Title> | ||
</Group> | ||
|
||
<SimpleGrid cols={2} mt="md" mb="xl"> | ||
{Object.entries(connectionRecord) | ||
.filter(([, value]) => typeof value !== 'object') | ||
.map(([name, value]) => ( | ||
<Group key={name} noWrap> | ||
<Title size="h6" className={classes.attributeName} w={160}> | ||
{capitalize(name)} | ||
</Title> | ||
<AttributeValue value={value} /> | ||
</Group> | ||
))} | ||
</SimpleGrid> | ||
|
||
<Title size="h3" mb="xs"> | ||
Record | ||
</Title> | ||
<RecordCodeBlock record={connectionRecord} /> | ||
</Card> | ||
) | ||
} |
49 changes: 0 additions & 49 deletions
49
packages/siera-ui/src/components/credentials/CredentialCard.tsx
This file was deleted.
Oops, something went wrong.
55 changes: 32 additions & 23 deletions
55
packages/siera-ui/src/components/credentials/CredentialDetails.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,39 +1,48 @@ | ||
import type { FormattedCredentialData } from '../../contexts/CredentialFormatDataProvider' | ||
|
||
import { capitalize } from '@animo/siera-core' | ||
import { Flex, Title } from '@mantine/core' | ||
import { Prism } from '@mantine/prism' | ||
import { formatSchemaName } from '@animo/siera-core' | ||
import { createStyles, Group, SimpleGrid, Title } from '@mantine/core' | ||
import React from 'react' | ||
|
||
import { InformationCollapse } from '../generic/information/InformationCollapse' | ||
import { Card } from '../Card' | ||
import { AttributeValue } from '../generic/information/AttributeValue' | ||
import { RecordCodeBlock } from '../generic/information/RecordCodeBlock' | ||
|
||
interface CredentialDetailsParams { | ||
credentialFormatted: FormattedCredentialData | ||
} | ||
|
||
const useStyles = createStyles(() => ({ | ||
attributeName: { | ||
whiteSpace: 'nowrap', | ||
}, | ||
})) | ||
|
||
export const CredentialDetails = ({ credentialFormatted }: CredentialDetailsParams) => { | ||
const { classes } = useStyles() | ||
if (credentialFormatted.offerAttributes == null) { | ||
return <div>There are no attributes</div> | ||
} | ||
|
||
const credentialName = formatSchemaName(credentialFormatted.credential?.indy?.schema_id) | ||
|
||
return ( | ||
<Flex direction="column" gap="md"> | ||
{credentialFormatted.offerAttributes.map(({ name, value }) => ( | ||
<Flex direction="column" key={name} gap="xs"> | ||
<Title size="h5">{capitalize(name)}</Title> | ||
{value ? ( | ||
<Prism language="json" noCopy> | ||
{JSON.stringify(value, null, 2)} | ||
</Prism> | ||
) : ( | ||
<Prism language="javascript">{value == null ? 'null' : 'undefined'}</Prism> | ||
)} | ||
</Flex> | ||
))} | ||
<InformationCollapse title="Raw Credential"> | ||
<Prism language="json" noCopy> | ||
{JSON.stringify(credentialFormatted, null, 2)} | ||
</Prism> | ||
</InformationCollapse> | ||
</Flex> | ||
<Card title={credentialName} titleSize="h2" withPadding> | ||
<SimpleGrid cols={2} mt="md" mb="xl"> | ||
{credentialFormatted.offerAttributes.map(({ name, value }) => ( | ||
<Group key={name} noWrap> | ||
<Title size="h6" className={classes.attributeName} w={120}> | ||
{name} | ||
</Title> | ||
<AttributeValue value={value} /> | ||
</Group> | ||
))} | ||
</SimpleGrid> | ||
|
||
<Title size="h3" mb="xs"> | ||
Record | ||
</Title> | ||
<RecordCodeBlock record={credentialFormatted} /> | ||
</Card> | ||
) | ||
} |
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
48 changes: 48 additions & 0 deletions
48
packages/siera-ui/src/components/generic/information/AttributeValue.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 |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import { createStyles } from '@mantine/core' | ||
import { Prism } from '@mantine/prism' | ||
import React from 'react' | ||
|
||
const useStyles = createStyles((theme) => ({ | ||
code: { | ||
borderRadius: theme.radius.md, | ||
border: `1px solid ${theme.colors.backgroundOne[6]}`, | ||
padding: theme.spacing.xs, | ||
}, | ||
root: { | ||
width: '100%', | ||
maxWidth: '100%', | ||
overflow: 'auto', | ||
}, | ||
line: { | ||
padding: 0, | ||
}, | ||
})) | ||
|
||
interface AttributeValueProps { | ||
value: unknown | ||
} | ||
export const AttributeValue = ({ value }: AttributeValueProps) => { | ||
const { classes } = useStyles() | ||
|
||
if (value == null) { | ||
return ( | ||
<Prism | ||
language="javascript" | ||
copyLabel="Copy value" | ||
classNames={{ root: classes.root, code: classes.code, line: classes.line }} | ||
> | ||
{value == undefined ? 'undefined' : 'null'} | ||
</Prism> | ||
) | ||
} | ||
|
||
return ( | ||
<Prism | ||
language="json" | ||
copyLabel="Copy value" | ||
classNames={{ root: classes.root, code: classes.code, line: classes.line }} | ||
> | ||
{JSON.stringify(value, null, 2)} | ||
</Prism> | ||
) | ||
} |
30 changes: 30 additions & 0 deletions
30
packages/siera-ui/src/components/generic/information/RecordCodeBlock.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 |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { createStyles } from '@mantine/core' | ||
import { Prism } from '@mantine/prism' | ||
import React from 'react' | ||
|
||
const useStyles = createStyles((theme) => ({ | ||
code: { | ||
borderRadius: theme.radius.md, | ||
border: `1px solid ${theme.colors.backgroundOne[6]}`, | ||
padding: theme.spacing.xs, | ||
}, | ||
root: { | ||
width: '100%', | ||
}, | ||
line: { | ||
padding: 0, | ||
}, | ||
})) | ||
|
||
interface RecordCodeBlockProps { | ||
record: unknown | ||
} | ||
|
||
export const RecordCodeBlock = ({ record }: RecordCodeBlockProps) => { | ||
const { classes } = useStyles() | ||
return ( | ||
<Prism language="json" withLineNumbers classNames={{ root: classes.root, code: classes.code, line: classes.line }}> | ||
{JSON.stringify(record, null, 2)} | ||
</Prism> | ||
) | ||
} |
Oops, something went wrong.