on master help sign in
ui: bucket TXs by ship, additional styling
commit1b438634d8bf5bfdb512a0b1967fe0c59db82216 authortomholford <tomholford@users.noreply.github.com> dateMon 11 Oct 2021, 22:50 (5 years ago) parent5cc7169
5 files changed+142−33
src/lib/constants.ts+1−1 src/views/Transactions/Gallery.tsx+20 src/views/Transactions/ShipRow.tsx+29 src/views/Transactions/TransactionHistory.scss+56−26 src/views/Transactions/TransactionHistory.tsx+36−6
src/lib/constants.ts+1−1
@@ -138,7 +138,7 @@ const TRANSACTION_STATUS_ICONS = {
138138
139139const TRANSACTION_TYPE_ICONS = {
140140 spawn: 'ArrowEast',
141− 'configure-keys': 'Gear',
141+ 'configure-keys': 'BootNode',
142142 'transfer-point': 'Swap',
143143 'set-management-proxy': 'ArrowRefresh',
144144};
src/views/Transactions/Gallery.tsxnew file+20
@@ -0,0 +1,20 @@
1+import { Box, Icon } from '@tlon/indigo-react';
2+import { _iconIndex as iconIndex } from '@tlon/indigo-react';
3+
4+export const Gallery = () => {
5+ const iconNames = Object.keys(iconIndex);
6+ return (
7+ <>
8+ {iconNames.map(name => {
9+ return (
10+ <>
11+ <Box padding={'5px'} marginBottom={'5px'} border={'solid 1px rgba(0,0,0,0.5)'}>
12+ {name}
13+ <Icon icon={name} height={'16px'} width={'16px'} />
14+ </Box>
15+ </>
16+ );
17+ })}
18+ </>
19+ );
20+};
src/views/Transactions/ShipRow.tsxnew file+29
@@ -0,0 +1,29 @@
1+import { Box, Row } from '@tlon/indigo-react';
2+import Sigil from 'components/Sigil';
3+
4+export const ShipRow = ({ patp }) => {
5+ return (
6+ <>
7+ <Box className="ship-row">
8+ <Box className="icon">
9+ <Box className="sigil">
10+ {
11+ <Sigil
12+ icon
13+ patp={patp}
14+ colors={['black', 'white']}
15+ size={12}
16+ display="block"
17+ padding={6}
18+ borderRadius={2}
19+ />
20+ }
21+ </Box>
22+ </Box>
23+ <Box className="info">
24+ <Box className="patp">~{patp}</Box>
25+ </Box>
26+ </Box>
27+ </>
28+ );
29+};
src/views/Transactions/TransactionHistory.scss+56−26
@@ -1,35 +1,69 @@
11@import 'style/shared/variables.scss';
22
3+@mixin tx-row {
4+ display: grid;
5+ grid-template-areas: "icon info";
6+ grid-template-columns: 24px auto;
7+ grid-template-rows: auto;
8+ column-gap: 16px;
9+ margin-top: 8px;
10+ margin-bottom: 8px;
11+ padding-top: 8px;
12+ padding-bottom: 8px;
13+}
14+
315.transaction-history {
416
517 .transaction-container {
618 width: 100%;
719 }
820
21+ .ship-row {
22+ @include tx-row();
23+
24+ .icon {
25+ grid-area: icon;
26+
27+ .sigil {
28+ background-color: black;
29+ height: 14px;
30+ width: 14px;
31+ padding: 4px;
32+ }
33+ }
34+
35+ .info {
36+ grid-area: info;
37+ display: flex;
38+ flex-flow: column nowrap;
39+ justify-content: center;
40+
41+ .patp {
42+ font-family: Source Code Pro;
43+ font-size: 14px;
44+ font-style: normal;
45+ font-weight: 500;
46+ line-height: 16px;
47+ letter-spacing: 0em;
48+ }
49+ }
50+ }
51+
952 .transaction-row {
10− display: grid;
11− grid-template-areas: "icon info";
12− grid-template-columns: 18px auto;
13− grid-template-rows: auto;
14− column-gap: 16px;
15− margin-top: 8px;
16− margin-bottom: 8px;
17− padding-top: 8px;
18− padding-bottom: 8px;
53+ @include tx-row();
1954
2055 .icon {
2156 grid-area: icon;
22− padding-top: 3px;
57+ padding-top: 6px;
2358
2459 svg {
25− height: 18px;
26− width: 18px;
60+ height: 16px;
61+ width: 16px;
2762 }
2863 }
2964
3065 .info {
3166 grid-area: info;
32−
3367 }
3468
3569 .title-row {
@@ -50,22 +84,22 @@
5084
5185 .status {
5286 .badge {
53− width: 78px;
87+ align-items: center;
88+ background-color: black;
89+ border-radius: 2px;
90+ color: white;
5491 display: flex;
5592 flex-flow: row nowrap;
56− justify-content: space-between;
57− align-items: center;
5893 font-family: Inter;
5994 font-size: 14px;
6095 font-style: normal;
6196 font-weight: 500;
62− line-height: 18px;
97+ justify-content: space-between;
6398 letter-spacing: 0em;
99+ line-height: 18px;
100+ padding: 4px 8px;
64101 text-align: center;
65− color: white;
66− background-color: black;
67− padding: 2px;
68− border-radius: 2px;
102+ width: 78px;
69103
70104 svg {
71105 height: 14px;
@@ -92,12 +126,8 @@
92126 &.pending {
93127 background-color: $rollup-yellow;
94128 color: #000;
95− padding: 4px 8px;
96129 width: 100px;
97− display: flex;
98− flex-direction: row;
99− justify-content: space-between;
100− align-items: center;
130+
101131
102132 svg {
103133 path {
src/views/Transactions/TransactionHistory.tsx+36−6
@@ -1,4 +1,4 @@
1−import React, { useCallback, useEffect, useState } from 'react';
1+import React, { useCallback, useEffect, useMemo, useState } from 'react';
22
33import * as need from 'lib/need';
44import { useWallet } from 'store/wallet';
@@ -15,6 +15,11 @@ import { RollerTransaction } from '@urbit/roller-api';
1515import './TransactionHistory.scss';
1616import { TransactionRow } from './TransactionRow';
1717import { Box } from '@tlon/indigo-react';
18+import { ShipRow } from './ShipRow';
19+
20+interface GroupedTransactions {
21+ [ship: string]: RollerTransaction[];
22+}
1823
1924const TransactionHistory = () => {
2025 const { pop }: any = useLocalRouter();
@@ -23,10 +28,24 @@ const TransactionHistory = () => {
2328 const address = need.addressFromWallet(wallet);
2429 const [transactions, setTransactions] = useState<RollerTransaction[]>([]);
2530
31+ const txnsByPatp = useMemo(() => {
32+ return transactions.reduce((memo, tx) => {
33+ if (Object.keys(memo).includes(tx.ship)) {
34+ memo[tx.ship].push(tx);
35+ } else {
36+ memo[tx.ship] = [tx];
37+ }
38+ return memo;
39+ }, {} as GroupedTransactions);
40+ }, [transactions]);
41+
42+ const txKeys = useMemo(() => {
43+ return Object.keys(txnsByPatp).sort();
44+ }, [txnsByPatp]);
45+
2646 const fetchTransactions = useCallback(async () => {
2747 const txns = await api.getHistory(address);
28− const sortedTxns = txns.sort((a, b) => a.time - b.time)
29− setTransactions(sortedTxns);
48+ setTransactions(txns);
3049 }, [address, api]);
3150
3251 useEffect(() => {
@@ -46,9 +65,20 @@ const TransactionHistory = () => {
4665 </HeaderPane>
4766 <BodyPane>
4867 <Box className="transaction-container">
49− {transactions.map(tx => (
50− <TransactionRow key={tx.time} {...tx} />
51− ))}
68+ {txKeys.map(patp => {
69+ return (
70+ <>
71+ <ShipRow patp={patp} />
72+ {txnsByPatp[patp]
73+ .sort((a, b) => {
74+ return a.time - b.time;
75+ })
76+ .map(tx => (
77+ <TransactionRow key={tx.time} {...tx} />
78+ ))}
79+ </>
80+ );
81+ })}
5282 </Box>
5383 </BodyPane>
5484 </Window>