Skip to content

Commit

Permalink
fix: update credential card style (#124)
Browse files Browse the repository at this point in the history
* fix: update credential card style

---------

Co-authored-by: Puria Nafisi Azizi <puria@dyne.org>
  • Loading branch information
phoebus-84 and puria authored Jul 23, 2024
1 parent 6a519e7 commit 73c0cb9
Show file tree
Hide file tree
Showing 29 changed files with 220 additions and 69 deletions.
19 changes: 17 additions & 2 deletions src/components.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ export namespace Components {
"size"?: Size;
"src"?: string;
}
interface DBadge {
}
interface DButton {
"buttonType": string;
"clear"?: boolean;
Expand All @@ -40,8 +42,9 @@ export namespace Components {
interface DButtonsGroup {
}
interface DCredentialCard {
"description"?: string;
"expirationDate"?: string;
"expirationLabel": string;
"issuedByLabel": string;
"issuer": string;
"logoSrc"?: string;
"name": string;
Expand Down Expand Up @@ -182,6 +185,12 @@ declare global {
prototype: HTMLDAvatarElement;
new (): HTMLDAvatarElement;
};
interface HTMLDBadgeElement extends Components.DBadge, HTMLStencilElement {
}
var HTMLDBadgeElement: {
prototype: HTMLDBadgeElement;
new (): HTMLDBadgeElement;
};
interface HTMLDButtonElementEventMap {
"dFocus": void;
"dBlur": void;
Expand Down Expand Up @@ -370,6 +379,7 @@ declare global {
"d-activity-card": HTMLDActivityCardElement;
"d-app-details": HTMLDAppDetailsElement;
"d-avatar": HTMLDAvatarElement;
"d-badge": HTMLDBadgeElement;
"d-button": HTMLDButtonElement;
"d-buttons-group": HTMLDButtonsGroupElement;
"d-credential-card": HTMLDCredentialCardElement;
Expand Down Expand Up @@ -414,6 +424,8 @@ declare namespace LocalJSX {
"size"?: Size;
"src"?: string;
}
interface DBadge {
}
interface DButton {
"buttonType"?: string;
"clear"?: boolean;
Expand All @@ -430,8 +442,9 @@ declare namespace LocalJSX {
interface DButtonsGroup {
}
interface DCredentialCard {
"description"?: string;
"expirationDate"?: string;
"expirationLabel"?: string;
"issuedByLabel"?: string;
"issuer"?: string;
"logoSrc"?: string;
"name"?: string;
Expand Down Expand Up @@ -544,6 +557,7 @@ declare namespace LocalJSX {
"d-activity-card": DActivityCard;
"d-app-details": DAppDetails;
"d-avatar": DAvatar;
"d-badge": DBadge;
"d-button": DButton;
"d-buttons-group": DButtonsGroup;
"d-credential-card": DCredentialCard;
Expand Down Expand Up @@ -576,6 +590,7 @@ declare module "@stencil/core" {
"d-activity-card": LocalJSX.DActivityCard & JSXBase.HTMLAttributes<HTMLDActivityCardElement>;
"d-app-details": LocalJSX.DAppDetails & JSXBase.HTMLAttributes<HTMLDAppDetailsElement>;
"d-avatar": LocalJSX.DAvatar & JSXBase.HTMLAttributes<HTMLDAvatarElement>;
"d-badge": LocalJSX.DBadge & JSXBase.HTMLAttributes<HTMLDBadgeElement>;
"d-button": LocalJSX.DButton & JSXBase.HTMLAttributes<HTMLDButtonElement>;
"d-buttons-group": LocalJSX.DButtonsGroup & JSXBase.HTMLAttributes<HTMLDButtonsGroupElement>;
"d-credential-card": LocalJSX.DCredentialCard & JSXBase.HTMLAttributes<HTMLDCredentialCardElement>;
Expand Down
Binary file added src/components/assets/card-bg2-dark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/components/assets/card-bg2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/components/assets/card-bg3-dark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/components/assets/card-bg3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/components/assets/card-bg4-dark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/components/assets/card-bg4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/components/assets/card-bg5-dark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/components/assets/card-bg5.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/components/assets/card-bg6-dark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/components/assets/card-bg6.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/components/assets/card-bg7-dark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/components/assets/card-bg7.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/components/assets/card-bg8-dark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/components/assets/card-bg8.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
23 changes: 23 additions & 0 deletions src/components/badge/badge.stories.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { DBadge } from './d-badge';
import { Meta, StoryObj } from '@storybook/html';

const meta = {
title: 'Design System/Atoms/Badge',
render: () =>
`<d-badge>
Address
</d-badge>`,
} satisfies Meta<DBadge>;

export default meta;
type Story = StoryObj<DBadge>;

export const Default: Story = {
parameters: {
design: {
type: 'figma',
url: 'https://www.figma.com/design/pdwfO3dMKtaCAQakht0JE6/DIDRoom-%2B-Signroom---WF-and-GUI---Dyne.org?node-id=3449-47234&m=dev',
},
},
};

3 changes: 3 additions & 0 deletions src/components/badge/d-badge.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
:host {
display: block;
}
20 changes: 20 additions & 0 deletions src/components/badge/d-badge.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { Component, Host, h } from '@stencil/core';

@Component({
tag: 'd-badge',
styleUrl: 'd-badge.css',
shadow: true,
})
export class DBadge {
render() {
return (
<Host>
<div class="flex w-fit justify-center items-center bg-accent px-2 py-0.5 rounded-md">
<span class="text-on-accent text-center text-sm font-normal leading-5">
<slot></slot>
</span>
</div>
</Host>
);
}
}
10 changes: 10 additions & 0 deletions src/components/badge/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# d-badge



<!-- Auto Generated Below -->


----------------------------------------------

*Built with [StencilJS](https://stenciljs.com/)*
11 changes: 11 additions & 0 deletions src/components/badge/test/d-badge.e2e.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { newE2EPage } from '@stencil/core/testing';

describe('d-badge', () => {
it('renders', async () => {
const page = await newE2EPage();
await page.setContent('<d-badge></d-badge>');

const element = await page.find('d-badge');
expect(element).toHaveClass('hydrated');
});
});
22 changes: 22 additions & 0 deletions src/components/badge/test/d-badge.spec.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { newSpecPage } from '@stencil/core/testing';
import { DBadge } from '../d-badge';

describe('d-badge', () => {
it('renders', async () => {
const page = await newSpecPage({
components: [DBadge],
html: `<d-badge></d-badge>`,
});
expect(page.root).toEqualHtml(`
<d-badge>
<mock:shadow-root>
<div class="bg-accent flex items-center justify-center px-2 py-0.5 rounded-md w-fit">
<span class="font-normal leading-5 text-center text-on-accent text-sm">
<slot></slot>
</span>
</div>
</mock:shadow-root>
</d-badge>
`);
});
});
8 changes: 6 additions & 2 deletions src/components/credential-card/credential-card.stories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,12 @@ const meta = {
`<d-credential-card
name="${args.name}"
issuer="${args.issuer}"
description="${args.description}"
expiration-date="${args.expirationDate}"
issued-by-label="${args.issuedByLabel}"
expiration-label="${args.expirationLabel}"
verified="${args.verified}">
<d-badge>address</d-badge>
<d-badge>email</d-badge>
</d-credential-card>`,
} satisfies Meta<DCredentialCard>;

Expand All @@ -19,8 +22,9 @@ type Story = StoryObj<DCredentialCard>;
export const Default: Story = {
args: {
name: 'Over 18',
description: 'This credential proves that you are over 18 years old',
issuer: 'Italian Government',
issuedByLabel: 'issued by',
expirationLabel: 'exp',
expirationDate: '2017-01-01',
verified: false
},
Expand Down
35 changes: 19 additions & 16 deletions src/components/credential-card/d-credential-card.css
Original file line number Diff line number Diff line change
@@ -1,32 +1,35 @@
:host {
@apply w-full inline-flex flex-col items-start gap-2.5 px-5 py-5 rounded-lg bg-no-repeat bg-primary bg-cover;
.main {
@apply w-full inline-flex flex-col items-start justify-between gap-2.5 px-5 py-5 rounded-2xl bg-no-repeat bg-primary bg-cover aspect-[2] border border-solid border-white self-stretch;
}

.main.bg1 {
background-image: var(--background-card-url);
}

.between {
@apply w-full flex justify-between items-start;
.main.bg2 {
background-image: var(--background-card-url-2);
}

.heading {
@apply flex items-center gap-2;
.main.bg3 {
background-image: var(--background-card-url-3);
}

.name {
@apply text-2xl not-italic font-semibold leading-[22.5px] tracking-[-0.5px];
.main.bg4 {
background-image: var(--background-card-url-4);
}

.info {
@apply inline-flex flex-col items-start gap-2 min-h-32;
.main.bg5 {
background-image: var(--background-card-url-5);
}

.description {
@apply text-xl not-italic font-medium leading-[20.5px] tracking-[-0.5px];
.main.bg6 {
background-image: var(--background-card-url-6);
}

.labeled-text {
@apply flex flex-col gap-0.5 whitespace-nowrap text-lg not-italic leading-[130%] tracking-[-0.5px];
.main.bg7 {
background-image: var(--background-card-url-7);
}

.label {
@apply font-bold;
.main.bg8 {
background-image: var(--background-card-url-8);
}
50 changes: 32 additions & 18 deletions src/components/credential-card/d-credential-card.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ const verifiedUser = (
</svg>
);


@Component({
tag: 'd-credential-card',
styleUrl: 'd-credential-card.css',
Expand All @@ -40,30 +39,45 @@ export class DCredentialCard {
@Prop() issuer: string;
@Prop() logoSrc?: string;
@Prop() verified?: boolean = false;
@Prop() description?: string;
@Prop() expirationDate?: string;
@Prop() issuedByLabel: string;
@Prop() expirationLabel: string;

//random background
private getRandomBg = () => {
const bg = ['bg1', 'bg2', 'bg3', 'bg4', 'bg5', 'bg6', 'bg7', 'bg8'];
return bg[Math.floor(Math.random() * bg.length)];
};

render() {
return (
<Host>
<div class="between">
<div class="info">
<div class="heading">
<d-avatar name={this.name} src={this.logoSrc}></d-avatar>
<d-heading class="name line-clamp-2">{this.name}</d-heading>
<div class={`main ${this.getRandomBg()}`}>
<div class="w-full flex flex-col gap-2">
<div class="w-full flex justify-between items-start">
<div class="inline-flex flex-col gap-3">
<div class="flex gap-2 items-start">
<d-avatar name={this.name} src={this.logoSrc} size="s"></d-avatar>
<d-text size="xl" class="not-italic font-normal leading-7">
{this.name}
</d-text>
</div>
</div>
{this.verified && verifiedUser}
</div>
<div class="flex flex-wrap gap-2">
<slot></slot>
</div>
<span class="description">{this.description}</span>
</div>
{this.verified && verifiedUser}
</div>
<div class="between">
<div class="labeled-text">
<span class="label">Issued by</span>
<span>{this.issuer}</span>
</div>
<div class="labeled-text items-end">
<span class="label">Exp</span>
<span>{this.expirationDate}</span>
<div class="w-full flex justify-between items-start">
<div class="flex flex-col gap-0.5 whitespace-nowrap text-xs font-normal not-italic leading-[130%] tracking-[-0.5px]">
<span>{this.issuedByLabel}</span>
<span>{this.issuer}</span>
</div>
<div class="flex flex-col gap-0.5 whitespace-nowrap text-xs font-normal not-italic leading-[130%] tracking-[-0.5px] items-end">
<span>{this.expirationLabel}</span>
<span>{this.expirationDate}</span>
</div>
</div>
</div>
</Host>
Expand Down
21 changes: 11 additions & 10 deletions src/components/credential-card/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,28 +7,29 @@

## Properties

| Property | Attribute | Description | Type | Default |
| ---------------- | ----------------- | ----------- | --------- | ----------- |
| `description` | `description` | | `string` | `undefined` |
| `expirationDate` | `expiration-date` | | `string` | `undefined` |
| `issuer` | `issuer` | | `string` | `undefined` |
| `logoSrc` | `logo-src` | | `string` | `undefined` |
| `name` | `name` | | `string` | `undefined` |
| `verified` | `verified` | | `boolean` | `false` |
| Property | Attribute | Description | Type | Default |
| ----------------- | ------------------ | ----------- | --------- | ----------- |
| `expirationDate` | `expiration-date` | | `string` | `undefined` |
| `expirationLabel` | `expiration-label` | | `string` | `undefined` |
| `issuedByLabel` | `issued-by-label` | | `string` | `undefined` |
| `issuer` | `issuer` | | `string` | `undefined` |
| `logoSrc` | `logo-src` | | `string` | `undefined` |
| `name` | `name` | | `string` | `undefined` |
| `verified` | `verified` | | `boolean` | `false` |


## Dependencies

### Depends on

- [d-avatar](../avatar)
- [d-heading](../heading)
- [d-text](../text)

### Graph
```mermaid
graph TD;
d-credential-card --> d-avatar
d-credential-card --> d-heading
d-credential-card --> d-text
style d-credential-card fill:#f9f,stroke:#333,stroke-width:4px
```

Expand Down
Loading

0 comments on commit 73c0cb9

Please sign in to comment.