Skip to content

Commit

Permalink
Merge pull request #330 from Concordium/display-credentials
Browse files Browse the repository at this point in the history
Display credentials
  • Loading branch information
orhoj authored Aug 9, 2023
2 parents b8d72ed + f337daa commit 05e15fa
Show file tree
Hide file tree
Showing 28 changed files with 1,464 additions and 3 deletions.
1 change: 1 addition & 0 deletions packages/browser-wallet/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
"i18next-browser-languagedetector": "^6.1.4",
"jotai": "^1.6.5",
"json-bigint": "^1.0.0",
"jsonschema": "^1.4.1",
"leb128": "^0.0.5",
"lodash.debounce": "^4.0.8",
"lodash.groupby": "^4.6.0",
Expand Down
3 changes: 3 additions & 0 deletions packages/browser-wallet/src/assets/svg/block.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions packages/browser-wallet/src/assets/svg/pending.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions packages/browser-wallet/src/assets/svg/revoked.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions packages/browser-wallet/src/assets/svg/verified.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion packages/browser-wallet/src/popup/constants/dimensions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@ export const medium: Dimensions = {

// >=1440p
export const large: Dimensions = {
width: 354,
width: 375,
height: 600, // Max allowed
};
3 changes: 3 additions & 0 deletions packages/browser-wallet/src/popup/constants/routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ export const relativeRoutes = {
path: 'identities',
add: { path: 'add' },
},
verifiableCredentials: {
path: 'verifiable-credentials',
},
settings: {
path: 'settings',
allowlist: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ function Header() {
return t('header.connect');
}
if (pathname.startsWith(absoluteRoutes.prompt.connectAccountsRequest.path)) {
return t('header.connectAccountsRequest');
return t('header.allowlistingRequest');
}
if (pathname.startsWith(absoluteRoutes.prompt.addTokens.path)) {
return t('header.addTokens');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ const transitionVariants: Variants = {
enum Section {
Account,
Id,
VerifiableCredentials,
Settings,
}

Expand All @@ -67,6 +68,8 @@ function getTitle(section: Section, pathname: string) {
return 'header.accounts';
case Section.Id:
return 'header.ids';
case Section.VerifiableCredentials:
return 'header.verifiableCredentials';
case Section.Settings: {
if (pathname.startsWith(absoluteRoutes.home.settings.allowlist.path)) {
return 'header.settings.allowlist';
Expand Down Expand Up @@ -94,6 +97,9 @@ function getSection(pathname: string): Section {
if (pathname.startsWith(absoluteRoutes.home.identities.path)) {
return Section.Id;
}
if (pathname.startsWith(absoluteRoutes.home.verifiableCredentials.path)) {
return Section.VerifiableCredentials;
}
if (pathname.startsWith(absoluteRoutes.home.settings.path)) {
return Section.Settings;
}
Expand Down Expand Up @@ -190,6 +196,12 @@ export default function Header({ onToggle, className }: Props) {
<HeaderLink onClick={() => setNavOpen(false)} to={absoluteRoutes.home.identities.path}>
{t('header.ids')}
</HeaderLink>
<HeaderLink
onClick={() => setNavOpen(false)}
to={absoluteRoutes.home.verifiableCredentials.path}
>
{t('header.verifiableCredentials')}
</HeaderLink>
<HeaderLink onClick={() => setNavOpen(false)} to={absoluteRoutes.home.settings.path}>
{t('header.settings.main')}
</HeaderLink>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const t: typeof en = {
header: {
accounts: 'Konti',
ids: 'ID kort',
verifiableCredentials: 'Legitimationsoplysninger',
settings: {
main: 'Wallet indstillinger',
allowlist: 'Tilladelsesliste',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ const t = {
header: {
accounts: 'Accounts',
ids: 'ID cards',
verifiableCredentials: 'Verifiable credentials',
settings: {
main: 'Wallet settings',
allowlist: 'Allowlist',
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
.verifiable-credential-list {
overflow-y: auto;
}

.verifiable-credential {
color: $color-white;
border-radius: rem(16px);
margin: rem(16px);
box-shadow: rgb(99 99 99 / 20%) rem(0) rem(2px) rem(8px) rem(0);
position: relative;

&__header {
display: flex;
align-items: center;
height: 62px;

&__logo {
flex-shrink: 0;
margin-left: rem(11px);
width: rem(28px);
height: rem(28px);

svg {
path {
fill: $color-white;
}
}
}

&__title {
font-size: rem(10px);
margin-left: rem(7px);
}

&__status {
display: flex;
font-size: rem(8px);
color: $color-white;
margin-right: rem(11px);
margin-left: auto;
align-items: center;

svg {
margin-left: rem(5px);
}

path {
fill: $color-white;
}
}
}

&__image {
margin-left: rem(8px);
margin-right: rem(8px);
height: 120px;
width: 308px;

img {
max-width: 100%;
max-height: 100%;
}
}

&__body-attributes {
padding: rem(11px);

&-row {
&:not(:last-child) {
margin-bottom: rem(10px);
}

label {
color: $color-white;
opacity: 0.5;
font-size: rem(9px);
font-variant: small-caps;
display: block;
}

&-value {
display: block;
font-size: rem(10px);
font-weight: $font-weight-light;
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
/* eslint-disable react/function-component-definition, react/destructuring-assignment */
import React from 'react';
import { ComponentMeta, ComponentStory } from '@storybook/react';
import { VerifiableCredentialSchema, VerifiableCredentialStatus } from '@shared/storage/types';
import { VerifiableCredentialMetadata } from '@shared/utils/verifiable-credential-helpers';
import { VerifiableCredentialCard } from './VerifiableCredentialCard';

export default {
title: 'VerifiableCredential/VerifiableCredentialCard',
component: VerifiableCredentialCard,
} as ComponentMeta<typeof VerifiableCredentialCard>;

const schema: VerifiableCredentialSchema = {
$id: 'https://example-university.com/certificates/JsonSchema2023-education-certificate.json',
$schema: 'https://json-schema.org/draft/2020-12/schema',
name: 'Education certificate',
description: 'Simple representation of an education certificate.',
type: 'object',
properties: {
credentialSubject: {
type: 'object',
properties: {
id: {
title: 'Credential subject id',
type: 'string',
description: 'Credential subject identifier',
},
degreeType: {
title: 'Degree Hello',
type: 'string',
description: 'Degree type',
},
degreeName: {
title: 'Degree name',
type: 'string',
description: 'Degree name',
},
graduationDate: {
title: 'Graduation date',
type: 'string',
format: 'date-time',
description: 'Graduation date',
},
},
required: ['id', 'degreeType', 'degreeName', 'graduationDate'],
},
},
required: ['credentialSubject'],
};

const metadata: VerifiableCredentialMetadata = {
title: 'Education Certificate v2',
logo: {
url: 'https://img.logoipsum.com/298.svg',
hash: '1c74f7eb1b3343a5834e60e9a8fce277f2c7553112accd42e63fae7a09e0caf8',
},
background_color: '#003d73',
image: {
url: 'https://picsum.photos/327/120',
},
localization: {
'da-DK': {
url: 'https://location.of/the/danish/metadata.json',
hash: '624a1a7e51f7a87effbf8261426cb7d436cf597be327ebbf113e62cb7814a34b',
},
},
};

const verifiableCredential = {
'@context': ['https://www.w3.org/2018/credentials/v1', 'Concordium VC URI'],
id: 'did:ccd:NETWORK:sci:INDEX:SUBINDEX/credentialEntry/ff4aa77af80b4d72973ccb957d180746',
type: ['VerifiableCredential', 'UniversityDegreeCredential'],
issuer: 'did:ccd:NETWORK:sci:INDEX:SUBINDEX/issuer',
issuanceDate: '2010-01-01T00:00:00Z',
credentialSubject: {
id: 'did:ccd:pkc:ebfeb1f712ebc6f1c276e12ec21',
degreeType: 'Bachelor degree',
degreeName: 'Bachelor of Science and Arts',
graduationDate: '2010-06-01T00:00:00Z',
},
credentialSchema: {
id: 'https://example-university.com/certificates/simple-education-certificate.json',
type: 'CredentialSchema2022', // the same for all schemas
},
};

export const Primary: ComponentStory<typeof VerifiableCredentialCard> = () => {
return (
<div style={{ width: 375 }}>
<VerifiableCredentialCard
credential={verifiableCredential}
schema={schema}
credentialStatus={VerifiableCredentialStatus.Active}
metadata={metadata}
/>
</div>
);
};
Loading

0 comments on commit 05e15fa

Please sign in to comment.