Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: card rendering background #93

Merged
merged 1 commit into from
Mar 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions packages/agent/src/display.ts
Original file line number Diff line number Diff line change
Expand Up @@ -289,13 +289,11 @@ export function getCredentialForDisplay(credentialRecord: W3cCredentialRecord |
const issuerDisplay = getSdJwtIssuerDisplay(openId4VcMetadata)
const credentialDisplay = getSdJwtCredentialDisplay(decodedPayload, openId4VcMetadata)

// TODO: should we add a way to see these claims? Currently matching what would
// be included in a w3c credential subject
// TODO: We should map these claims to nice format and names
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const { _sd_alg, _sd_hash, iss, vct, cnf, ...visibleProperties } = decodedPayload
const { _sd_alg, _sd_hash, iss, vct, cnf, iat, exp, ...visibleProperties } = decodedPayload

// TODO: display somehow which fields can be selective disclosed

return {
id: `sd-jwt-vc-${credentialRecord.id}` satisfies CredentialForDisplayId,
createdAt: credentialRecord.createdAt,
Expand Down
9 changes: 8 additions & 1 deletion packages/app/components/CredentialCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ export default function CredentialCard({
}}
h="$16"
onPress={onPress}
overflow="hidden"
>
<Card.Header padding={0}>
<XStack jc="space-between">
Expand Down Expand Up @@ -105,7 +106,13 @@ export default function CredentialCard({
<Card.Background>
{hasInternet ? (
<YStack width="100%" height="100%" bg={bgColor ?? '$grey-900'}>
<Image src={backgroundImage.url} alt={backgroundImage.altText} resizeMode="cover" />
<Image
src={backgroundImage.url}
alt={backgroundImage.altText}
width="100%"
height="100%"
resizeMode="cover"
/>
</YStack>
) : (
<YStack width="100%" height="100%" bg={bgColor ?? '$grey-900'} />
Expand Down
10 changes: 8 additions & 2 deletions packages/app/utils/formatCredentialSubject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,16 @@ export function formatCredentialSubject(
image: value,
type: 'image',
})
} else if (typeof value === 'string') {
} else if (typeof value === 'string' || typeof value === 'number') {
stringRows.push({
key: sanitizeString(key),
value: value,
value: `${value}`,
type: 'string',
})
} else if (typeof value === 'boolean') {
stringRows.push({
key: sanitizeString(key),
value: value ? 'Yes' : 'No',
type: 'string',
})
}
Expand Down
2 changes: 1 addition & 1 deletion packages/utils/src/format.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export function capitalizeFirstLetter(string: string) {
* i.e. sanitizeString("helloWorld") // returns: 'Hello world'
*/
export function sanitizeString(str: string) {
const result = str.replace(/([a-z0-9])([A-Z])/g, '$1 $2')
const result = str.replace(/([a-z0-9])([A-Z])/g, '$1 $2').replaceAll('_', ' ')
let words = result.split(' ')
words = words.map((word, index) => {
if (index === 0 || word.toUpperCase() === word) {
Expand Down
Loading