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
5eaf61c4
Commit
5eaf61c4
authored
Dec 08, 2022
by
tom
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
clean up
parent
452f8c20
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
10 deletions
+19
-10
AddressDetails.tsx
ui/address/AddressDetails.tsx
+1
-1
AddressQrCode.tsx
ui/address/details/AddressQrCode.tsx
+18
-9
No files found.
ui/address/AddressDetails.tsx
View file @
5eaf61c4
...
@@ -69,7 +69,7 @@ const AddressDetails = ({ addressQuery }: Props) => {
...
@@ -69,7 +69,7 @@ const AddressDetails = ({ addressQuery }: Props) => {
<
Button
variant=
"outline"
size=
"sm"
ml=
{
3
}
>
<
Button
variant=
"outline"
size=
"sm"
ml=
{
3
}
>
<
Icon
as=
{
starOutlineIcon
}
boxSize=
{
5
}
/>
<
Icon
as=
{
starOutlineIcon
}
boxSize=
{
5
}
/>
</
Button
>
</
Button
>
<
AddressQrCode
hash=
{
addressQuery
.
data
.
hash
}
/>
<
AddressQrCode
hash=
{
addressQuery
.
data
.
hash
}
ml=
{
2
}
/>
</
Flex
>
</
Flex
>
{
explorers
.
length
>
0
&&
(
{
explorers
.
length
>
0
&&
(
<
Flex
mt=
{
8
}
columnGap=
{
4
}
flexWrap=
"wrap"
>
<
Flex
mt=
{
8
}
columnGap=
{
4
}
flexWrap=
"wrap"
>
...
...
ui/address/details/AddressQrCode.tsx
View file @
5eaf61c4
import
{
Button
,
Alert
,
Icon
,
Modal
,
ModalBody
,
ModalContent
,
ModalCloseButton
,
ModalOverlay
,
Box
,
useDisclosure
}
from
'
@chakra-ui/react
'
;
import
{
chakra
,
Alert
,
Icon
,
Modal
,
ModalBody
,
ModalContent
,
ModalCloseButton
,
ModalOverlay
,
Box
,
useDisclosure
,
Tooltip
,
IconButton
}
from
'
@chakra-ui/react
'
;
import
*
as
Sentry
from
'
@sentry/react
'
;
import
*
as
Sentry
from
'
@sentry/react
'
;
import
QRCode
from
'
qrcode
'
;
import
QRCode
from
'
qrcode
'
;
import
React
from
'
react
'
;
import
React
from
'
react
'
;
...
@@ -11,19 +11,19 @@ const SVG_OPTIONS = {
...
@@ -11,19 +11,19 @@ const SVG_OPTIONS = {
};
};
interface
Props
{
interface
Props
{
className
?:
string
;
hash
:
string
;
hash
:
string
;
}
}
const
AddressQrCode
=
({
hash
}:
Props
)
=>
{
const
AddressQrCode
=
({
hash
,
className
}:
Props
)
=>
{
const
{
isOpen
,
onOpen
,
onClose
}
=
useDisclosure
();
const
{
isOpen
,
onOpen
,
onClose
}
=
useDisclosure
();
const
isMobile
=
useIsMobile
();
const
isMobile
=
useIsMobile
();
const
ref
=
React
.
useRef
<
HTMLDivElement
>
(
null
);
const
[
qr
,
setQr
]
=
React
.
useState
(
''
);
const
[
qr
,
setQr
]
=
React
.
useState
(
''
);
const
[
error
,
setError
]
=
React
.
useState
(
''
);
const
[
error
,
setError
]
=
React
.
useState
(
''
);
React
.
useEffect
(()
=>
{
React
.
useEffect
(()
=>
{
if
(
isOpen
)
{
if
(
isOpen
)
{
QRCode
.
toString
(
hash
,
SVG_OPTIONS
,
function
(
error
:
Error
|
null
|
undefined
,
svg
:
string
)
{
QRCode
.
toString
(
hash
,
SVG_OPTIONS
,
(
error
:
Error
|
null
|
undefined
,
svg
:
string
)
=>
{
if
(
error
)
{
if
(
error
)
{
setError
(
'
We were unable to generate QR code.
'
);
setError
(
'
We were unable to generate QR code.
'
);
Sentry
.
captureException
(
error
,
{
tags
:
{
source
:
'
QR code
'
}
});
Sentry
.
captureException
(
error
,
{
tags
:
{
source
:
'
QR code
'
}
});
...
@@ -38,15 +38,24 @@ const AddressQrCode = ({ hash }: Props) => {
...
@@ -38,15 +38,24 @@ const AddressQrCode = ({ hash }: Props) => {
return
(
return
(
<>
<>
<
Button
variant=
"outline"
size=
"sm"
ml=
{
2
}
onClick=
{
onOpen
}
aria
-
label=
"Show QR code"
>
<
Tooltip
label=
"Click to view QR code"
>
<
Icon
as=
{
qrCodeIcon
}
boxSize=
{
5
}
/>
<
IconButton
</
Button
>
className=
{
className
}
aria
-
label=
"Show QR code"
variant=
"outline"
size=
"sm"
pl=
"6px"
pr=
"6px"
onClick=
{
onOpen
}
icon=
{
<
Icon
as=
{
qrCodeIcon
}
boxSize=
{
5
}
/>
}
/>
</
Tooltip
>
<
Modal
isOpen=
{
isOpen
}
onClose=
{
onClose
}
size=
{
{
base
:
'
full
'
,
lg
:
'
sm
'
}
}
>
<
Modal
isOpen=
{
isOpen
}
onClose=
{
onClose
}
size=
{
{
base
:
'
full
'
,
lg
:
'
sm
'
}
}
>
<
ModalOverlay
/>
<
ModalOverlay
/>
<
ModalContent
bgColor=
{
error
?
undefined
:
'
white
'
}
>
<
ModalContent
bgColor=
{
error
?
undefined
:
'
white
'
}
>
{
isMobile
&&
<
ModalCloseButton
/>
}
{
isMobile
&&
<
ModalCloseButton
/>
}
<
ModalBody
mb=
{
0
}
>
<
ModalBody
mb=
{
0
}
>
{
error
?
<
Alert
status=
"warning"
>
{
error
}
</
Alert
>
:
<
Box
ref=
{
ref
}
dangerouslySetInnerHTML=
{
{
__html
:
qr
}
}
/>
}
{
error
?
<
Alert
status=
"warning"
>
{
error
}
</
Alert
>
:
<
Box
dangerouslySetInnerHTML=
{
{
__html
:
qr
}
}
/>
}
</
ModalBody
>
</
ModalBody
>
</
ModalContent
>
</
ModalContent
>
</
Modal
>
</
Modal
>
...
@@ -54,4 +63,4 @@ const AddressQrCode = ({ hash }: Props) => {
...
@@ -54,4 +63,4 @@ const AddressQrCode = ({ hash }: Props) => {
);
);
};
};
export
default
React
.
memo
(
AddressQrCode
);
export
default
React
.
memo
(
chakra
(
AddressQrCode
)
);
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