Skip to content

Commit 630b4c0

Browse files
authored
fix: simplify styles & fix margins on homescreen (#3092)
* fix: simplify styles & fix margins on homescreen * fix: remove obsolete translation * fix: conditions * fix: conditions
1 parent d878ba1 commit 630b4c0

File tree

6 files changed

+65
-108
lines changed

6 files changed

+65
-108
lines changed

src/app/components/TransactionsTable/index.tsx

+5-3
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,15 @@ export default function TransactionsTable({
3737
}
3838

3939
return (
40-
<div className="mt-4">
40+
<div>
4141
{loading ? (
4242
<div className="w-full flex flex-col items-center">
4343
<Loading />
4444
</div>
45-
) : !transactions?.length && noResultMsg ? (
46-
<p className="text-gray-500 dark:text-neutral-400">{noResultMsg}</p>
45+
) : !transactions?.length ? (
46+
<p className="text-gray-500 dark:text-neutral-400">
47+
{t("no_transactions")}
48+
</p>
4749
) : (
4850
<>
4951
{transactions?.map((tx) => {

src/app/screens/Home/AllowanceView/index.tsx

+5-23
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import Header from "@components/Header";
22
import IconButton from "@components/IconButton";
3-
import Loading from "@components/Loading";
43
import Progressbar from "@components/Progressbar";
54
import PublisherCard from "@components/PublisherCard";
65
import SitePreferences from "@components/SitePreferences";
@@ -9,7 +8,7 @@ import { PopiconsChevronLeftLine } from "@popicons/react";
98
import dayjs from "dayjs";
109
import relativeTime from "dayjs/plugin/relativeTime";
1110
import { FC, useEffect, useState } from "react";
12-
import { Trans, useTranslation } from "react-i18next";
11+
import { useTranslation } from "react-i18next";
1312
import toast from "~/app/components/Toast";
1413
import { useSettings } from "~/app/context/SettingsContext";
1514
import { PublisherLnData } from "~/app/screens/Home/PublisherLnData";
@@ -40,7 +39,6 @@ const AllowanceView: FC<Props> = (props) => {
4039
const { t } = useTranslation("translation", { keyPrefix: "home" });
4140

4241
const showFiat = !isLoadingSettings && settings.showFiat;
43-
const hasTransactions = !isLoadingTransactions && !!transactions?.length;
4442

4543
// get array of payments if not done yet
4644
useEffect(() => {
@@ -139,26 +137,10 @@ const AllowanceView: FC<Props> = (props) => {
139137
/>
140138
</div>
141139
)}
142-
143-
{isLoadingTransactions && (
144-
<div className="flex justify-center">
145-
<Loading />
146-
</div>
147-
)}
148-
149-
{hasTransactions && <TransactionsTable transactions={transactions} />}
150-
151-
{!isLoadingTransactions && !transactions?.length && (
152-
<p className="text-gray-500 dark:text-neutral-400 text-center">
153-
<Trans
154-
i18nKey={"allowance_view.no_transactions"}
155-
t={t}
156-
values={{ name: props.allowance.name }}
157-
// eslint-disable-next-line react/jsx-key
158-
components={[<strong></strong>]}
159-
/>
160-
</p>
161-
)}
140+
<TransactionsTable
141+
loading={isLoadingTransactions}
142+
transactions={transactions}
143+
/>
162144
</div>
163145
</div>
164146
);

src/app/screens/Home/DefaultView/index.tsx

+47-45
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ const DefaultView: FC<Props> = (props) => {
5353
useTransactions();
5454

5555
const isLoading = accountLoading || isLoadingTransactions;
56+
const needsKeySetup =
57+
!currentAccount?.hasMnemonic || !currentAccount?.isMnemonicBackupDone;
5658

5759
useEffect(() => {
5860
loadTransactions(itemsLimit);
@@ -190,52 +192,52 @@ const DefaultView: FC<Props> = (props) => {
190192
)}
191193

192194
{!isLoading && (
193-
<div>
194-
<div className="flex flex-col mt-4 gap-2 md:gap-3">
195-
{transactions.length == 0 && (
196-
<IconLinkCard
197-
title={t("default_view.actions.get_started.title")}
198-
description={t(
199-
"default_view.actions.get_started.description"
200-
)}
201-
icon={<PopiconsBulbLine className="w-8 h-8" />}
202-
onClick={() => {
203-
utils.openUrl(
204-
"https://guides.getalby.com/user-guide/v/alby-account-and-browser-extension/"
205-
);
206-
}}
207-
/>
208-
)}
209-
210-
{!(
211-
currentAccount?.hasMnemonic &&
212-
currentAccount?.isMnemonicBackupDone
213-
) && (
214-
<IconLinkCard
215-
title={t("default_view.actions.setup_keys.title")}
216-
description={t("default_view.actions.setup_keys.description")}
217-
icon={<PopiconsKeyLine className="w-8 h-8" />}
218-
onClick={async () => {
219-
openOptions(
220-
`accounts/${currentAccount?.id}/secret-key/new`
221-
);
222-
}}
223-
/>
224-
)}
195+
<div className="mt-4 flex flex-col gap-4">
196+
{(transactions.length === 0 || needsKeySetup) && (
197+
<div className="flex flex-col gap-2 md:gap-3">
198+
{transactions.length === 0 && (
199+
<IconLinkCard
200+
title={t("default_view.actions.get_started.title")}
201+
description={t(
202+
"default_view.actions.get_started.description"
203+
)}
204+
icon={<PopiconsBulbLine className="w-8 h-8" />}
205+
onClick={() => {
206+
utils.openUrl(
207+
"https://guides.getalby.com/user-guide/v/alby-account-and-browser-extension/"
208+
);
209+
}}
210+
/>
211+
)}
212+
{needsKeySetup && (
213+
<IconLinkCard
214+
title={t("default_view.actions.setup_keys.title")}
215+
description={t(
216+
"default_view.actions.setup_keys.description"
217+
)}
218+
icon={<PopiconsKeyLine className="w-8 h-8" />}
219+
onClick={async () => {
220+
openOptions(
221+
`accounts/${currentAccount?.id}/secret-key/new`
222+
);
223+
}}
224+
/>
225+
)}
226+
{transactions.length === 0 && (
227+
<IconLinkCard
228+
title={t("default_view.actions.receive_bitcoin.title")}
229+
description={t(
230+
"default_view.actions.receive_bitcoin.description"
231+
)}
232+
icon={<PopiconsArrowDownLine className="w-8 h-8" />}
233+
onClick={() => {
234+
navigate("/receive");
235+
}}
236+
/>
237+
)}
238+
</div>
239+
)}
225240

226-
{transactions.length == 0 && (
227-
<IconLinkCard
228-
title={t("default_view.actions.receive_bitcoin.title")}
229-
description={t(
230-
"default_view.actions.receive_bitcoin.description"
231-
)}
232-
icon={<PopiconsArrowDownLine className="w-8 h-8" />}
233-
onClick={() => {
234-
navigate("/receive");
235-
}}
236-
/>
237-
)}
238-
</div>
239241
<TransactionsTable
240242
transactions={transactions}
241243
loading={isLoading}

src/app/screens/Publishers/Detail/index.tsx

+2-19
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import TransactionsTable from "@components/TransactionsTable";
44
import dayjs from "dayjs";
55
import relativeTime from "dayjs/plugin/relativeTime";
66
import { useCallback, useEffect, useRef, useState } from "react";
7-
import { Trans, useTranslation } from "react-i18next";
87
import { useNavigate, useParams } from "react-router-dom";
98
import toast from "~/app/components/Toast";
109
import { useSettings } from "~/app/context/SettingsContext";
@@ -15,9 +14,6 @@ import type { Allowance, Transaction } from "~/types";
1514
dayjs.extend(relativeTime);
1615

1716
function PublisherDetail() {
18-
const { t } = useTranslation("translation", {
19-
keyPrefix: "home",
20-
});
2117
const {
2218
isLoading: isLoadingSettings,
2319
settings,
@@ -84,23 +80,10 @@ function PublisherDetail() {
8480
isSmall={false}
8581
/>
8682
)}
87-
8883
{allowance && (
8984
<Container>
90-
<div className="mt-5">
91-
{transactions && transactions?.length > 0 ? (
92-
<TransactionsTable transactions={transactions} />
93-
) : (
94-
<p className="text-gray-500 dark:text-neutral-400">
95-
<Trans
96-
i18nKey={"allowance_view.no_transactions"}
97-
t={t}
98-
values={{ name: allowance.name }}
99-
// eslint-disable-next-line react/jsx-key
100-
components={[<strong></strong>]}
101-
/>
102-
</p>
103-
)}
85+
<div className="mt-4">
86+
<TransactionsTable transactions={transactions} />
10487
</div>
10588
</Container>
10689
)}

src/app/screens/Transactions/index.tsx

+1-12
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import Container from "@components/Container";
2-
import Loading from "@components/Loading";
32
import TransactionsTable from "@components/TransactionsTable";
43
import { useEffect } from "react";
54
import { useTranslation } from "react-i18next";
@@ -31,17 +30,7 @@ function Transactions() {
3130
{t("description")}
3231
</p>
3332

34-
{isLoading ? (
35-
<div className="flex justify-center mt-12">
36-
<Loading />
37-
</div>
38-
) : (
39-
<div>
40-
{transactions && transactions.length > 0 && (
41-
<TransactionsTable transactions={transactions} />
42-
)}
43-
</div>
44-
)}
33+
<TransactionsTable loading={isLoading} transactions={transactions} />
4534
</Container>
4635
);
4736
}

src/i18n/locales/en/translation.json

+5-6
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,6 @@
361361
"allowance_view": {
362362
"budget_spent": "Budget spent",
363363
"sats": "sats",
364-
"no_transactions": "No transactions on <0>{{name}}</0> yet.",
365364
"total_spent": "Total spent",
366365
"total_payments": "Total payments",
367366
"permissions": "Permissions"
@@ -374,15 +373,15 @@
374373
"actions": {
375374
"get_started": {
376375
"title": "Get Started With Alby Extension",
377-
"description": "New to Alby Extension? Check out our guides, videos, and explanations"
376+
"description": "New to Alby Extension? Check out our guides, videos and explanations"
378377
},
379378
"setup_keys": {
380379
"title": "Setup your keys",
381380
"description": "Take care of your Master Key or import your existing Nostr account"
382381
},
383382
"receive_bitcoin": {
384383
"title": "Receive bitcoin",
385-
"description": "Get bitcoin to your lightning address, a lightning invoice or bitcoin address."
384+
"description": "Fund your account and receive via your lightning address or an invoice"
386385
}
387386
}
388387
}
@@ -951,8 +950,7 @@
951950
},
952951
"transactions": {
953952
"title": "Transactions",
954-
"description": "Transactions for this account",
955-
"list_empty": "No transactions available yet."
953+
"description": "Transactions for this account"
956954
},
957955
"onboard": {
958956
"title": "Setup your keys",
@@ -1106,7 +1104,8 @@
11061104
"timestamp": "Timestamp",
11071105
"totalAmount": "Total amount"
11081106
},
1109-
"open_location": "Open website"
1107+
"open_location": "Open website",
1108+
"no_transactions": "No transactions yet."
11101109
},
11111110
"budget_control": {
11121111
"remember": {

0 commit comments

Comments
 (0)