Skip to content

Commit 99c1a32

Browse files
committed
Remove transactions heading
We believe the list is self-explanatory.
1 parent ef3122f commit 99c1a32

File tree

6 files changed

+66
-198
lines changed

6 files changed

+66
-198
lines changed

package.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
},
1212
"homepage": "https://grouptabs.net/",
1313
"dependencies": {
14-
"@seznam/compose-react-refs": "^1.0.6",
1514
"@testing-library/jest-dom": "^5.14.1",
1615
"@testing-library/react": "^13.0.0",
1716
"@testing-library/user-event": "^14.1.1",
@@ -44,7 +43,6 @@
4443
"redux-first-router": "^2.1.5",
4544
"redux-thunk": "^2.4.0",
4645
"reselect": "^4.1.2",
47-
"smooth-scroll": "^16.1.3",
4846
"stream-browserify": "^3.0.0",
4947
"typescript": "^4.4.4",
5048
"util": "^0.12.4",

src/components/__snapshots__/main.test.tsx.snap

Lines changed: 43 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -230,59 +230,54 @@ exports[`renders summary and transaction list 1`] = `
230230
<div
231231
className="row"
232232
>
233-
<h3
234-
className="transactions-heading"
235-
>
236-
Transactions
237-
</h3>
238233
<div
239234
id="transactions"
240235
>
241-
<div>
242-
<div>
243-
<div
244-
className="dategroup"
245-
>
246-
9/20/2020
247-
</div>
248-
<div
249-
className="transaction list-item-with-arrow"
250-
onClick={[Function]}
251-
>
252-
<table>
253-
<tbody>
254-
<tr>
255-
<td
256-
className="title"
236+
<div
237+
className="dategroup"
238+
>
239+
<div
240+
className="date"
241+
>
242+
9/20/2020
243+
</div>
244+
<div
245+
className="transaction list-item-with-arrow"
246+
onClick={[Function]}
247+
>
248+
<table>
249+
<tbody>
250+
<tr>
251+
<td
252+
className="title"
253+
>
254+
Gummibärchen
255+
<div
256+
className="payments"
257+
>
258+
<strong>
259+
Martin: 22.8,
260+
</strong>
261+
Jan
262+
</div>
263+
</td>
264+
<td
265+
className="total"
266+
>
267+
<span
268+
className="amount-integer"
257269
>
258-
Gummibärchen
259-
<div
260-
className="payments"
261-
>
262-
<strong>
263-
Martin: 22.8,
264-
</strong>
265-
Jan
266-
</div>
267-
</td>
268-
<td
269-
className="total"
270+
22
271+
</span>
272+
<small
273+
className="amount-fraction"
270274
>
271-
<span
272-
className="amount-integer"
273-
>
274-
22
275-
</span>
276-
<small
277-
className="amount-fraction"
278-
>
279-
80
280-
</small>
281-
</td>
282-
</tr>
283-
</tbody>
284-
</table>
285-
</div>
275+
80
276+
</small>
277+
</td>
278+
</tr>
279+
</tbody>
280+
</table>
286281
</div>
287282
</div>
288283
</div>

src/components/main.tsx

Lines changed: 2 additions & 99 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,11 @@
1-
import React, {
2-
FunctionComponent,
3-
useRef,
4-
useState,
5-
useEffect,
6-
memo,
7-
RefObject,
8-
} from "react";
9-
// @ts-ignore
10-
import SmoothScroll from "smooth-scroll";
1+
import React, { FunctionComponent, memo } from "react";
112
import Loader from "./loader";
123
import Summary from "./summary";
134
import TransactionList from "./transactionlist";
145
import TotalSpending from "./totalspending";
156
import LoadError from "./loaderror";
167
import { Account, Transaction, Info } from "../types";
178
import useScrollIndicator from "../hooks/scrollindicator";
18-
import composeRefs from "@seznam/compose-react-refs";
199

2010
interface Props {
2111
tabInfo?: Info;
@@ -32,82 +22,9 @@ interface Props {
3222
onDetailsClick: (tabId: string, transactionId: string) => void;
3323
}
3424

35-
const useTransactionHeadingScroller = (
36-
scrollContainerRef: RefObject<HTMLElement>,
37-
transactionsHeadingRef: RefObject<HTMLElement>,
38-
recheckDependencies: unknown[]
39-
): {
40-
transactionsHeadingIsOutOfViewport: boolean;
41-
scrollToTransactionHeading: () => void;
42-
} => {
43-
const [
44-
transactionsHeadingIsOutOfViewport,
45-
setTransactionsHeadingIsOutOfViewport,
46-
] = useState<boolean>(false);
47-
48-
// this ref is needed as the state updates unreliably
49-
const transactionsHeadingIsOutOfViewportRef = useRef(false);
50-
51-
const checkTransactionsHeadingVisibilityRef = useRef(() => {
52-
if (!scrollContainerRef.current || !transactionsHeadingRef.current) {
53-
return;
54-
}
55-
56-
const scrollContainer = scrollContainerRef.current;
57-
const scrollBottomY =
58-
scrollContainer.clientHeight + scrollContainer.scrollTop;
59-
const headingY = transactionsHeadingRef.current.offsetTop;
60-
const newTransactionsHeadingIsOutOfViewport = scrollBottomY < headingY + 60;
61-
if (
62-
newTransactionsHeadingIsOutOfViewport !==
63-
transactionsHeadingIsOutOfViewportRef.current
64-
) {
65-
transactionsHeadingIsOutOfViewportRef.current =
66-
newTransactionsHeadingIsOutOfViewport;
67-
setTransactionsHeadingIsOutOfViewport(
68-
newTransactionsHeadingIsOutOfViewport
69-
);
70-
}
71-
});
72-
73-
const scroller = useRef<any>(new SmoothScroll());
74-
75-
useEffect(() => {
76-
const handler = checkTransactionsHeadingVisibilityRef.current;
77-
const scrollContainer = scrollContainerRef.current;
78-
scrollContainer?.addEventListener("scroll", handler);
79-
window.addEventListener("resize", handler);
80-
handler();
81-
82-
return () => {
83-
scrollContainer?.removeEventListener("scroll", handler);
84-
window.removeEventListener("resize", handler);
85-
};
86-
}, [scrollContainerRef]);
87-
88-
useEffect(() => {
89-
setTimeout(checkTransactionsHeadingVisibilityRef.current);
90-
}, recheckDependencies); // eslint-disable-line react-hooks/exhaustive-deps
91-
92-
return {
93-
transactionsHeadingIsOutOfViewport,
94-
scrollToTransactionHeading: () => {
95-
scroller.current.animateScroll(transactionsHeadingRef.current);
96-
},
97-
};
98-
};
99-
10025
const Main: FunctionComponent<Props> = (props) => {
101-
const contentContainerRef = useRef<HTMLDivElement>(null);
102-
const transactionsHeadingRef = useRef<HTMLHeadingElement>(null);
103-
10426
const [isScrolled, scrollContainerRef] = useScrollIndicator();
10527

106-
const { transactionsHeadingIsOutOfViewport, scrollToTransactionHeading } =
107-
useTransactionHeadingScroller(contentContainerRef, transactionsHeadingRef, [
108-
props.accounts,
109-
]);
110-
11128
const handleNewEntryClick = () => {
11229
if (!props.tabId) {
11330
throw new Error("Tab ID missing.");
@@ -137,9 +54,6 @@ const Main: FunctionComponent<Props> = (props) => {
13754
<Summary accounts={props.accounts} />
13855
</div>
13956
<div className="row">
140-
<h3 ref={transactionsHeadingRef} className="transactions-heading">
141-
Transactions
142-
</h3>
14357
<TransactionList
14458
transactions={props.transactions}
14559
onDetailsClick={props.onDetailsClick}
@@ -206,21 +120,10 @@ const Main: FunctionComponent<Props> = (props) => {
206120
return (
207121
<div className="scene mainScene">
208122
{renderHeader(!isLoading && !props.remoteTabError)}
209-
{transactionsHeadingIsOutOfViewport && (
210-
<h3
211-
className="transactions-heading transactions-heading-fixed"
212-
onClick={scrollToTransactionHeading}
213-
>
214-
▾ Transactions
215-
</h3>
216-
)}
217123
<div
218124
id="main-content"
219125
className="content"
220-
ref={composeRefs<HTMLDivElement>(
221-
contentContainerRef,
222-
scrollContainerRef
223-
)}
126+
ref={scrollContainerRef}
224127
style={{ position: "relative" }}
225128
>
226129
<Loader show={isLoading}>{renderContent()}</Loader>

src/components/transactionlist.tsx

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -46,22 +46,20 @@ const TransactionList: FunctionComponent<Props> = ({
4646
}) => {
4747
return (
4848
<div id="transactions">
49-
<div>
50-
{groupTransactions(transactions).map((dateGroup) => (
51-
<div key={dateGroup.date}>
52-
<div className="dategroup">{dateGroup.date}</div>
53-
{dateGroup.transactions.map((transaction) => {
54-
return (
55-
<TransactionListItem
56-
key={transaction.timestamp + "_" + transaction.description}
57-
transaction={transaction}
58-
onDetailsClick={onDetailsClick}
59-
/>
60-
);
61-
})}
62-
</div>
63-
))}
64-
</div>
49+
{groupTransactions(transactions).map((dateGroup) => (
50+
<div key={dateGroup.date} className="dategroup">
51+
<div className="date">{dateGroup.date}</div>
52+
{dateGroup.transactions.map((transaction) => {
53+
return (
54+
<TransactionListItem
55+
key={transaction.timestamp + "_" + transaction.description}
56+
transaction={transaction}
57+
onDetailsClick={onDetailsClick}
58+
/>
59+
);
60+
})}
61+
</div>
62+
))}
6563
</div>
6664
);
6765
};

src/index.css

Lines changed: 7 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -555,33 +555,17 @@ input[type="number"] {
555555
font-size: 18px;
556556
}
557557

558+
.summary {
559+
margin-bottom: 38px;
560+
}
558561
.summary tr {
559562
box-sizing: border-box;
560563
height: 56px;
561564
}
562565

563-
.transactions-heading {
564-
text-align: center;
565-
padding-top: 18px;
566-
padding-bottom: 0;
567-
margin-bottom: 0;
568-
}
569-
.mainScene {
570-
position: relative;
571-
}
572-
.transactions-heading-fixed {
573-
position: absolute;
574-
z-index: 1;
575-
left: 0;
576-
bottom: 0;
577-
margin: 0;
578-
width: 100%;
579-
padding: 20px 0 12px;
580-
background: linear-gradient(transparent, var(--main-background-color));
581-
text-shadow: 0 0 4px var(--main-background-color);
582-
cursor: pointer;
566+
#transactions .dategroup:not(:last-child) {
567+
margin-bottom: 26px;
583568
}
584-
585569
#transactions .transaction {
586570
-moz-box-sizing: border-box;
587571
-webkit-box-sizing: border-box;
@@ -594,8 +578,8 @@ input[type="number"] {
594578
#transactions .transaction:first-child {
595579
border-top: none;
596580
}
597-
#transactions .dategroup {
598-
padding: 26px 12px 6px;
581+
#transactions .date {
582+
padding: 0 12px 6px;
599583
font-size: 12px;
600584
color: var(--subtle-text-color);
601585
}

yarn.lock

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1633,11 +1633,6 @@
16331633
resolved "https://registry.yarnpkg.com/@rushstack/eslint-patch/-/eslint-patch-1.2.0.tgz#8be36a1f66f3265389e90b5f9c9962146758f728"
16341634
integrity sha512-sXo/qW2/pAcmT43VoRKOJbDOfV3cYpq3szSVfIThQXNt+E4DfKj361vaAt3c88U5tPUxzEswam7GW48PJqtKAg==
16351635

1636-
"@seznam/compose-react-refs@^1.0.6":
1637-
version "1.0.6"
1638-
resolved "https://registry.yarnpkg.com/@seznam/compose-react-refs/-/compose-react-refs-1.0.6.tgz#6ec4e70bdd6e32f8e70b4100f27267cf306bd8df"
1639-
integrity sha512-izzOXQfeQLonzrIQb8u6LQ8dk+ymz3WXTIXjvOlTXHq6sbzROg3NWU+9TTAOpEoK9Bth24/6F/XrfHJ5yR5n6Q==
1640-
16411636
"@sinclair/typebox@^0.24.1":
16421637
version "0.24.51"
16431638
resolved "https://registry.yarnpkg.com/@sinclair/typebox/-/typebox-0.24.51.tgz#645f33fe4e02defe26f2f5c0410e1c094eac7f5f"
@@ -8927,11 +8922,6 @@ slice-ansi@^5.0.0:
89278922
ansi-styles "^6.0.0"
89288923
is-fullwidth-code-point "^4.0.0"
89298924

8930-
smooth-scroll@^16.1.3:
8931-
version "16.1.3"
8932-
resolved "https://registry.yarnpkg.com/smooth-scroll/-/smooth-scroll-16.1.3.tgz#c5b68194b4186173f9f61065103ae4e26ce36885"
8933-
integrity sha512-ca9U+neJS/cbdScTBuUTCZvUWNF2EuMCk7oAx3ImdeRK5FPm+xRo9XsVHIkeEVkn7MBRx+ufVEhyveM4ZhaTGA==
8934-
89358925
sockjs@^0.3.24:
89368926
version "0.3.24"
89378927
resolved "https://registry.yarnpkg.com/sockjs/-/sockjs-0.3.24.tgz#c9bc8995f33a111bea0395ec30aa3206bdb5ccce"

0 commit comments

Comments
 (0)