-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'dev' into fix/expired-assets-nova
- Loading branch information
Showing
5 changed files
with
352 additions
and
216 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
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); | ||
} | ||
} |
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,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; | ||
} |
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
Oops, something went wrong.