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
1df3a163
Commit
1df3a163
authored
Sep 27, 2024
by
isstuev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
change mobile page titke for the chart
parent
3df4bd4f
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
68 additions
and
65 deletions
+68
-65
AddressCoinBalance.pw.tsx
ui/address/AddressCoinBalance.pw.tsx
+18
-2
AddressCoinBalance.pw.tsx_dark-color-mode_base-view-dark-mode-1.png
...nBalance.pw.tsx_dark-color-mode_base-view-dark-mode-1.png
+0
-0
AddressCoinBalance.pw.tsx_default_base-view-dark-mode-1.png
...dressCoinBalance.pw.tsx_default_base-view-dark-mode-1.png
+0
-0
AddressCoinBalance.pw.tsx_default_base-view-dark-mode-mobile-1.png
...inBalance.pw.tsx_default_base-view-dark-mode-mobile-1.png
+0
-0
AddressCoinBalance.pw.tsx_default_mobile-base-view-1.png
.../AddressCoinBalance.pw.tsx_default_mobile-base-view-1.png
+0
-0
Chart.tsx
ui/pages/Chart.tsx
+44
-53
Chart.pw.tsx_mobile_base-view-dark-mode-mobile-1.png
...ts__/Chart.pw.tsx_mobile_base-view-dark-mode-mobile-1.png
+0
-0
ChartMenu.tsx
ui/shared/chart/ChartMenu.tsx
+3
-8
ChartWidget.tsx
ui/shared/chart/ChartWidget.tsx
+3
-2
No files found.
ui/address/AddressCoinBalance.pw.tsx
View file @
1df3a163
import
React
from
'
react
'
;
import
React
from
'
react
'
;
import
*
as
balanceHistoryMock
from
'
mocks/address/coinBalanceHistory
'
;
import
*
as
balanceHistoryMock
from
'
mocks/address/coinBalanceHistory
'
;
import
{
test
,
expect
}
from
'
playwright/lib
'
;
import
{
test
,
expect
,
devices
}
from
'
playwright/lib
'
;
import
AddressCoinBalance
from
'
./AddressCoinBalance
'
;
import
AddressCoinBalance
from
'
./AddressCoinBalance
'
;
...
@@ -12,7 +12,7 @@ const hooksConfig = {
...
@@ -12,7 +12,7 @@ const hooksConfig = {
},
},
};
};
test
(
'
base view +@dark-mode
+@mobile
'
,
async
({
render
,
page
,
mockApiResponse
})
=>
{
test
(
'
base view +@dark-mode
'
,
async
({
render
,
page
,
mockApiResponse
})
=>
{
await
mockApiResponse
(
'
address_coin_balance
'
,
balanceHistoryMock
.
baseResponse
,
{
pathParams
:
{
hash
:
addressHash
}
});
await
mockApiResponse
(
'
address_coin_balance
'
,
balanceHistoryMock
.
baseResponse
,
{
pathParams
:
{
hash
:
addressHash
}
});
await
mockApiResponse
(
'
address_coin_balance_chart
'
,
balanceHistoryMock
.
chartResponse
,
{
pathParams
:
{
hash
:
addressHash
}
});
await
mockApiResponse
(
'
address_coin_balance_chart
'
,
balanceHistoryMock
.
chartResponse
,
{
pathParams
:
{
hash
:
addressHash
}
});
const
component
=
await
render
(<
AddressCoinBalance
/>,
{
hooksConfig
});
const
component
=
await
render
(<
AddressCoinBalance
/>,
{
hooksConfig
});
...
@@ -23,3 +23,19 @@ test('base view +@dark-mode +@mobile', async({ render, page, mockApiResponse })
...
@@ -23,3 +23,19 @@ test('base view +@dark-mode +@mobile', async({ render, page, mockApiResponse })
await
page
.
mouse
.
move
(
240
,
100
);
await
page
.
mouse
.
move
(
240
,
100
);
await
expect
(
component
).
toHaveScreenshot
();
await
expect
(
component
).
toHaveScreenshot
();
});
});
test
.
describe
(
'
mobile
'
,
()
=>
{
test
.
use
({
viewport
:
devices
[
'
iPhone 13 Pro
'
].
viewport
});
test
(
'
base view
'
,
async
({
render
,
page
,
mockApiResponse
})
=>
{
await
mockApiResponse
(
'
address_coin_balance
'
,
balanceHistoryMock
.
baseResponse
,
{
pathParams
:
{
hash
:
addressHash
}
});
await
mockApiResponse
(
'
address_coin_balance_chart
'
,
balanceHistoryMock
.
chartResponse
,
{
pathParams
:
{
hash
:
addressHash
}
});
const
component
=
await
render
(<
AddressCoinBalance
/>,
{
hooksConfig
});
await
page
.
waitForFunction
(()
=>
{
return
document
.
querySelector
(
'
path[data-name="chart-Balances-small"]
'
)?.
getAttribute
(
'
opacity
'
)
===
'
1
'
;
});
await
page
.
mouse
.
move
(
100
,
100
);
await
page
.
mouse
.
move
(
240
,
100
);
await
expect
(
component
).
toHaveScreenshot
();
});
});
ui/address/__screenshots__/AddressCoinBalance.pw.tsx_dark-color-mode_base-view-dark-mode-
mobile-
1.png
→
ui/address/__screenshots__/AddressCoinBalance.pw.tsx_dark-color-mode_base-view-dark-mode-1.png
View file @
1df3a163
File moved
ui/address/__screenshots__/AddressCoinBalance.pw.tsx_default_base-view-dark-mode-1.png
0 → 100644
View file @
1df3a163
55.1 KB
ui/address/__screenshots__/AddressCoinBalance.pw.tsx_default_base-view-dark-mode-mobile-1.png
deleted
100644 → 0
View file @
3df4bd4f
55.1 KB
ui/address/__screenshots__/AddressCoinBalance.pw.tsx_default_mobile-base-view-1.png
0 → 100644
View file @
1df3a163
47.2 KB
ui/pages/Chart.tsx
View file @
1df3a163
import
{
Button
,
Flex
,
IconButton
,
Link
,
Text
}
from
'
@chakra-ui/react
'
;
import
{
Button
,
Flex
,
Link
,
Text
}
from
'
@chakra-ui/react
'
;
import
type
{
NextRouter
}
from
'
next/router
'
;
import
type
{
NextRouter
}
from
'
next/router
'
;
import
{
useRouter
}
from
'
next/router
'
;
import
{
useRouter
}
from
'
next/router
'
;
import
React
from
'
react
'
;
import
React
from
'
react
'
;
...
@@ -95,10 +95,14 @@ const Chart = () => {
...
@@ -95,10 +95,14 @@ const Chart = () => {
const
onIntervalChange
=
React
.
useCallback
((
interval
:
StatsIntervalIds
)
=>
{
const
onIntervalChange
=
React
.
useCallback
((
interval
:
StatsIntervalIds
)
=>
{
setIntervalState
(
interval
);
setIntervalState
(
interval
);
router
.
push
({
router
.
push
(
pathname
:
router
.
pathname
,
{
query
:
{
...
router
.
query
,
interval
},
pathname
:
router
.
pathname
,
});
query
:
{
...
router
.
query
,
interval
},
},
undefined
,
{
shallow
:
true
},
);
},
[
setIntervalState
,
router
]);
},
[
setIntervalState
,
router
]);
const
onResolutionChange
=
React
.
useCallback
((
resolution
:
Resolution
)
=>
{
const
onResolutionChange
=
React
.
useCallback
((
resolution
:
Resolution
)
=>
{
...
@@ -143,16 +147,7 @@ const Chart = () => {
...
@@ -143,16 +147,7 @@ const Chart = () => {
const
isInfoLoading
=
!
info
&&
lineQuery
.
isPlaceholderData
;
const
isInfoLoading
=
!
info
&&
lineQuery
.
isPlaceholderData
;
const
shareButton
=
isMobile
?
(
const
shareButton
=
(
<
IconButton
aria
-
label=
"share"
variant=
"outline"
boxSize=
{
8
}
size=
"sm"
icon=
{
<
IconSvg
name=
"share"
boxSize=
{
5
}
/>
}
onClick=
{
onShare
}
/>
)
:
(
<
Button
<
Button
leftIcon=
{
<
IconSvg
name=
"share"
w=
{
4
}
h=
{
4
}
/>
}
leftIcon=
{
<
IconSvg
name=
"share"
w=
{
4
}
h=
{
4
}
/>
}
colorScheme=
"blue"
colorScheme=
"blue"
...
@@ -169,41 +164,6 @@ const Chart = () => {
...
@@ -169,41 +164,6 @@ const Chart = () => {
</
Button
>
</
Button
>
);
);
const
shareAndMenu
=
(
<
Flex
alignItems=
"center"
ml=
"auto"
gap=
{
3
}
>
{
/* TS thinks window.navigator.share can't be undefined, but it can */
}
{
/* eslint-disable-next-line @typescript-eslint/no-explicit-any */
}
{
(
isInBrowser
&&
((
window
.
navigator
.
share
as
any
)
?
shareButton
:
(
<
CopyToClipboard
text=
{
config
.
app
.
baseUrl
+
router
.
asPath
}
size=
{
5
}
type=
"link"
variant=
"outline"
colorScheme=
"blue"
display=
"flex"
borderRadius=
"8px"
width=
{
8
}
height=
{
8
}
/>
)
))
}
{
(
hasItems
||
lineQuery
.
isPlaceholderData
)
&&
(
<
ChartMenu
items=
{
items
}
title=
{
info
?.
title
||
''
}
isLoading=
{
lineQuery
.
isPlaceholderData
}
chartRef=
{
ref
}
resolution=
{
resolution
}
zoomRange=
{
zoomRange
}
handleZoom=
{
handleZoom
}
handleZoomReset=
{
handleZoomReset
}
/>
)
}
</
Flex
>
);
return
(
return
(
<>
<>
<
PageTitle
<
PageTitle
...
@@ -211,14 +171,13 @@ const Chart = () => {
...
@@ -211,14 +171,13 @@ const Chart = () => {
mb=
{
3
}
mb=
{
3
}
isLoading=
{
isInfoLoading
}
isLoading=
{
isInfoLoading
}
backLink=
{
backLink
}
backLink=
{
backLink
}
afterTitle=
{
isMobile
?
shareAndMenu
:
undefined
}
secondRow=
{
info
?.
description
||
lineQuery
.
data
?.
info
?.
description
}
secondRow=
{
info
?.
description
||
lineQuery
.
data
?.
info
?.
description
}
withTextAd
withTextAd
/>
/>
<
Flex
alignItems=
"center"
justifyContent=
"space-between"
>
<
Flex
alignItems=
"center"
justifyContent=
"space-between"
>
<
Flex
alignItems=
"center"
gap=
{
{
base
:
3
,
lg
:
6
}
}
maxW=
"100%"
overflow=
"hidden"
>
<
Flex
alignItems=
"center"
gap=
{
{
base
:
3
,
lg
:
6
}
}
maxW=
"100%"
overflow=
"hidden"
>
<
Flex
alignItems=
"center"
gap=
{
3
}
>
<
Flex
alignItems=
"center"
gap=
{
3
}
>
<
Text
>
Period
</
Text
>
{
!
isMobile
&&
<
Text
>
Period
</
Text
>
}
<
ChartIntervalSelect
interval=
{
interval
}
onIntervalChange=
{
onIntervalChange
}
/>
<
ChartIntervalSelect
interval=
{
interval
}
onIntervalChange=
{
onIntervalChange
}
/>
</
Flex
>
</
Flex
>
{
lineQuery
.
data
?.
info
?.
resolutions
&&
lineQuery
.
data
?.
info
?.
resolutions
.
length
>
1
&&
(
{
lineQuery
.
data
?.
info
?.
resolutions
&&
lineQuery
.
data
?.
info
?.
resolutions
.
length
>
1
&&
(
...
@@ -243,7 +202,39 @@ const Chart = () => {
...
@@ -243,7 +202,39 @@ const Chart = () => {
</
Link
>
</
Link
>
)
}
)
}
</
Flex
>
</
Flex
>
{
!
isMobile
&&
shareAndMenu
}
<
Flex
alignItems=
"center"
gap=
{
3
}
>
{
/* TS thinks window.navigator.share can't be undefined, but it can */
}
{
/* eslint-disable-next-line @typescript-eslint/no-explicit-any */
}
{
!
isMobile
&&
(
isInBrowser
&&
((
window
.
navigator
.
share
as
any
)
?
shareButton
:
(
<
CopyToClipboard
text=
{
config
.
app
.
baseUrl
+
router
.
asPath
}
size=
{
5
}
type=
"link"
variant=
"outline"
colorScheme=
"blue"
display=
"flex"
borderRadius=
"8px"
width=
{
8
}
height=
{
8
}
/>
)
))
}
{
(
hasItems
||
lineQuery
.
isPlaceholderData
)
&&
(
<
ChartMenu
items=
{
items
}
title=
{
info
?.
title
||
''
}
isLoading=
{
lineQuery
.
isPlaceholderData
}
chartRef=
{
ref
}
resolution=
{
resolution
}
zoomRange=
{
zoomRange
}
handleZoom=
{
handleZoom
}
handleZoomReset=
{
handleZoomReset
}
chartUrl=
{
isMobile
?
window
.
location
.
href
:
undefined
}
/>
)
}
</
Flex
>
</
Flex
>
</
Flex
>
<
Flex
<
Flex
ref=
{
ref
}
ref=
{
ref
}
...
...
ui/pages/__screenshots__/Chart.pw.tsx_mobile_base-view-dark-mode-mobile-1.png
View replaced file @
3df4bd4f
View file @
1df3a163
37.6 KB
|
W:
|
H:
36 KB
|
W:
|
H:
2-up
Swipe
Onion skin
ui/shared/chart/ChartMenu.tsx
View file @
1df3a163
...
@@ -14,10 +14,6 @@ import React from 'react';
...
@@ -14,10 +14,6 @@ import React from 'react';
import
type
{
TimeChartItem
}
from
'
./types
'
;
import
type
{
TimeChartItem
}
from
'
./types
'
;
import
type
{
Resolution
}
from
'
@blockscout/stats-types
'
;
import
type
{
Resolution
}
from
'
@blockscout/stats-types
'
;
import
type
{
Route
}
from
'
nextjs-routes
'
;
import
{
route
}
from
'
nextjs-routes
'
;
import
config
from
'
configs/app
'
;
import
dayjs
from
'
lib/date/dayjs
'
;
import
dayjs
from
'
lib/date/dayjs
'
;
import
isBrowser
from
'
lib/isBrowser
'
;
import
isBrowser
from
'
lib/isBrowser
'
;
import
saveAsCSV
from
'
lib/saveAsCSV
'
;
import
saveAsCSV
from
'
lib/saveAsCSV
'
;
...
@@ -33,7 +29,7 @@ export type Props = {
...
@@ -33,7 +29,7 @@ export type Props = {
units
?:
string
;
units
?:
string
;
isLoading
:
boolean
;
isLoading
:
boolean
;
chartRef
:
React
.
RefObject
<
HTMLDivElement
>
;
chartRef
:
React
.
RefObject
<
HTMLDivElement
>
;
href
?:
Route
;
chartUrl
?:
string
;
resolution
?:
Resolution
;
resolution
?:
Resolution
;
zoomRange
?:
[
Date
,
Date
];
zoomRange
?:
[
Date
,
Date
];
handleZoom
:
(
range
:
[
Date
,
Date
])
=>
void
;
handleZoom
:
(
range
:
[
Date
,
Date
])
=>
void
;
...
@@ -49,7 +45,7 @@ const ChartMenu = ({
...
@@ -49,7 +45,7 @@ const ChartMenu = ({
units
,
units
,
isLoading
,
isLoading
,
chartRef
,
chartRef
,
href
,
chartUrl
,
resolution
,
resolution
,
zoomRange
,
zoomRange
,
handleZoom
,
handleZoom
,
...
@@ -58,7 +54,6 @@ const ChartMenu = ({
...
@@ -58,7 +54,6 @@ const ChartMenu = ({
const
pngBackgroundColor
=
useColorModeValue
(
'
white
'
,
'
black
'
);
const
pngBackgroundColor
=
useColorModeValue
(
'
white
'
,
'
black
'
);
const
[
isFullscreen
,
setIsFullscreen
]
=
React
.
useState
(
false
);
const
[
isFullscreen
,
setIsFullscreen
]
=
React
.
useState
(
false
);
const
chartUrl
=
href
?
config
.
app
.
baseUrl
+
route
(
href
)
:
''
;
const
{
onCopy
}
=
useClipboard
(
chartUrl
);
const
{
onCopy
}
=
useClipboard
(
chartUrl
);
const
isInBrowser
=
isBrowser
();
const
isInBrowser
=
isBrowser
();
...
@@ -144,7 +139,7 @@ const ChartMenu = ({
...
@@ -144,7 +139,7 @@ const ChartMenu = ({
</
MenuButton
>
</
MenuButton
>
</
Skeleton
>
</
Skeleton
>
<
MenuList
>
<
MenuList
>
{
href
&&
(
{
chartUrl
&&
(
<
MenuItem
<
MenuItem
display=
"flex"
display=
"flex"
alignItems=
"center"
alignItems=
"center"
...
...
ui/shared/chart/ChartWidget.tsx
View file @
1df3a163
...
@@ -11,8 +11,9 @@ import React, { useRef } from 'react';
...
@@ -11,8 +11,9 @@ import React, { useRef } from 'react';
import
type
{
TimeChartItem
}
from
'
./types
'
;
import
type
{
TimeChartItem
}
from
'
./types
'
;
import
type
{
Route
}
from
'
nextjs-routes
'
;
import
{
route
,
type
Route
}
from
'
nextjs-routes
'
;
import
config
from
'
configs/app
'
;
import
IconSvg
from
'
ui/shared/IconSvg
'
;
import
IconSvg
from
'
ui/shared/IconSvg
'
;
import
ChartMenu
from
'
./ChartMenu
'
;
import
ChartMenu
from
'
./ChartMenu
'
;
...
@@ -133,7 +134,7 @@ const ChartWidget = ({
...
@@ -133,7 +134,7 @@ const ChartWidget = ({
items=
{
items
}
items=
{
items
}
title=
{
title
}
title=
{
title
}
description=
{
description
}
description=
{
description
}
href=
{
href
}
chartUrl=
{
href
?
config
.
app
.
baseUrl
+
route
(
href
)
:
undefined
}
isLoading=
{
isLoading
}
isLoading=
{
isLoading
}
chartRef=
{
ref
}
chartRef=
{
ref
}
units=
{
units
}
units=
{
units
}
...
...
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