Skip to content

Commit f9cfe13

Browse files
authored
Fix 359 account page alignment (#361)
* Use simple icons for brand icons * Reuse button on account page * Fix lint warning in balance list * Update shadcn components * Properly handle classname in accountbutton to work asChild
1 parent 2d9c31b commit f9cfe13

File tree

13 files changed

+331
-347
lines changed

13 files changed

+331
-347
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
"@ducanh2912/next-pwa": "^10.2.9",
3232
"@heroicons/react": "^2.1.1",
3333
"@hookform/resolvers": "^3.3.4",
34+
"@icons-pack/react-simple-icons": "^13.7.0",
3435
"@next-auth/prisma-adapter": "^1.0.7",
3536
"@prisma/client": "^6.8.2",
3637
"@t3-oss/env-nextjs": "^0.11.1",

pnpm-lock.yaml

Lines changed: 13 additions & 13 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import React from 'react';
2+
import { Button, type ButtonProps } from '../ui/button';
3+
import Link from 'next/link';
4+
import { ChevronRight } from 'lucide-react';
5+
import { cn } from '~/lib/utils';
6+
7+
export const AccountButton: React.FC<React.PropsWithChildren<ButtonProps> & { href?: string }> = ({
8+
children,
9+
href,
10+
className,
11+
...buttonProps
12+
}) => (
13+
<WithLink href={href}>
14+
<Button
15+
variant="ghost"
16+
className={cn(className, 'text-md hover:text-foreground/80 w-full justify-between px-0')}
17+
{...buttonProps}
18+
>
19+
<div className="flex items-center gap-4">{children}</div>
20+
<ChevronRight className="h-6 w-6 text-gray-500" />
21+
</Button>
22+
</WithLink>
23+
);
24+
25+
export const WithLink: React.FC<React.PropsWithChildren<{ href?: string }>> = ({
26+
href,
27+
children,
28+
}) =>
29+
href ? (
30+
<Link href={href} target={href.startsWith('http') ? '_blank' : undefined}>
31+
{children}
32+
</Link>
33+
) : (
34+
children
35+
);

src/components/Account/DownloadAppDrawer.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,5 +55,3 @@ export const DownloadAppDrawer: React.FC<DownloadAppDrawerProps> = ({ children,
5555
</AppDrawer>
5656
);
5757
};
58-
59-
export default DownloadAppDrawer;

src/components/Account/LanguagePicker.tsx

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
1-
import { ChevronRight, Languages } from 'lucide-react';
2-
import React, { useCallback, useMemo } from 'react';
3-
import { toast } from 'sonner';
41
import { useTranslation } from 'next-i18next';
52
import { useRouter } from 'next/router';
3+
import React, { type PropsWithChildren, useCallback, useMemo } from 'react';
4+
import { toast } from 'sonner';
65
import { api } from '~/utils/api';
76
import { getSupportedLanguages } from '~/utils/i18n/client';
87
import { GeneralPicker } from '../GeneralPicker';
98

10-
export const LanguagePicker: React.FC = () => {
9+
export const LanguagePicker: React.FC<PropsWithChildren> = ({ children }) => {
1110
const router = useRouter();
1211
const { i18n, t } = useTranslation('account_page');
1312
const updateUser = api.user.updateUserDetail.useMutation();
@@ -34,19 +33,6 @@ export const LanguagePicker: React.FC = () => {
3433
[router, t, updateUser],
3534
);
3635

37-
const trigger = useMemo(
38-
() => (
39-
<div className="hover:text-foreground/80 flex w-full justify-between px-0 py-2 text-[16px] font-medium text-gray-300">
40-
<div className="flex items-center gap-4">
41-
<Languages className="h-5 w-5 text-green-500" />
42-
{t('ui.change_language')}
43-
</div>
44-
<ChevronRight className="h-6 w-6 text-gray-500" />
45-
</div>
46-
),
47-
[t],
48-
);
49-
5036
const extractKey = useCallback((language: { code: string }) => language.code, []);
5137
const selected = useCallback(
5238
(language: { code: string }) => i18n.language === language.code,
@@ -56,7 +42,7 @@ export const LanguagePicker: React.FC = () => {
5642

5743
return (
5844
<GeneralPicker
59-
trigger={trigger}
45+
trigger={children}
6046
title={t('ui.change_language_details.title')}
6147
placeholderText={t('ui.change_language_details.placeholder')}
6248
noOptionsText={t('ui.change_language_details.no_currency_found')}

src/components/Account/SubmitFeedback.tsx

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import { api } from '~/utils/api';
1111
import { AppDrawer } from '../ui/drawer';
1212
import { Form, FormControl, FormField, FormItem, FormMessage } from '../ui/form';
1313
import { Textarea } from '../ui/textarea';
14+
import { AccountButton } from './AccountButton';
1415

1516
const feedbackSchema = (t: TFunction) =>
1617
z.object({
@@ -49,13 +50,10 @@ export const SubmitFeedback: React.FC = () => {
4950

5051
const trigger = useMemo(
5152
() => (
52-
<div className="hover:text-foreground/80 flex w-full justify-between px-0 py-2 text-[16px] font-medium text-gray-300">
53-
<div className="flex items-center gap-4 text-[16px]">
54-
<MessageSquare className="h-5 w-5 text-green-500" />
55-
{t('ui.submit_feedback')}
56-
</div>
57-
<ChevronRight className="h-6x w-6 text-gray-500" />
58-
</div>
53+
<AccountButton>
54+
<MessageSquare className="h-5 w-5 text-green-500" />
55+
{t('ui.submit_feedback')}
56+
</AccountButton>
5957
),
6058
[t],
6159
);

src/components/Account/SubscribeNotification.tsx

Lines changed: 14 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { api } from '~/utils/api';
66
import { useTranslation } from 'next-i18next';
77

88
import { Button } from '../ui/button';
9+
import { AccountButton } from './AccountButton';
910

1011
const base64ToUint8Array = (base64: string) => {
1112
const padding = '='.repeat((4 - (base64.length % 4)) % 4);
@@ -94,27 +95,18 @@ export const SubscribeNotification: React.FC = () => {
9495
}
9596

9697
return (
97-
<>
98-
<Button
99-
variant="ghost"
100-
className="text-md hover:text-foreground/80 w-full justify-between px-0"
101-
onClick={isSubscribed ? unSubscribeNotification : onRequestNotification}
102-
>
103-
<div className="flex items-center gap-4">
104-
{!isSubscribed ? (
105-
<>
106-
<Bell className="h-5 w-5 text-red-400" />
107-
{t('ui.notifications.enable_notification')}
108-
</>
109-
) : (
110-
<>
111-
<BellOff className="h-5 w-5 text-red-400" />
112-
{t('ui.notifications.disable_notification')}
113-
</>
114-
)}
115-
</div>
116-
<ChevronRight className="h-6 w-6 text-gray-500" />
117-
</Button>
118-
</>
98+
<AccountButton onClick={isSubscribed ? unSubscribeNotification : onRequestNotification}>
99+
{!isSubscribed ? (
100+
<>
101+
<Bell className="h-5 w-5 text-red-400" />
102+
{t('ui.notifications.enable_notification')}
103+
</>
104+
) : (
105+
<>
106+
<BellOff className="h-5 w-5 text-red-400" />
107+
{t('ui.notifications.disable_notification')}
108+
</>
109+
)}
110+
</AccountButton>
119111
);
120112
};

src/components/Expense/BalanceList.tsx

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,10 @@ export const BalanceList: React.FC<{
2424
const userQuery = api.user.me.useQuery();
2525

2626
const userMap = useMemo(() => {
27-
const res = users.reduce(
28-
(acc, user) => {
29-
acc[user.id] = { user, balances: {}, total: {} };
30-
return acc;
31-
},
32-
{} as Record<number, UserWithBalance>,
33-
);
27+
const res = users.reduce<Record<number, UserWithBalance>>((acc, user) => {
28+
acc[user.id] = { user, balances: {}, total: {} };
29+
return acc;
30+
}, {});
3431
groupBalances
3532
.filter(({ amount }) => 0 < BigMath.abs(amount))
3633
.forEach((balance) => {

0 commit comments

Comments
 (0)