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

Chore: Polish Nova Output Page #1318

Merged
merged 19 commits into from
Mar 27, 2024
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
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
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,12 @@ import classNames from "classnames";
import React, { useState } from "react";
import AddressView from "./address/AddressView";
import DropdownIcon from "~assets/dropdown-arrow.svg?react";
import DataToggle from "../DataToggle";
import DataToggle from "~/app/components/DataToggle";
import { useNetworkInfoNova } from "~/helpers/nova/networkInfo";
import { formatAmount } from "~/helpers/stardust/valueFormatHelper";
import TruncatedId from "~/app/components/stardust/TruncatedId";
import Tooltip from "~/app/components/Tooltip";
import { EPOCH_HINT } from "./OutputView";

interface FeatureViewProps {
/**
Expand All @@ -34,6 +39,7 @@ interface FeatureViewProps {
}

const FeatureView: React.FC<FeatureViewProps> = ({ feature, isImmutable, isPreExpanded }) => {
const { name: network, tokenInfo, manaInfo } = useNetworkInfoNova((s) => s.networkInfo);
const [isExpanded, setIsExpanded] = useState<boolean>(isPreExpanded ?? false);

return (
Expand Down Expand Up @@ -89,13 +95,42 @@ const FeatureView: React.FC<FeatureViewProps> = ({ feature, isImmutable, isPreEx
{feature.type === FeatureType.Staking && (
<div className="padding-l-t left-border">
<div className="card--label">Staked amount:</div>
<div className="card--value row">{Number((feature as StakingFeature).stakedAmount)}</div>
<div className="card--value row">
{formatAmount((feature as StakingFeature).stakedAmount, tokenInfo, false)}
</div>
<div className="card--label">Fixed cost:</div>
<div className="card--value row">{Number((feature as StakingFeature).fixedCost)}</div>
<div className="card--value row">{formatAmount((feature as StakingFeature).fixedCost, manaInfo, false)}</div>
<div className="card--label">Start epoch:</div>
<div className="card--value row">{Number((feature as StakingFeature).startEpoch)}</div>
<div className="card--value row">
<TruncatedId
id={String((feature as StakingFeature).startEpoch)}
link={
(feature as StakingFeature).startEpoch === 0
? undefined
: `/${network}/epoch/${(feature as StakingFeature).startEpoch}`
}
showCopyButton={false}
/>
</div>
<div className="card--label">End epoch:</div>
<div className="card--value row">{Number((feature as StakingFeature).endEpoch)}</div>
<div className="card--value row epoch-info epoch-info--above">
<TruncatedId
id={String((feature as StakingFeature).endEpoch)}
link={
(feature as StakingFeature).endEpoch === 0
? undefined
: `/${network}/epoch/${(feature as StakingFeature).endEpoch}`
}
showCopyButton={false}
/>
{(feature as StakingFeature).endEpoch === 0 && (
<Tooltip tooltipContent={EPOCH_HINT}>
<div className="modal--icon margin-t-2">
<span className="material-icons">info</span>
</div>
</Tooltip>
)}
</div>
</div>
)}
</div>
Expand Down
161 changes: 96 additions & 65 deletions client/src/app/components/nova/OutputView.scss
Original file line number Diff line number Diff line change
Expand Up @@ -3,100 +3,131 @@
@import "../../../scss/mixins";
@import "../../../scss/fonts";

.card--content__output {
padding: 0 30px;
margin-bottom: 20px;
.output-page {
.card--content__output {
padding: 0 30px;
margin-bottom: 20px;

@include phone-down {
padding: 0 4px;
}

.card--value.card-header--wrapper {
width: 100%;
display: flex;
margin-bottom: 0px;
height: 32px;
align-items: center;
@include phone-down {
padding: 0 4px;
}

.output-header {
display: flex;
.card--value.card-header--wrapper {
width: 100%;
display: flex;
margin-bottom: 0px;
height: 32px;
align-items: center;

.output-type--name {
white-space: nowrap;
}

.output-id--link {
.output-header {
display: flex;
margin-right: 2px;
white-space: nowrap;
width: 100%;

a {
margin-right: 0px;
.output-type--name {
white-space: nowrap;
}

.highlight {
font-weight: 500;
color: $gray-6;
margin-left: 2px;
.output-id--link {
display: flex;
margin-right: 2px;
white-space: nowrap;

a {
margin-right: 0px;
}

.highlight {
font-weight: 500;
color: $gray-6;
margin-left: 2px;
}

.copy-button {
margin-left: 2px;
}
}
}

.copy-button {
margin-left: 2px;
.amount-size {
width: min-content;
text-align: end;
word-break: normal;
white-space: nowrap;
cursor: pointer;
margin-bottom: 0;
margin-right: 4px;

span {
word-break: keep-all;
}
}
}

.amount-size {
width: min-content;
text-align: end;
word-break: normal;
white-space: nowrap;
cursor: pointer;
margin-bottom: 0;
margin-right: 4px;

span {
word-break: keep-all;
.unlock-condition-icon {
color: #fec900;
font-size: 18px;

&.expired {
color: #ff4800;
}
}
}

.unlock-condition-icon {
color: #fec900;
font-size: 18px;
@media (min-width: #{768px}) and (max-width: #{820px}) {
display: none;
}

&.expired {
color: #ff4800;
@include phone-down {
display: none;
}
}

@media (min-width: #{768px}) and (max-width: #{820px}) {
display: none;
.left-border {
border-left: 1px solid var(--border-color);
}
}

@include phone-down {
display: none;
.card--content--dropdown {
margin-right: 8px;
cursor: pointer;

svg {
transition: transform 0.25s ease;

path {
fill: var(--card-color);
}
}
}

.left-border {
border-left: 1px solid var(--border-color);
&.opened > svg {
transform: rotate(90deg);
}
}
}

.card--content--dropdown {
margin-right: 8px;
cursor: pointer;

svg {
transition: transform 0.25s ease;
.epoch-info {
.material-icons {
margin-top: 6px;
padding-left: 5px;
font-size: 18px;
color: #b0bfd9;
}

path {
fill: var(--card-color);
.tooltip .wrap {
width: 230px !important;
.arrow {
left: 8px !important;
margin-left: 0 !important;
&--down {
top: 95%;
}
}
}

&.opened > svg {
transform: rotate(90deg);
&--above {
.tooltip .wrap {
top: -416%;
.arrow {
top: 94%;
}
}
}
}
58 changes: 47 additions & 11 deletions client/src/app/components/nova/OutputView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import { IPreExpandedConfig } from "~models/components";
import CopyButton from "../CopyButton";
import Tooltip from "../Tooltip";
import TruncatedId from "../stardust/TruncatedId";
import FeatureView from "./FeaturesView";
import FeatureView from "./FeatureView";
import KeyValueEntries from "./KeyValueEntries";
import "./OutputView.scss";
import UnlockConditionView from "./UnlockConditionView";
Expand All @@ -48,7 +48,11 @@ interface OutputViewProps {
manaDetails?: OutputManaDetails | null;
}

export const EPOCH_HINT =
"When the end epoch is set to 0, it indicates that no specific end epoch has been defined for this delegation output.";

const OutputView: React.FC<OutputViewProps> = ({ outputId, output, showCopyAmount, preExpandedConfig, isLinksDisabled, manaDetails }) => {
const { manaInfo } = useNetworkInfoNova((s) => s.networkInfo);
const [isExpanded, setIsExpanded] = useState(preExpandedConfig?.isAllPreExpanded ?? preExpandedConfig?.isPreExpanded ?? false);
const [isFormattedBalance, setIsFormattedBalance] = useState(true);
const { bech32Hrp, name: network, protocolInfo, tokenInfo } = useNetworkInfoNova((s) => s.networkInfo);
Expand All @@ -57,8 +61,10 @@ const OutputView: React.FC<OutputViewProps> = ({ outputId, output, showCopyAmoun
const accountOrNftBech32 = buildAddressForAccountOrNft(outputId, output, bech32Hrp);
const outputIdTransactionPart = `${outputId.slice(0, 8)}....${outputId.slice(-8, -4)}`;
const outputIdIndexPart = outputId.slice(-4);
const manaEntries = manaDetails ? getManaKeyValueEntries(manaDetails) : undefined;
const manaEntries = manaDetails ? getManaKeyValueEntries(manaDetails, manaInfo, output.type === OutputType.Delegation) : undefined;
const isSpecialCondition = hasSpecialCondition(output as CommonOutput);
const validatorAddress =
output.type === OutputType.Delegation ? Utils.addressToBech32((output as DelegationOutput).validatorAddress, bech32Hrp) : "";

useEffect(() => {
setIsExpanded(preExpandedConfig?.isAllPreExpanded ?? preExpandedConfig?.isPreExpanded ?? isExpanded ?? false);
Expand Down Expand Up @@ -196,24 +202,54 @@ const OutputView: React.FC<OutputViewProps> = ({ outputId, output, showCopyAmoun
)}
</React.Fragment>
)}
{(output.type === OutputType.Basic ||
output.type === OutputType.Account ||
output.type === OutputType.Anchor ||
output.type === OutputType.Nft) &&
manaEntries &&
manaDetails?.totalMana && <KeyValueEntries isPreExpanded={true} {...manaEntries} />}
{output.type !== OutputType.Foundry && manaEntries && manaDetails?.totalMana && (
<KeyValueEntries isPreExpanded={true} {...manaEntries} />
)}
{output.type === OutputType.Delegation && (
<React.Fragment>
<div className="card--label">Delegated amount:</div>
<div className="card--value row">{Number((output as DelegationOutput).delegatedAmount)}</div>
<div className="card--label">Delegation Id:</div>
<div className="card--value row">{(output as DelegationOutput).delegationId}</div>
<div className="card--label">Validator Address:</div>
<div className="card--value row">{Utils.addressToBech32((output as DelegationOutput).validatorAddress, bech32Hrp)}</div>
<div className="card--value row">
<TruncatedId
id={validatorAddress}
link={isLinksDisabled ? undefined : `/${network}/addr/${validatorAddress}`}
showCopyButton
/>
</div>
<div className="card--label">Start epoch:</div>
<div className="card--value row">{(output as DelegationOutput).startEpoch}</div>
<div className="card--value row">
<TruncatedId
id={(output as DelegationOutput).startEpoch.toString()}
link={
isLinksDisabled || (output as DelegationOutput).startEpoch === 0
? undefined
: `/${network}/epoch/${(output as DelegationOutput).startEpoch}`
}
showCopyButton={false}
/>
</div>
<div className="card--label">End epoch:</div>
<div className="card--value row">{(output as DelegationOutput).endEpoch}</div>
<div className="card--value row epoch-info">
<TruncatedId
id={(output as DelegationOutput).endEpoch.toString()}
link={
isLinksDisabled || (output as DelegationOutput).endEpoch === 0
? undefined
: `/${network}/epoch/${(output as DelegationOutput).endEpoch}`
}
showCopyButton={false}
/>
{(output as DelegationOutput).endEpoch === 0 && (
<Tooltip tooltipContent={EPOCH_HINT}>
<div className="modal--icon">
<span className="material-icons">info</span>
</div>
</Tooltip>
)}
</div>
</React.Fragment>
)}
</React.Fragment>
Expand Down
2 changes: 1 addition & 1 deletion client/src/app/components/nova/address/FeaturesSection.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { AccountOutput, FoundryOutput, NftOutput } from "@iota/sdk-wasm-nova/web";
import { optional } from "@ruffy/ts-optional";
import React from "react";
import FeatureView from "../FeaturesView";
import FeatureView from "../FeatureView";

interface FeaturesSectionProps {
/**
Expand Down
Loading
Loading