Skip to content

Commit a1bc034

Browse files
authored
fix: replace inline SVGs with lucide-react icons and .svg images (#347)
1 parent 576328c commit a1bc034

11 files changed

Lines changed: 80 additions & 134 deletions

File tree

app/components/editor/common/EndpointSelector.tsx

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import React from 'react';
22
import { clsx } from 'clsx';
3+
import { Link } from 'lucide-react';
34
import { DEFAULT_ENDPOINT } from '@/app/components/hooks/useRemoteEnforcer';
45
import { useLang } from '@/app/context/LangContext';
56
import { useAutoCarousel } from '@/app/context/AutoCarouselContext';
@@ -67,12 +68,7 @@ export const EndpointSelector: React.FC = () => {
6768
}}
6869
className="border border-[#e13c3c] rounded px-2 py-1 text-[#e13c3c] hover:bg-[#e13c3c] hover:text-white flex items-center gap-1"
6970
>
70-
<svg className="w-4 h-4" viewBox="0 0 1024 1024" fill="currentColor">
71-
{/* eslint-disable-next-line max-len */}
72-
<path d="M607.934444 417.856853c-6.179746-6.1777-12.766768-11.746532-19.554358-16.910135l-0.01228 0.011256c-6.986111-6.719028-16.47216-10.857279-26.930349-10.857279-21.464871 0-38.864146 17.400299-38.864146 38.864146 0 9.497305 3.411703 18.196431 9.071609 24.947182l-0.001023 0c0.001023 0.001023 0.00307 0.00307 0.005117 0.004093 2.718925 3.242857 5.953595 6.03853 9.585309 8.251941 3.664459 3.021823 7.261381 5.997598 10.624988 9.361205l3.203972 3.204995c40.279379 40.229237 28.254507 109.539812-12.024871 149.820214L371.157763 796.383956c-40.278355 40.229237-105.761766 40.229237-146.042167 0l-3.229554-3.231601c-40.281425-40.278355-40.281425-105.809861 0-145.991002l75.93546-75.909877c9.742898-7.733125 15.997346-19.668968 15.997346-33.072233 0-23.312962-18.898419-42.211381-42.211381-42.211381-8.797363 0-16.963347 2.693342-23.725354 7.297197-0.021489-0.045025-0.044002-0.088004-0.066515-0.134053l-0.809435 0.757247c-2.989077 2.148943-5.691629 4.669346-8.025791 7.510044l-78.913281 73.841775c-74.178443 74.229608-74.178443 195.632609 0 269.758863l3.203972 3.202948c74.178443 74.127278 195.529255 74.127278 269.707698 0l171.829484-171.880649c74.076112-74.17435 80.357166-191.184297 6.282077-265.311575L607.934444 417.856853z" />
73-
{/* eslint-disable-next-line max-len */}
74-
<path d="M855.61957 165.804257l-3.203972-3.203972c-74.17742-74.178443-195.528232-74.178443-269.706675 0L410.87944 334.479911c-74.178443 74.178443-78.263481 181.296089-4.085038 255.522628l3.152806 3.104711c3.368724 3.367701 6.865361 6.54302 10.434653 9.588379 2.583848 2.885723 5.618974 5.355985 8.992815 7.309476 0.025583 0.020466 0.052189 0.041956 0.077771 0.062422l0.011256-0.010233c5.377474 3.092431 11.608386 4.870938 18.257829 4.870938 20.263509 0 36.68962-16.428158 36.68962-36.68962 0-5.719258-1.309832-11.132548-3.645017-15.95846l0 0c-4.850471-10.891048-13.930267-17.521049-20.210297-23.802102l-3.15383-3.102664c-40.278355-40.278355-24.982998-98.79612 15.295358-139.074476l171.930791-171.830507c40.179095-40.280402 105.685018-40.280402 145.965419 0l3.206018 3.152806c40.279379 40.281425 40.279379 105.838513 0 146.06775l-75.686796 75.737962c-10.296507 7.628748-16.97358 19.865443-16.97358 33.662681 0 23.12365 18.745946 41.87062 41.87062 41.87062 8.048303 0 15.563464-2.275833 21.944801-6.211469 0.048095 0.081864 0.093121 0.157589 0.141216 0.240477l1.173732-1.083681c3.616364-2.421142 6.828522-5.393847 9.529027-8.792247l79.766718-73.603345C929.798013 361.334535 929.798013 239.981676 855.61957 165.804257z" />
75-
</svg>
71+
<Link className="w-4 h-4" />
7672
</button>
7773
</TooltipTrigger>
7874
<TooltipContent

app/components/editor/common/EngineSelector.tsx

Lines changed: 48 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
import React, { useState, useRef } from 'react';
2+
import { ChevronDown } from 'lucide-react';
23
import { useLang } from '@/app/context/LangContext';
34
import { useAutoCarousel } from '@/app/context/AutoCarouselContext';
45
import * as DropdownMenu from '@radix-ui/react-dropdown-menu';
56
import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from '@/app/components/ui/tooltip';
67
import { EngineType, ENGINES } from '@/app/config/engineConfig';
78
import type { VersionInfo } from '@/app/components/hooks/useRemoteEnforcer';
9+
import { clsx } from 'clsx';
810

911
interface EngineSelectorProps {
1012
selectedEngine: EngineType;
@@ -15,10 +17,10 @@ interface EngineSelectorProps {
1517
}
1618

1719
export const EngineSelector: React.FC<EngineSelectorProps> = ({ selectedEngine, comparisonEngines, onEngineChange, versions, engineGithubLinks }) => {
18-
const { t } = useLang();
20+
const { t, theme } = useLang();
21+
const iconFilterClass = theme === 'dark' ? 'filter invert' : '';
1922
const { disableAutoCarousel } = useAutoCarousel();
2023
const [isOpen, setIsOpen] = useState(false);
21-
const dropdownRef = useRef<HTMLDivElement>(null);
2224
const [isComparisonOpen, setIsComparisonOpen] = useState(false);
2325
const engines = Object.entries(ENGINES).map(([id, config]) => {
2426
return {
@@ -82,17 +84,9 @@ export const EngineSelector: React.FC<EngineSelectorProps> = ({ selectedEngine,
8284
<span className="truncate text-sm">
8385
{displayText}
8486
</span>
85-
<svg
87+
<ChevronDown
8688
className={`w-3 h-3 flex-shrink-0 ml-2 transition-transform ${isOpen ? 'rotate-180' : ''}`}
87-
fill="currentColor"
88-
viewBox="0 0 20 20"
89-
>
90-
<path
91-
fillRule="evenodd"
92-
d="M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z"
93-
clipRule="evenodd"
94-
/>
95-
</svg>
89+
/>
9690
</button>
9791
</DropdownMenu.Trigger>
9892

@@ -141,20 +135,21 @@ export const EngineSelector: React.FC<EngineSelectorProps> = ({ selectedEngine,
141135
<button
142136
className={
143137
"border border-primary rounded-lg px-2 py-1 text-primary bg-secondary " +
144-
"hover:bg-primary hover:text-primary-foreground transition-all duration-200"
138+
"hover:bg-primary hover:text-primary-foreground transition-all duration-200 " +
139+
"flex items-center justify-center"
145140
}
146-
>
147-
<svg className="w-4 h-4" viewBox="0 0 1024 1024" fill="currentColor">
148-
<path d={
149-
"M116.364 837.818h279.272v93.091H23.273V93.091h372.363v93.09H116.364v651.637z " +
150-
"m512 0h93.09v93.091h-93.09v-93.09z m139.636 0h93.09v93.091H768v-93.09z " +
151-
"m139.636 93.091v-93.09h93.091v93.09h-93.09z m0-325.818V512h93.091v93.09h-93.09z " +
152-
"m0 139.636v-93.09h93.091v93.09h-93.09z m0-279.272v-93.091h93.091v93.09h-93.09z " +
153-
"m0-139.637v-93.09h93.091v93.09h-93.09z m0-139.636V93.09h93.091v93.09h-93.09z " +
154-
"m-46.545 0H768V93.09h93.09v93.09z m-139.636 0h-93.091V93.09h93.09v93.09z " +
155-
"M488.727 0h93.091v1024h-93.09V0z"
156-
} />
157-
</svg>
141+
>
142+
<span
143+
className={clsx('w-4 h-4 inline-flex items-center justify-center')}
144+
style={{
145+
maskImage: "url('/compareEngines.svg')",
146+
maskRepeat: 'no-repeat',
147+
maskSize: 'contain',
148+
maskPosition: 'center center',
149+
backgroundColor: 'currentColor',
150+
transition: 'opacity 0.2s, filter 0.5s',
151+
}}
152+
/>
158153
</button>
159154
</DropdownMenu.Trigger>
160155
</TooltipTrigger>
@@ -209,45 +204,39 @@ export const EngineSelector: React.FC<EngineSelectorProps> = ({ selectedEngine,
209204
</DropdownMenu.Content>
210205
</DropdownMenu.Root>
211206

212-
<TooltipProvider>
213-
<Tooltip>
214-
<TooltipTrigger asChild>
215-
<a
216-
href={engineGithubLinks[selectedEngine]}
217-
target="_blank"
218-
rel="noopener noreferrer"
219-
className="text-primary hover:text-primary/80 transition-colors"
220-
>
221-
<svg
222-
xmlns="http://www.w3.org/2000/svg"
223-
width="20"
224-
height="20"
225-
viewBox="0 0 24 24"
226-
fill="currentColor"
227-
>
228-
<path d={
229-
"M12 0c-6.626 0-12 5.373-12 12 0 5.302 3.438 9.8 " +
230-
"8.207 11.387.599.111.793-.261.793-.577v-2.234c-3.338.726-4.033-1.416-4.033-1.416 " +
231-
"-.546-1.387-1.333-1.756-1.333-1.756-1.089-.745.083-.729.083-.729 1.205.084 1.839 1.237 1.839 1.237 " +
232-
"1.07 1.834 2.807 1.304 3.492.997.107-.775.418-1.305.762-1.604-2.665-.305-5.467-1.334-5.467-5.931 " +
233-
"0-1.311.469-2.381 1.236-3.221-.124-.303-.535-1.524.117-3.176 0 0 1.008-.322 3.301 1.23.957-.266 " +
234-
"1.983-.399 3.003-.404 1.02.005 2.047.138 3.006.404 2.291-1.552 3.297-1.23 3.297-1.30.653 1.653 " +
235-
".242 2.874.118 3.176.77.84 1.235 1.911 1.235 3.221 0 4.609-2.807 5.624-5.479 5.921.43.372.823 " +
236-
"1.102.823 2.222v3.293c0 .319.192.694.801.576 4.765-1.589 8.199-6.086 8.199-11.386 0-6.627-5.373-12-12-12z"
237-
} />
238-
</svg>
239-
</a>
240-
</TooltipTrigger>
207+
<TooltipProvider>
208+
<Tooltip>
209+
<TooltipTrigger asChild>
210+
<a
211+
href={engineGithubLinks[selectedEngine]}
212+
target="_blank"
213+
rel="noopener noreferrer"
214+
className="text-primary hover:text-primary/80 transition-colors group"
215+
>
216+
<span
217+
className={clsx('w-5 h-5 inline-flex items-center justify-center transition-opacity duration-200 group-hover:opacity-80')}
218+
style={{
219+
maskImage: "url('/github.svg')",
220+
maskRepeat: 'no-repeat',
221+
maskSize: 'contain',
222+
maskPosition: 'center center',
223+
backgroundColor: 'currentColor',
224+
transition: 'opacity 0.2s, filter 0.5s',
225+
verticalAlign: 'middle',
226+
}}
227+
/>
228+
</a>
229+
</TooltipTrigger>
241230
<TooltipContent
242231
className={
243232
"bg-white dark:bg-gray-800 text-primary " +
244233
"border border-primary"
245234
}
246235
>
247-
<p>{t('View Source Code')}</p>
248-
</TooltipContent>
249-
</Tooltip>
250-
</TooltipProvider>
251-
</div>
236+
<p>{t('View Source Code')}</p>
237+
</TooltipContent>
238+
</Tooltip>
239+
</TooltipProvider>
240+
</div>
252241
);
253242
};

app/components/editor/common/FileUploadButton.tsx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { useRef } from 'react';
22
import clsx from 'clsx';
3+
import { Upload } from 'lucide-react';
34
import { useLang } from '@/app/context/LangContext';
45
import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from '@/app/components/ui/tooltip';
56

@@ -56,10 +57,7 @@ export const FileUploadButton: React.FC<FileUploadButtonProps> = ({ onFileConten
5657
'shadow-sm hover:shadow-md',
5758
)}
5859
>
59-
<svg className="w-4 h-4" viewBox="0 0 1051 1024" fill="currentColor">
60-
{/* eslint-disable-next-line max-len */}
61-
<path d="M525.814398 698.649244a43.115789 43.115789 0 0 0 42.991894-42.991894V131.4536l180.268602 180.268602a43.983061 43.983061 0 0 0 60.709014 0 42.991894 42.991894 0 0 0 0-60.709014L582.31095 23.168542a79.293406 79.293406 0 0 0-111.506352 0L241.968784 251.013188a42.867998 42.867998 0 0 0 60.709014 60.709014L483.194192 131.4536v524.20375a42.991894 42.991894 0 0 0 42.620206 42.991894z M863.926437 117.08167a42.991894 42.991894 0 1 0 0 85.859891A102.09026 102.09026 0 0 1 966.388385 304.907925v531.26582a102.09026 102.09026 0 0 1-101.966364 101.966364H187.826255a102.09026 102.09026 0 0 1-101.966364-101.966364V304.907925a102.09026 102.09026 0 0 1 101.966364-101.966364 42.991894 42.991894 0 0 0 0-85.859891A188.074047 188.074047 0 0 0 0 304.907925v531.26582a188.074047 188.074047 0 0 0 187.826255 187.826255h676.100182a188.074047 188.074047 0 0 0 187.826255-187.826255V304.907925A188.074047 188.074047 0 0 0 863.926437 117.08167z" />
62-
</svg>
60+
<Upload className="w-4 h-4" />
6361
</button>
6462
</TooltipTrigger>
6563
<TooltipContent className="bg-white dark:bg-gray-800 text-primary border border-primary shadow-lg">

app/components/editor/common/MessageWithTooltip.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import React, { useRef, useState } from 'react';
22
import { clsx } from 'clsx';
3+
import { Check } from 'lucide-react';
34

45
interface MessageWithTooltipProps {
56
message: React.ReactNode;
@@ -60,9 +61,7 @@ export const MessageWithTooltip: React.FC<MessageWithTooltipProps> = ({ message,
6061
onMouseLeave={handleMouseLeave}
6162
>
6263
{isDoneMessage && (
63-
<svg className="w-5 h-5 flex-shrink-0" fill="currentColor" viewBox="0 0 24 24">
64-
<path d="M9 16.17L4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41z" />
65-
</svg>
64+
<Check className="w-5 h-5 flex-shrink-0" />
6665
)}
6766
{message}
6867
</div>

app/components/editor/index.tsx

Lines changed: 7 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import { StateEffect, StateField } from '@codemirror/state';
1111
import { javascriptLanguage } from '@codemirror/lang-javascript';
1212
import { linter, lintGutter } from '@codemirror/lint';
1313
import { PanelGroup, Panel, PanelResizeHandle } from 'react-resizable-panels';
14+
import { HelpCircle, ChevronLeft } from 'lucide-react';
1415
import { CasbinConfSupport } from '@/app/components/editor/casbin-mode/casbin-conf';
1516
import { CasbinPolicySupport } from '@/app/components/editor/casbin-mode/casbin-csv';
1617
import SidePanelChat from '@/app/components/editor/panels/SidePanelChat';
@@ -171,6 +172,7 @@ export const EditorScreen = () => {
171172
};
172173

173174
const textClass = clsx(theme === 'dark' ? 'text-gray-200' : 'text-gray-800');
175+
const iconFilterClass = theme === 'dark' ? '' : 'filter invert';
174176

175177
useEffect(() => {
176178
// Define a StateEffect and StateField to manage line decorations
@@ -263,17 +265,7 @@ export const EditorScreen = () => {
263265
'flex items-center gap-2',
264266
)}
265267
>
266-
<svg className="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
267-
<path
268-
strokeLinecap="round"
269-
strokeLinejoin="round"
270-
strokeWidth={2}
271-
d="M4 6a2 2 0 012-2h2a2 2 0 012 2v2a2 2 0 01-2 2H6a2 2 0 01-2-2V6z
272-
M14 6a2 2 0 012-2h2a2 2 0 012 2v2a2 2 0 01-2 2h-2a2 2 0 01-2-2V6z
273-
M4 16a2 2 0 012-2h2a2 2 0 012 2v2a2 2 0 01-2 2H6a2 2 0 01-2-2v-2z
274-
M14 16a2 2 0 012-2h2a2 2 0 012 2v2a2 2 0 01-2 2h-2a2 2 0 01-2-2v-2z"
275-
/>
276-
</svg>
268+
<img src="/modelGallery.svg" alt="Model Gallery" className={clsx('w-5 h-5', iconFilterClass)} />
277269
<span>{t('Model Gallery')}</span>
278270
</a>
279271
</div>
@@ -464,17 +456,7 @@ export const EditorScreen = () => {
464456
}
465457
}}
466458
>
467-
<svg className="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
468-
<path
469-
strokeLinecap="round"
470-
strokeLinejoin="round"
471-
strokeWidth={2}
472-
d={
473-
'M8.228 9c.549-1.165 2.03-2 3.772-2 2.21 0 4 1.343 4 3 0 1.4-1.278 2.575-3.006 2.907' +
474-
'-.542.104-.994.54-.994 1.093m0 3h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z'
475-
}
476-
/>
477-
</svg>
459+
<HelpCircle className="w-4 h-4" />
478460
<span>{t('Explain it')}</span>
479461
</button>
480462
</div>
@@ -562,15 +544,12 @@ export const EditorScreen = () => {
562544
return setShowCustomConfig(!showCustomConfig);
563545
}}
564546
>
565-
<svg
547+
<ChevronLeft
566548
className={clsx('h-5 w-5')}
567549
style={{
568550
transform: showCustomConfig ? 'rotateZ(90deg)' : 'rotateZ(-90deg)',
569551
}}
570-
viewBox="0 0 24 24"
571-
>
572-
<path fill={'currentColor'} d="M15.41,16.58L10.83,12L15.41,7.41L14,6L8,12L14,18L15.41,16.58Z" />
573-
</svg>
552+
/>
574553
</button>
575554
</div>
576555
</div>
@@ -702,17 +681,7 @@ export const EditorScreen = () => {
702681
}
703682
}}
704683
>
705-
<svg className="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
706-
<path
707-
strokeLinecap="round"
708-
strokeLinejoin="round"
709-
strokeWidth={2}
710-
d={
711-
'M8.228 9c.549-1.165 2.03-2 3.772-2 2.21 0 4 1.343 4 3 0 1.4-1.278 2.575-3.006 2.907' +
712-
'-.542.104-.994.54-.994 1.093m0 3h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z'
713-
}
714-
/>
715-
</svg>
684+
<HelpCircle className="w-4 h-4" />
716685
<span>{t('Explain it')}</span>
717686
</button>
718687
</div>

app/components/editor/panels/ModelToolbar.tsx

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { clsx } from 'clsx';
22
import * as DropdownMenu from '@radix-ui/react-dropdown-menu';
33
import * as Switch from '@radix-ui/react-switch';
4+
import { ChevronDown } from 'lucide-react';
45
import { FileUploadButton } from '@/app/components/editor/common/FileUploadButton';
56
import { example } from '@/app/components/editor/casbin-mode/example';
67
import { useLang } from '@/app/context/LangContext';
@@ -65,14 +66,7 @@ export const ModelToolbar = ({ modelKind, setModelKind, setRequestResults, setMo
6566
<span className="truncate text-sm">
6667
{modelKind ? example[modelKind]?.name : t('Select your model')}
6768
</span>
68-
{/* Dropdown arrow icon */}
69-
<svg className="w-3 h-3 flex-shrink-0 ml-2" fill="currentColor" viewBox="0 0 20 20">
70-
<path
71-
fillRule="evenodd"
72-
d="M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z"
73-
clipRule="evenodd"
74-
/>
75-
</svg>
69+
<ChevronDown className="w-3 h-3 flex-shrink-0 ml-2" />
7670
</button>
7771
</DropdownMenu.Trigger>
7872

app/components/editor/panels/SidePanelChat.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { useState, useEffect, forwardRef, useImperativeHandle } from 'react';
2+
import { X } from 'lucide-react';
23
import { extractPageContent } from '@/app/utils/contentExtractor';
34
import { useLang } from '@/app/context/LangContext';
45
import { clsx } from 'clsx';
@@ -53,9 +54,7 @@ const SidePanelChat = forwardRef<any, { onOpenChange?: (open: boolean) => void;
5354
<div>AI Assistant</div>
5455
</a>
5556
<button onClick={toggleDrawer} className="text-gray-500 hover:text-gray-700">
56-
<svg className="w-6 h-6" fill="none" stroke="currentColor" viewBox="0 0 24 24">
57-
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M6 18L18 6M6 6l12 12" />
58-
</svg>
57+
<X className="w-6 h-6" />
5958
</button>
6059
</div>
6160
<div className="flex-1 h-[calc(100%-60px)]">

0 commit comments

Comments
 (0)