Skip to content

Commit 0109682

Browse files
committed
Added icons to dropdown for UI
1 parent be8ab71 commit 0109682

2 files changed

Lines changed: 34 additions & 2 deletions

File tree

frontend/components/SearchBar.js

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
11
import React, { useState, useEffect } from 'react';
22
import Select from 'react-select';
3-
import { AiOutlineSend } from 'react-icons/ai';
3+
import { AiOutlineSend, AiFillPython } from 'react-icons/ai';
44
import { HiOutlineRefresh } from 'react-icons/hi';
5+
import { DiJavascript1 } from 'react-icons/di'; // JS icon
6+
import { MdDescription } from 'react-icons/md'; // Readme icon
7+
import { FaPython } from 'react-icons/fa';
8+
9+
10+
511

612
const SearchBar = ({ addFileToContext }) => {
713
const [selectedOptions, setSelectedOptions] = useState(null);
@@ -10,6 +16,27 @@ const SearchBar = ({ addFileToContext }) => {
1016
const [fileStatus, setFileStatus] = useState(null); // Add this state
1117

1218
const timetout = 1000;
19+
const fileIcon = (fileType) => {
20+
console.log(fileType);
21+
switch (fileType) {
22+
case 'py':
23+
return <span className='text-python-blue'><FaPython /></span>
24+
case 'js':
25+
return <span className='text-yellow-500'><DiJavascript1 /></span>
26+
case 'md':
27+
return <span className="text-black"><MdDescription /></span>
28+
default:
29+
return null;
30+
}
31+
};
32+
// Modify the option labels
33+
const formatOptionLabel = ({ value, label }) => (
34+
35+
< div className="flex items-center" >
36+
{fileIcon(value.split('.').pop())} <span className="ml-2">{label}</span>
37+
</div >
38+
39+
);
1340

1441
const handleChange = option => {
1542
setSelectedOptions(option);
@@ -156,6 +183,7 @@ const SearchBar = ({ addFileToContext }) => {
156183
styles={customStyles}
157184
closeMenuOnSelect={false}
158185
blurInputOnSelect={false}
186+
formatOptionLabel={formatOptionLabel} // Use the custom format here
159187
placeholder='Add File to Context'
160188
/>
161189
<button className='text-purple-700 ml-5 text-lg' onClick={sendFiles}>

frontend/tailwind.config.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,11 @@ module.exports = {
1313
'gradient-conic':
1414
'conic-gradient(from 180deg at 50% 50%, var(--tw-gradient-stops))',
1515
},
16-
},
16+
colors: {
17+
'python-blue': '#3776ab',
18+
'python-yellow': '#ffd43b',
19+
}
20+
}
1721
},
1822
plugins: [],
1923
}

0 commit comments

Comments
 (0)