Skip to content

Commit

Permalink
Merge branch 'dev' into fix/expired-assets-nova
Browse files Browse the repository at this point in the history
  • Loading branch information
begonaalvarezd authored Apr 22, 2024
2 parents 4235daa + a0bd434 commit ee7cfe1
Show file tree
Hide file tree
Showing 5 changed files with 352 additions and 216 deletions.
87 changes: 87 additions & 0 deletions client/src/app/components/CardInfo.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
@import "../../scss/fonts";
@import "../../scss/mixins";
@import "../../scss/media-queries";
@import "../../scss/variables";

.card-info {
width: 100%;
background: var(--card-body);
border-radius: 6px;
padding: 24px;
font-family: $inter;

.card-info__title,
.card-info__detail-title {
font-size: 12px;
font-weight: 500;
color: var(--card-color);
}

.card-info__value,
.card-info__detail-value {
cursor: pointer;
font-weight: 500;
color: var(--body-color);
}

.card-info--header-title {
margin-bottom: 6px;
display: flex;
align-items: center;
}

.card-info--tooltip {
margin-left: 6px;

.material-icons {
font-size: 18px;
color: #b0bfd9;
padding-left: 5px;
}

.tooltip {
height: 18px;
}
}

.card-info__value-wrap {
display: flex;
flex-flow: row nowrap;
}

.card-info__value {
font-size: 20px;
}

.card-info__copy {
display: flex;
align-items: center;
margin-left: 6px;
}

.card-info__details-divider {
margin-top: 16px;
border-top: 1px solid $gray-3;
}

.card-info__details {
display: flex;
flex-direction: column;
gap: 16px;
}

.card-info__detail {
display: flex;
flex-flow: row nowrap;
align-items: center;
justify-content: space-between;
gap: 8px;
}

.card-info__detail-value {
font-size: 12px;
display: flex;
flex-flow: row nowrap;
color: var(--body-color);
}
}
84 changes: 84 additions & 0 deletions client/src/app/components/CardInfo.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
import React from "react";
import CopyButton from "~app/components/CopyButton";
import Tooltip from "~app/components/Tooltip";
import classNames from "classnames";

import "./CardInfo.scss";

export interface CardInfoDetail {
title: string;
value?: number | string | null;
onClickValue?: () => void;
copyValue?: string;
}

interface CardInfoProps {
/**
* The title of the card.
*/
title: string;
tooltip?: string;
value?: number | string | null;
onClickValue?: () => void;
copyValue?: string;
details?: (CardInfoDetail | null)[];
options?: {
headerDirectionRow?: boolean;
};
}

export const CardInfo = ({ options, details, tooltip, title, value, onClickValue = () => {}, copyValue }: CardInfoProps) => {
const detailsFiltered = (details?.filter((i) => i !== null) as CardInfoDetail[]) || [];

return (
<div className="card-info">
<div className={classNames("card-info--header", { "row middle space-between": !!options?.headerDirectionRow })}>
<div className="card-info--header-title">
<div className="card-info__title">{title}</div>
{!!tooltip && (
<div className="card-info--tooltip">
<Tooltip tooltipContent={tooltip}>
<span className="material-icons">info</span>
</Tooltip>
</div>
)}
</div>
<div className="card-info__value-wrap" onClick={onClickValue}>
<div className="card-info__value">{value}</div>
{isValueNotZero(value) && !!copyValue && (
<div className="card-info__copy">
<CopyButton copy={String(copyValue)} />
</div>
)}
</div>
</div>
{!!detailsFiltered.length && (
<div className="card-info__details">
<div className="card-info__details-divider"></div>
{detailsFiltered?.map((detail, idx) => (
<div key={idx + detail.title} className="card-info__detail">
<div className="card-info__detail-title">{detail.title}</div>
<div className="card-info__detail-value" onClick={detail.onClickValue}>
{detail.value !== null ? detail.value : "-"}
{isValueNotZero(detail.value) && !!detail.copyValue && (
<div className="card-info__copy">
<CopyButton copy={String(detail.copyValue)} />
</div>
)}
</div>
</div>
))}
</div>
)}
</div>
);
};

function isValueNotZero(value: number | string | null | undefined): boolean {
if (typeof value === "number") {
return value !== 0;
} else if (typeof value === "string") {
return parseFloat(value) !== 0;
}
return false;
}
32 changes: 17 additions & 15 deletions client/src/app/components/nova/address/AddressBalance.scss
Original file line number Diff line number Diff line change
@@ -1,29 +1,36 @@
@import "../../../../scss/media-queries";

.balance-wrapper {
.balance-wrapper.nova {
display: flex;
flex-direction: row;
align-items: center;
flex-direction: column;
gap: 24px;

.icon {
margin-right: 16px;
}

.balance-wrapper__inner {
.balance-wrapper--row {
display: flex;
flex-direction: column;

flex-direction: row;
gap: 40px;
@include tablet-down {
flex-direction: column;
}
.balance-wrapper__base-token {
margin-bottom: 12px;
}

.balance-wrapper__base-token,
.balance-wrapper__mana {
display: flex;
flex-direction: row;
flex-direction: column;
gap: 20px;
flex: 1;

.balance {
display: flex;
flex-direction: column;
gap: 10px;

.icon {
align-self: center;
Expand All @@ -34,8 +41,6 @@
}

&:not(:last-child) {
margin-right: 40px;

@include tablet-down {
margin-right: 0px;
}
Expand All @@ -60,6 +65,7 @@
.balance-fiat {
color: #b0bfd9;
font-size: 18px;
white-space: nowrap;
}

.balance-heading {
Expand All @@ -74,12 +80,8 @@

.balance__mana {
display: flex;
align-items: center;
margin-left: 8px;

.value {
margin-left: 4px;
}
flex-direction: column;
margin-left: 0;
}
}
}
Expand Down
Loading

0 comments on commit ee7cfe1

Please sign in to comment.