Skip to content

Commit

Permalink
Do not display empty NFT attributes
Browse files Browse the repository at this point in the history
Fixes #2337
  • Loading branch information
tom2drum committed Oct 31, 2024
1 parent d5863de commit 9dccf19
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 5 deletions.
2 changes: 1 addition & 1 deletion ui/shared/TruncatedValue.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const TruncatedValue = ({ className, isLoading, value, tooltipPlacement }: Props
textOverflow="ellipsis"
height="fit-content"
>
{ value }
<span>{ value }</span>
</Skeleton>
</TruncatedTextTooltip>
);
Expand Down
17 changes: 13 additions & 4 deletions ui/tokenInstance/details/TokenInstanceMetadataInfo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,16 @@ const Item = ({ data, isLoading }: ItemProps) => {
flexDir="column"
alignItems="flex-start"
>
<Skeleton isLoaded={ !isLoading } fontSize="xs" lineHeight={ 4 } color="text_secondary" fontWeight={ 500 } mb={ 1 }>
<span>{ data.trait_type }</span>
</Skeleton>
<TruncatedValue
value={ data.trait_type }
fontSize="xs"
w="100%"
lineHeight={ 4 }
color="text_secondary"
fontWeight={ 500 }
mb={ 1 }
isLoading={ isLoading }
/>
{ value }
</GridItem>
);
Expand Down Expand Up @@ -126,7 +133,9 @@ const TokenInstanceMetadataInfo = ({ data, isLoading: isLoadingProp }: Props) =>
</DetailsInfoItem.Label>
<DetailsInfoItem.Value>
<Grid gap={ 2 } templateColumns="repeat(auto-fill,minmax(160px, 1fr))" w="100%" whiteSpace="normal">
{ metadata.attributes.map((attribute, index) => <Item key={ index } data={ attribute } isLoading={ isLoading }/>) }
{ metadata.attributes
.filter((attribute) => attribute.value)
.map((attribute, index) => <Item key={ index } data={ attribute } isLoading={ isLoading }/>) }
</Grid>
</DetailsInfoItem.Value>
</>
Expand Down
3 changes: 3 additions & 0 deletions ui/tokenInstance/metadata/MetadataItemPrimitive.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ const MetadataItemPrimitive = ({ name, value, isItem = true, isFlat, level }: Pr
if (url) {
return <LinkExternal href={ url.toString() }>{ value }</LinkExternal>;
}
if (value === '') {
return <div>&quot;&quot;</div>;
}
}
// eslint-disable-next-line no-fallthrough
default: {
Expand Down

0 comments on commit 9dccf19

Please sign in to comment.