Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
F
frontend
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
vicotor
frontend
Commits
301dceb1
Commit
301dceb1
authored
Jun 21, 2023
by
tom
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
display NFT app link even if url is not full and highlight link to ipfs
parent
3d771944
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
32 additions
and
10 deletions
+32
-10
regexp.ts
lib/regexp.ts
+3
-0
urlParser.ts
lib/token/metadata/urlParser.ts
+17
-0
tokenInstance.ts
mocks/tokens/tokenInstance.ts
+1
-1
TokenInstance.tsx
ui/pages/TokenInstance.tsx
+7
-3
TokenInstanceMetadata.pw.tsx_default_base-view-mobile-1.png
...kenInstanceMetadata.pw.tsx_default_base-view-mobile-1.png
+0
-0
TokenInstanceMetadata.pw.tsx_mobile_base-view-mobile-1.png
...okenInstanceMetadata.pw.tsx_mobile_base-view-mobile-1.png
+0
-0
MetadataItemPrimitive.tsx
ui/tokenInstance/metadata/MetadataItemPrimitive.tsx
+4
-6
No files found.
lib/regexp.ts
0 → 100644
View file @
301dceb1
export
const
URL_PREFIX
=
/^https
?
:
\/\/
/i
;
export
const
IPFS_PREFIX
=
/^ipfs:
\/\/
/i
;
lib/token/metadata/urlParser.ts
0 → 100644
View file @
301dceb1
import
*
as
regexp
from
'
lib/regexp
'
;
export
default
function
urlParser
(
maybeUrl
:
string
):
URL
|
undefined
{
try
{
return
constructUrl
(
maybeUrl
);
}
catch
(
error
)
{}
}
function
constructUrl
(
maybeUrl
:
string
)
{
if
(
regexp
.
IPFS_PREFIX
.
test
(
maybeUrl
))
{
return
new
URL
(
maybeUrl
.
replace
(
regexp
.
IPFS_PREFIX
,
'
https://ipfs.io/ipfs/
'
));
}
if
(
regexp
.
URL_PREFIX
.
test
(
maybeUrl
))
{
return
new
URL
(
maybeUrl
);
}
}
mocks/tokens/tokenInstance.ts
View file @
301dceb1
...
@@ -171,7 +171,7 @@ export const withRichMetadata: TokenInstance = {
...
@@ -171,7 +171,7 @@ export const withRichMetadata: TokenInstance = {
token_id
:
'
7741920
'
,
token_id
:
'
7741920
'
,
serial_total
:
1100
,
serial_total
:
1100
,
blockchain_state
:
'
BURNING
'
,
blockchain_state
:
'
BURNING
'
,
image
:
'
https://nftu.com/nft-content/media/PAPAYA/92ee5f5c-bce9-4d64-8a25-c7e1e6305572
/dee8734bbefb0d63d6156b6fa0e1385822480589daa1862cbd37a94f6bc2ba3a
'
,
image
:
'
ipfs:/
/dee8734bbefb0d63d6156b6fa0e1385822480589daa1862cbd37a94f6bc2ba3a
'
,
revealed_nfts
:
null
,
revealed_nfts
:
null
,
nft_data_id
:
'
92ee5f5c-bce9-4d64-8a25-c7e1e6305572
'
,
nft_data_id
:
'
92ee5f5c-bce9-4d64-8a25-c7e1e6305572
'
,
series
:
'
Tip-Off
'
,
series
:
'
Tip-Off
'
,
...
...
ui/pages/TokenInstance.tsx
View file @
301dceb1
...
@@ -9,6 +9,7 @@ import nftIcon from 'icons/nft_shield.svg';
...
@@ -9,6 +9,7 @@ import nftIcon from 'icons/nft_shield.svg';
import
useApiQuery
from
'
lib/api/useApiQuery
'
;
import
useApiQuery
from
'
lib/api/useApiQuery
'
;
import
{
useAppContext
}
from
'
lib/contexts/app
'
;
import
{
useAppContext
}
from
'
lib/contexts/app
'
;
import
useIsMobile
from
'
lib/hooks/useIsMobile
'
;
import
useIsMobile
from
'
lib/hooks/useIsMobile
'
;
import
*
as
regexp
from
'
lib/regexp
'
;
import
{
TOKEN_INSTANCE
}
from
'
stubs/token
'
;
import
{
TOKEN_INSTANCE
}
from
'
stubs/token
'
;
import
*
as
tokenStubs
from
'
stubs/token
'
;
import
*
as
tokenStubs
from
'
stubs/token
'
;
import
{
generateListStub
}
from
'
stubs/utils
'
;
import
{
generateListStub
}
from
'
stubs/utils
'
;
...
@@ -124,12 +125,15 @@ const TokenInstanceContent = () => {
...
@@ -124,12 +125,15 @@ const TokenInstanceContent = () => {
}
}
try
{
try
{
const
url
=
new
URL
(
tokenInstanceQuery
.
data
.
external_app_url
);
const
url
=
regexp
.
URL_PREFIX
.
test
(
tokenInstanceQuery
.
data
.
external_app_url
)
?
new
URL
(
tokenInstanceQuery
.
data
.
external_app_url
)
:
new
URL
(
'
https://
'
+
tokenInstanceQuery
.
data
.
external_app_url
);
return
(
return
(
<
Skeleton
isLoaded=
{
!
tokenInstanceQuery
.
isPlaceholderData
}
display=
"inline-block"
fontSize=
"sm"
mt=
{
6
}
>
<
Skeleton
isLoaded=
{
!
tokenInstanceQuery
.
isPlaceholderData
}
display=
"inline-block"
fontSize=
"sm"
mt=
{
6
}
>
<
span
>
View in app
</
span
>
<
span
>
View in app
</
span
>
<
LinkExternal
href=
{
tokenInstanceQuery
.
data
.
external_app_url
}
>
<
LinkExternal
href=
{
url
.
toString
()
}
>
{
url
.
hostname
}
{
url
.
hostname
||
tokenInstanceQuery
.
data
.
external_app_url
}
</
LinkExternal
>
</
LinkExternal
>
</
Skeleton
>
</
Skeleton
>
);
);
...
...
ui/tokenInstance/__screenshots__/TokenInstanceMetadata.pw.tsx_default_base-view-mobile-1.png
View replaced file @
3d771944
View file @
301dceb1
210 KB
|
W:
|
H:
207 KB
|
W:
|
H:
2-up
Swipe
Onion skin
ui/tokenInstance/__screenshots__/TokenInstanceMetadata.pw.tsx_mobile_base-view-mobile-1.png
View replaced file @
3d771944
View file @
301dceb1
181 KB
|
W:
|
H:
178 KB
|
W:
|
H:
2-up
Swipe
Onion skin
ui/tokenInstance/metadata/MetadataItemPrimitive.tsx
View file @
301dceb1
...
@@ -2,6 +2,7 @@ import { Box } from '@chakra-ui/react';
...
@@ -2,6 +2,7 @@ import { Box } from '@chakra-ui/react';
import
React
from
'
react
'
;
import
React
from
'
react
'
;
import
type
{
Primitive
}
from
'
react-hook-form
'
;
import
type
{
Primitive
}
from
'
react-hook-form
'
;
import
urlParser
from
'
lib/token/metadata/urlParser
'
;
import
LinkExternal
from
'
ui/shared/LinkExternal
'
;
import
LinkExternal
from
'
ui/shared/LinkExternal
'
;
import
MetadataAccordionItem
from
'
./MetadataAccordionItem
'
;
import
MetadataAccordionItem
from
'
./MetadataAccordionItem
'
;
...
@@ -22,13 +23,10 @@ const MetadataItemPrimitive = ({ name, value, isItem = true, isFlat, level }: Pr
...
@@ -22,13 +23,10 @@ const MetadataItemPrimitive = ({ name, value, isItem = true, isFlat, level }: Pr
const
content
=
(()
=>
{
const
content
=
(()
=>
{
switch
(
typeof
value
)
{
switch
(
typeof
value
)
{
case
'
string
'
:
{
case
'
string
'
:
{
try
{
const
url
=
urlParser
(
value
);
if
(
!
value
.
includes
(
'
http
'
))
{
if
(
url
)
{
throw
new
Error
();
}
const
url
=
new
URL
(
value
);
return
<
LinkExternal
href=
{
url
.
toString
()
}
>
{
value
}
</
LinkExternal
>;
return
<
LinkExternal
href=
{
url
.
toString
()
}
>
{
value
}
</
LinkExternal
>;
}
catch
(
error
)
{}
}
}
}
// eslint-disable-next-line no-fallthrough
// eslint-disable-next-line no-fallthrough
default
:
{
default
:
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment