Skip to content

Commit 07dd3d5

Browse files
committed
fix minor issues with loading svgs
1 parent cf3eaea commit 07dd3d5

4 files changed

Lines changed: 23 additions & 20 deletions

File tree

README.md

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,3 @@
1-
<div align="center">
2-
<img width="1200" height="475" alt="GHBanner" src="https://github.com/user-attachments/assets/0aa67016-6eaf-458a-adb2-6e31a0763ed6" />
3-
</div>
4-
5-
# Run and deploy your AI Studio app
6-
7-
This contains everything you need to run your app locally.
8-
9-
View your app in AI Studio: https://ai.studio/apps/drive/1gQhirq9MyOQQJ-cb6hdhHH8dYafKFjSF
101

112
## Run Locally
123

@@ -15,6 +6,5 @@ View your app in AI Studio: https://ai.studio/apps/drive/1gQhirq9MyOQQJ-cb6hdhHH
156

167
1. Install dependencies:
178
`npm install`
18-
2. Set the `GEMINI_API_KEY` in [.env.local](.env.local) to your Gemini API key
19-
3. Run the app:
9+
2. Run the app:
2010
`npm run dev`

components/SwapCard.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ const SwapCard: React.FC<SwapCardProps> = ({
259259
<input
260260
type="text"
261261
placeholder="0"
262-
className="bg-transparent text-3xl text-gray-900 dark:text-white font-semibold focus:outline-none w-full placeholder-gray-400 dark:placeholder-gray-600"
262+
className="bg-transparent text-lg lg:text-3xl text-gray-900 dark:text-white font-semibold focus:outline-none w-full placeholder-gray-400 dark:placeholder-gray-600"
263263
value={fromAmount}
264264
onChange={handleFromAmountChange}
265265
/>
@@ -323,7 +323,7 @@ const SwapCard: React.FC<SwapCardProps> = ({
323323
<input
324324
type="text"
325325
placeholder="0"
326-
className="bg-transparent text-3xl text-gray-900 dark:text-white font-semibold focus:outline-none w-full placeholder-gray-400 dark:placeholder-gray-600"
326+
className="bg-transparent text-xl lg:text-3xl text-gray-900 dark:text-white font-semibold focus:outline-none w-full placeholder-gray-400 dark:placeholder-gray-600"
327327
value={toAmount}
328328
onChange={handleToAmountChange}
329329
/>

components/TokenIcon.tsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { useState } from 'react';
1+
import React, { useState, useEffect } from 'react';
22
import { Coins } from 'lucide-react';
33

44
interface TokenIconProps {
@@ -8,8 +8,10 @@ interface TokenIconProps {
88

99
const TokenIcon: React.FC<TokenIconProps> = ({ symbol, className = "w-6 h-6" }) => {
1010
const [error, setError] = useState(false);
11-
12-
// Construct the URL for the token icon based on common Switcheo repo structure
11+
useEffect(() => {
12+
setError(false);
13+
}, [symbol]);
14+
1315
const iconUrl = `https://raw.githubusercontent.com/Switcheo/token-icons/main/tokens/${symbol}.svg`;
1416

1517
if (error) {
@@ -22,6 +24,7 @@ const TokenIcon: React.FC<TokenIconProps> = ({ symbol, className = "w-6 h-6" })
2224

2325
return (
2426
<img
27+
key={symbol}
2528
src={iconUrl}
2629
alt={symbol}
2730
className={`${className} rounded-full`}

components/TokenModal.tsx

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { useState, useMemo } from 'react';
1+
import React, { useState, useMemo, useEffect } from 'react';
22
import { X, Search } from 'lucide-react';
33
import { Token } from '../types';
44
import TokenIcon from './TokenIcon';
@@ -18,12 +18,22 @@ const TokenModal: React.FC<TokenModalProps> = ({ isOpen, onClose, tokens, onSele
1818
const lowerSearch = search.toLowerCase();
1919
return tokens.filter(t => t.symbol.toLowerCase().includes(lowerSearch));
2020
}, [tokens, search]);
21+
useEffect(() => {
22+
if (!isOpen) {
23+
setSearch('');
24+
document.body.style.overflow;
25+
} else {
26+
document.body.style.overflow = 'hidden';
27+
}
28+
}, [isOpen]);
2129

22-
if (!isOpen) return null;
30+
if (!isOpen) {
31+
return null;
32+
}
2333

2434
return (
2535
<div className="fixed inset-0 z-50 flex items-center justify-center p-4 bg-black/60 backdrop-blur-sm">
26-
<div className="bg-white dark:bg-dark-card border border-gray-200 dark:border-gray-700 w-full max-w-md rounded-2xl shadow-2xl overflow-hidden flex flex-col max-h-[80vh] transition-colors duration-300">
36+
<div className="bg-white dark:bg-dark-card border border-gray-200 dark:border-gray-700 w-full max-w-md rounded-2xl shadow-2xl overflow-hidden flex flex-col h-[80vh] transition-colors duration-300">
2737

2838
<div className="p-4 border-b border-gray-200 dark:border-gray-700 flex justify-between items-center">
2939
<h3 className="text-lg font-semibold text-gray-900 dark:text-white">Select Token</h3>
@@ -65,7 +75,7 @@ const TokenModal: React.FC<TokenModalProps> = ({ isOpen, onClose, tokens, onSele
6575
<span className="font-medium text-gray-900 dark:text-white group-hover:text-primary transition-colors">{token.symbol}</span>
6676
<span className="text-xs text-gray-500 dark:text-gray-400">Price: ${token.price.toFixed(4)}</span>
6777
</div>
68-
<div className="ml-auto text-gray-400 dark:text-gray-500 opacity-0 group-hover:opacity-100 transition-opacity">
78+
<div className="ml-auto text-gray-400 dark:text-primary opacity-0 group-hover:opacity-100 transition-opacity">
6979
Select
7080
</div>
7181
</button>

0 commit comments

Comments
 (0)