Skip to content

Commit 8c108eb

Browse files
committed
moved border box to new file and renamed it data box
1 parent d0f4cd4 commit 8c108eb

File tree

2 files changed

+43
-38
lines changed

2 files changed

+43
-38
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import {Children, FC, ReactNode} from "react";
2+
import {useTheme} from "styled-components";
3+
4+
const DataBox: FC<{children: ReactNode, label: string}> = ({children, label}) => {
5+
const theme = useTheme();
6+
const modifiedChildren = typeof children === 'object'
7+
? Children.map(children as JSX.Element, (child: JSX.Element) => {
8+
return <span {...child.props} style={{margin: 0}}></span>;
9+
})
10+
: children;
11+
12+
return (
13+
<fieldset style={{
14+
border: `1.5px solid ${theme.dark ? '#5f5f5f' : '#ccc'}`,
15+
borderRadius: '5px',
16+
padding: '0.1rem 0.4rem',
17+
wordBreak: 'break-all',
18+
whiteSpace: 'normal',
19+
width: 'fit-content',
20+
height: 'fit-content'
21+
}}>
22+
<legend style={{margin: '-0.2rem 0.1rem'}}>{label}</legend>
23+
{modifiedChildren}
24+
</fieldset>
25+
);
26+
}
27+
28+
export default DataBox;

packages/insight/src/components/transaction-details.tsx

Lines changed: 15 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import {
88
isRBF,
99
getLib,
1010
} from '../utilities/helper-methods';
11-
import {useState, useEffect, FC, memo, ReactNode, Children} from 'react';
11+
import {useState, useEffect, FC, memo} from 'react';
1212
import {
1313
TransactionBodyCol,
1414
TransactionTile,
@@ -26,8 +26,9 @@ import ArrowSvg from '../assets/images/arrow.svg';
2626
import BlueArrowSvg from '../assets/images/arrow-blue.svg';
2727
import CircleSvg from '../assets/images/circle.svg';
2828
import {useNavigate, createSearchParams} from 'react-router-dom';
29-
import styled, { useTheme } from 'styled-components';
29+
import styled from 'styled-components';
3030
import {Slate, SlateDark} from '../assets/styles/colors';
31+
import DataBox from './data-box';
3132

3233
const TextElipsis = styled(ScriptText)`
3334
overflow: hidden;
@@ -58,30 +59,6 @@ const TxAddressLink = styled.span`
5859
}
5960
`
6061

61-
const BorderBoxLabel: FC<{children: ReactNode, label: string}> = ({children, label}) => {
62-
const theme = useTheme();
63-
const modifiedChildren = typeof children === 'object'
64-
? Children.map(children as JSX.Element, (child: JSX.Element) => {
65-
return <span {...child.props} style={{margin: 0}}></span>;
66-
})
67-
: children;
68-
69-
return (
70-
<fieldset style={{
71-
border: `1.5px solid ${theme.dark ? '#5f5f5f' : '#ccc'}`,
72-
borderRadius: '5px',
73-
padding: '0.1rem 0.4rem',
74-
wordBreak: 'break-all',
75-
whiteSpace: 'normal',
76-
width: 'fit-content',
77-
height: 'fit-content'
78-
}}>
79-
<legend style={{margin: '-0.2rem 0.1rem'}}>{label}</legend>
80-
{modifiedChildren}
81-
</fieldset>
82-
);
83-
}
84-
8562
interface TransactionDetailsProps {
8663
transaction: Transaction;
8764
currency: string;
@@ -226,7 +203,7 @@ const TransactionDetails: FC<TransactionDetailsProps> = ({
226203
<>
227204

228205
<TileDescription padding='0 1rem 0 0' value>
229-
<BorderBoxLabel label='Tx ID'>
206+
<DataBox label='Tx ID'>
230207
<TextElipsis>
231208
<SpanLink
232209
onClick={() =>
@@ -235,28 +212,28 @@ const TransactionDetails: FC<TransactionDetailsProps> = ({
235212
{item.mintTxid}
236213
</SpanLink>
237214
</TextElipsis>
238-
</BorderBoxLabel>
215+
</DataBox>
239216

240217
<span style={{display: 'flex'}}>
241-
<BorderBoxLabel label='Tx Index'>
218+
<DataBox label='Tx Index'>
242219
<TextElipsis>
243220
{item.mintIndex}
244221
</TextElipsis>
245-
</BorderBoxLabel>
222+
</DataBox>
246223

247224
{item.uiConfirmations && confirmations > 0 ? (
248-
<BorderBoxLabel label='Confirmations'>
225+
<DataBox label='Confirmations'>
249226
<ScriptText>
250227
{item.uiConfirmations + confirmations}
251228
</ScriptText>
252-
</BorderBoxLabel>
229+
</DataBox>
253230
) : null}
254231
</span>
255232

256233
{item.script && (
257234
<>
258-
<BorderBoxLabel label='Script Hex'>{item.script}</BorderBoxLabel>
259-
<BorderBoxLabel label='Script ASM'>{new lib.Script(item.script).toASM()}</BorderBoxLabel>
235+
<DataBox label='Script Hex'>{item.script}</DataBox>
236+
<DataBox label='Script ASM'>{new lib.Script(item.script).toASM()}</DataBox>
260237
</>
261238
)}
262239
</TileDescription>
@@ -315,19 +292,19 @@ const TransactionDetails: FC<TransactionDetailsProps> = ({
315292
<>
316293
<TileDescription padding='0 1rem 0 0' value>
317294
{vo.spentTxid && (
318-
<BorderBoxLabel label='Spent By'>
295+
<DataBox label='Spent By'>
319296
<TextElipsis>
320297
<SpanLink onClick={() => goToTx(vo.spentTxid, transaction.txid, i)}>
321298
{vo.spentTxid}
322299
</SpanLink>
323300
</TextElipsis>
324-
</BorderBoxLabel>
301+
</DataBox>
325302
)}
326303
{isOpReturn(vo) && <ScriptText>{getOpReturnText(vo)}</ScriptText>}
327304
{vo.script && (
328305
<>
329-
<BorderBoxLabel label='Script Hex'>{new lib.Script(vo.script).toHex()}</BorderBoxLabel>
330-
<BorderBoxLabel label='Script ASM'>{new lib.Script(vo.script).toASM()}</BorderBoxLabel>
306+
<DataBox label='Script Hex'>{new lib.Script(vo.script).toHex()}</DataBox>
307+
<DataBox label='Script ASM'>{new lib.Script(vo.script).toASM()}</DataBox>
331308
</>
332309
)}
333310
</TileDescription>

0 commit comments

Comments
 (0)