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
b827b27b
Commit
b827b27b
authored
Aug 24, 2023
by
tom
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
noLink prop for entities
parent
98ec03cd
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
35 additions
and
20 deletions
+35
-20
AddressEntity.pw.tsx
ui/shared/entities/address/AddressEntity.pw.tsx
+13
-0
AddressEntity.tsx
ui/shared/entities/address/AddressEntity.tsx
+1
-3
AddressEntity.pw.tsx_default_no-link-1.png
..._screenshots__/AddressEntity.pw.tsx_default_no-link-1.png
+0
-0
components.tsx
ui/shared/entities/base/components.tsx
+19
-11
TokenEntity.tsx
ui/shared/entities/token/TokenEntity.tsx
+1
-3
TxEntity.tsx
ui/shared/entities/tx/TxEntity.tsx
+1
-3
No files found.
ui/shared/entities/address/AddressEntity.pw.tsx
View file @
b827b27b
...
@@ -95,6 +95,19 @@ test('external link', async({ mount }) => {
...
@@ -95,6 +95,19 @@ test('external link', async({ mount }) => {
await
expect
(
component
).
toHaveScreenshot
();
await
expect
(
component
).
toHaveScreenshot
();
});
});
test
(
'
no link
'
,
async
({
mount
})
=>
{
const
component
=
await
mount
(
<
TestApp
>
<
AddressEntity
address=
{
addressMock
.
withoutName
}
noLink
/>
</
TestApp
>,
);
await
expect
(
component
).
toHaveScreenshot
();
});
test
(
'
customization
'
,
async
({
mount
})
=>
{
test
(
'
customization
'
,
async
({
mount
})
=>
{
const
component
=
await
mount
(
const
component
=
await
mount
(
<
TestApp
>
<
TestApp
>
...
...
ui/shared/entities/address/AddressEntity.tsx
View file @
b827b27b
...
@@ -14,9 +14,7 @@ import * as EntityBase from 'ui/shared/entities/base/components';
...
@@ -14,9 +14,7 @@ import * as EntityBase from 'ui/shared/entities/base/components';
import
{
getIconProps
}
from
'
../base/utils
'
;
import
{
getIconProps
}
from
'
../base/utils
'
;
interface
LinkProps
extends
Pick
<
EntityProps
,
'
className
'
|
'
address
'
|
'
onClick
'
|
'
isLoading
'
|
'
isExternal
'
|
'
href
'
|
'
query
'
>
{
type
LinkProps
=
EntityBase
.
LinkBaseProps
&
Pick
<
EntityProps
,
'
address
'
>
;
children
:
React
.
ReactNode
;
}
const
Link
=
chakra
((
props
:
LinkProps
)
=>
{
const
Link
=
chakra
((
props
:
LinkProps
)
=>
{
const
defaultHref
=
route
({
pathname
:
'
/address/[hash]
'
,
query
:
{
...
props
.
query
,
hash
:
props
.
address
.
hash
}
});
const
defaultHref
=
route
({
pathname
:
'
/address/[hash]
'
,
query
:
{
...
props
.
query
,
hash
:
props
.
address
.
hash
}
});
...
...
ui/shared/entities/address/__screenshots__/AddressEntity.pw.tsx_default_no-link-1.png
0 → 100644
View file @
b827b27b
3.12 KB
ui/shared/entities/base/components.tsx
View file @
b827b27b
...
@@ -14,17 +14,17 @@ import { getIconProps, type IconSize } from './utils';
...
@@ -14,17 +14,17 @@ import { getIconProps, type IconSize } from './utils';
export
type
Truncation
=
'
constant
'
|
'
dynamic
'
|
'
tail
'
|
'
none
'
;
export
type
Truncation
=
'
constant
'
|
'
dynamic
'
|
'
tail
'
|
'
none
'
;
// TODO @tom2drum add disabled link props
export
interface
EntityBaseProps
{
export
interface
EntityBaseProps
{
className
?:
string
;
className
?:
string
;
isLoading
?:
boolean
;
href
?:
string
;
iconSize
?:
IconSize
;
iconSize
?:
IconSize
;
onClick
?:
(
event
:
React
.
MouseEvent
<
HTMLAnchorElement
>
)
=>
void
;
isExternal
?:
boolean
;
isExternal
?:
boolean
;
href
?:
string
;
isLoading
?:
boolean
;
query
?:
Record
<
string
,
string
>
;
noIcon
?:
boolean
;
noCopy
?:
boolean
;
noCopy
?:
boolean
;
noIcon
?:
boolean
;
noLink
?:
boolean
;
onClick
?:
(
event
:
React
.
MouseEvent
<
HTMLAnchorElement
>
)
=>
void
;
query
?:
Record
<
string
,
string
>
;
tailLength
?:
number
;
tailLength
?:
number
;
truncation
?:
Truncation
;
truncation
?:
Truncation
;
}
}
...
@@ -45,21 +45,29 @@ const Container = chakra(({ className, children }: ContainerBaseProps) => {
...
@@ -45,21 +45,29 @@ const Container = chakra(({ className, children }: ContainerBaseProps) => {
);
);
});
});
export
interface
LinkBaseProps
extends
Pick
<
EntityBaseProps
,
'
className
'
|
'
onClick
'
|
'
isLoading
'
|
'
isExternal
'
|
'
href
'
>
{
export
interface
LinkBaseProps
extends
Pick
<
EntityBaseProps
,
'
className
'
|
'
onClick
'
|
'
isLoading
'
|
'
isExternal
'
|
'
href
'
|
'
noLink
'
|
'
query
'
>
{
children
:
React
.
ReactNode
;
children
:
React
.
ReactNode
;
}
}
const
Link
=
chakra
(({
isLoading
,
children
,
isExternal
,
onClick
,
href
}:
LinkBaseProps
)
=>
{
const
Link
=
chakra
(({
isLoading
,
children
,
isExternal
,
onClick
,
href
,
noLink
}:
LinkBaseProps
)
=>
{
const
styles
=
{
display
:
'
inline-flex
'
,
alignItems
:
'
center
'
,
minWidth
:
0
,
// for content truncation - https://css-tricks.com/flexbox-truncated-text/
};
if
(
noLink
)
{
return
<
Skeleton
isLoaded=
{
!
isLoading
}
{
...
styles
}
>
{
children
}
</
Skeleton
>;
}
const
Component
=
isExternal
?
LinkExternal
:
LinkInternal
;
const
Component
=
isExternal
?
LinkExternal
:
LinkInternal
;
return
(
return
(
<
Component
<
Component
{
...
styles
}
href=
{
href
}
href=
{
href
}
isLoading=
{
isLoading
}
isLoading=
{
isLoading
}
onClick=
{
onClick
}
onClick=
{
onClick
}
display=
"inline-flex"
alignItems=
"center"
minWidth=
{
0
}
// for content truncation - https://css-tricks.com/flexbox-truncated-text/
>
>
{
children
}
{
children
}
</
Component
>
</
Component
>
...
...
ui/shared/entities/token/TokenEntity.tsx
View file @
b827b27b
...
@@ -13,9 +13,7 @@ import TruncatedTextTooltip from 'ui/shared/TruncatedTextTooltip';
...
@@ -13,9 +13,7 @@ import TruncatedTextTooltip from 'ui/shared/TruncatedTextTooltip';
import
{
getIconProps
}
from
'
../base/utils
'
;
import
{
getIconProps
}
from
'
../base/utils
'
;
interface
LinkProps
extends
Pick
<
EntityProps
,
'
className
'
|
'
token
'
|
'
onClick
'
|
'
isLoading
'
|
'
isExternal
'
|
'
href
'
|
'
query
'
>
{
type
LinkProps
=
EntityBase
.
LinkBaseProps
&
Pick
<
EntityProps
,
'
token
'
>
;
children
:
React
.
ReactNode
;
}
const
Link
=
chakra
((
props
:
LinkProps
)
=>
{
const
Link
=
chakra
((
props
:
LinkProps
)
=>
{
const
defaultHref
=
route
({
pathname
:
'
/token/[hash]
'
,
query
:
{
...
props
.
query
,
hash
:
props
.
token
.
address
}
});
const
defaultHref
=
route
({
pathname
:
'
/token/[hash]
'
,
query
:
{
...
props
.
query
,
hash
:
props
.
token
.
address
}
});
...
...
ui/shared/entities/tx/TxEntity.tsx
View file @
b827b27b
...
@@ -8,9 +8,7 @@ import { route } from 'nextjs-routes';
...
@@ -8,9 +8,7 @@ import { route } from 'nextjs-routes';
import
transactionIcon
from
'
icons/transactions_slim.svg
'
;
import
transactionIcon
from
'
icons/transactions_slim.svg
'
;
import
*
as
EntityBase
from
'
ui/shared/entities/base/components
'
;
import
*
as
EntityBase
from
'
ui/shared/entities/base/components
'
;
interface
LinkProps
extends
Pick
<
EntityProps
,
'
className
'
|
'
hash
'
|
'
onClick
'
|
'
isLoading
'
|
'
isExternal
'
|
'
href
'
>
{
type
LinkProps
=
EntityBase
.
LinkBaseProps
&
Pick
<
EntityProps
,
'
hash
'
>
;
children
:
React
.
ReactNode
;
}
const
Link
=
chakra
((
props
:
LinkProps
)
=>
{
const
Link
=
chakra
((
props
:
LinkProps
)
=>
{
const
defaultHref
=
route
({
pathname
:
'
/tx/[hash]
'
,
query
:
{
hash
:
props
.
hash
}
});
const
defaultHref
=
route
({
pathname
:
'
/tx/[hash]
'
,
query
:
{
hash
:
props
.
hash
}
});
...
...
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