Skip to content

Commit 19f764c

Browse files
authored
Merge pull request #90 from Lynndabel/creator
Add creator card network fee hint
2 parents d5c2a1a + d22296f commit 19f764c

3 files changed

Lines changed: 78 additions & 5 deletions

File tree

‎src/components/common/CreatorCard.tsx‎

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
import { useRef, useState } from 'react';
22
import { useAccount } from 'wagmi';
3-
import { AsyncButton } from '@/components/ui/async-button';
43
import type { Course } from '@/services/course.service';
54
import { cn } from '@/lib/utils';
65
import { ShoppingCart, Link as LinkIcon, TrendingUp } from 'lucide-react';
76
import toast from 'react-hot-toast';
87
import showToast from '@/utils/toast.util';
8+
import { formatCompactNumber, formatNumber } from '@/utils/numberFormat.utils';
9+
import { AsyncButton } from '@/components/ui/async-button';
10+
import { useNetworkMismatch } from '@/hooks/useNetworkMismatch';
11+
import { useTransactionTelemetry } from '@/hooks/useTransactionTelemetry';
912
import TransactionRetryNotice from '@/components/common/TransactionRetryNotice';
1013
import TransactionFailureDrawer from '@/components/common/TransactionFailureDrawer';
1114
import type { TransactionFailureDetails } from '@/components/common/TransactionFailureDrawer';
@@ -21,10 +24,8 @@ import Change24hBadge from '@/components/common/Change24hBadge';
2124
import KeySupplyBadge from '@/components/common/KeySupplyBadge';
2225
import CreatorListRowDivider from '@/components/common/CreatorListRowDivider';
2326
import BuyActionHelperText from '@/components/common/BuyActionHelperText';
27+
import NetworkFeeHint from '@/components/common/NetworkFeeHint';
2428
import CreatorBio from '@/components/common/CreatorBio';
25-
import { useTransactionTelemetry } from '@/hooks/useTransactionTelemetry';
26-
import { useNetworkMismatch } from '@/hooks/useNetworkMismatch';
27-
import { formatCompactNumber, formatNumber } from '@/utils/numberFormat.utils';
2829

2930
interface CreatorCardProps {
3031
creator: Course;
@@ -218,7 +219,8 @@ const CreatorCard: React.FC<CreatorCardProps> = ({ creator, className }) => {
218219
</div>
219220
<CreatorListRowDivider className="mt-4 mb-2" />
220221

221-
<div className="flex items-center justify-end gap-4">
222+
<div className="flex flex-col sm:flex-row sm:items-center sm:justify-between gap-4">
223+
<NetworkFeeHint className="shrink-0" />
222224
<AsyncButton
223225
onClick={handleBuy}
224226
variant={isConnected ? 'default' : 'outline'}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import { cn } from '@/lib/utils';
2+
import { Zap } from 'lucide-react';
3+
4+
interface NetworkFeeHintProps {
5+
fee?: string;
6+
className?: string;
7+
variant?: 'chip' | 'text';
8+
}
9+
10+
const NetworkFeeHint = ({
11+
fee = '~0.0001 ETH',
12+
className,
13+
variant = 'chip',
14+
}: NetworkFeeHintProps) => {
15+
if (variant === 'text') {
16+
return (
17+
<div className={cn('flex items-center gap-1.5 text-xs text-white/40', className)}>
18+
<Zap className="size-3 text-amber-500/50" />
19+
<span>Network fee: {fee}</span>
20+
</div>
21+
);
22+
}
23+
24+
return (
25+
<div
26+
className={cn(
27+
'inline-flex min-w-0 items-center gap-1.5 rounded-full border border-amber-500/20 bg-amber-500/5 px-2 py-1 text-[0.6rem] font-medium text-amber-200/70 backdrop-blur-sm',
28+
className
29+
)}
30+
>
31+
<Zap className="size-3 text-amber-500/60 shrink-0" />
32+
<span className="truncate font-jakarta text-xs">
33+
{fee}
34+
</span>
35+
</div>
36+
);
37+
};
38+
39+
export default NetworkFeeHint;
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
// Test component to demonstrate NetworkFeeHint usage
2+
// This file shows how the component can be used in different contexts
3+
4+
import NetworkFeeHint from './NetworkFeeHint';
5+
6+
export const NetworkFeeHintExamples = () => {
7+
return (
8+
<div className="space-y-4 p-4">
9+
<div>
10+
<h3 className="text-white mb-2">Chip Variant (Default)</h3>
11+
<NetworkFeeHint fee="~0.0001 ETH" />
12+
</div>
13+
14+
<div>
15+
<h3 className="text-white mb-2">Text Variant</h3>
16+
<NetworkFeeHint fee="~0.0002 ETH" variant="text" />
17+
</div>
18+
19+
<div>
20+
<h3 className="text-white mb-2">Custom Fee Amount</h3>
21+
<NetworkFeeHint fee="~0.00005 ETH" />
22+
</div>
23+
24+
<div>
25+
<h3 className="text-white mb-2">With Custom ClassName</h3>
26+
<NetworkFeeHint fee="~0.0001 ETH" className="border-red-500/20 bg-red-500/5" />
27+
</div>
28+
</div>
29+
);
30+
};
31+
32+
export default NetworkFeeHintExamples;

0 commit comments

Comments
 (0)