Skip to content

Commit 8f9dbad

Browse files
committed
Rewrote most of it to be in line with
Roey's seggustions.
1 parent 6173afe commit 8f9dbad

File tree

3 files changed

+40
-20
lines changed

3 files changed

+40
-20
lines changed
Lines changed: 12 additions & 0 deletions
Loading
Lines changed: 6 additions & 0 deletions
Loading

ui/src/components/search-result.tsx

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,20 @@ uses.
66

77
import React from 'react';
88

9-
import { FaConfluence, FaSlack, FaGoogleDrive } from "react-icons/fa";
9+
import { FaConfluence, FaSlack, FaGoogleDrive, FaUser } from "react-icons/fa";
1010

1111
// This imports the full-color icons
1212
import Slack from '../assets/images/slack.svg';
1313
import Confluence from '../assets/images/confluence.svg';
1414
import GoogleDrive from '../assets/images/google-drive.svg'
15+
import BlueFolder from '../assets/images/'
16+
import ProfileDefault from "../assets/images/profile-picture-default.svg"
17+
18+
const paths = {
19+
"slack": Slack,
20+
"confluence": Confluence,
21+
"google drive": GoogleDrive
22+
}
1523

1624
export interface TextPart {
1725
content: string
@@ -52,7 +60,7 @@ export const SearchResult = (props: SearchResultProps) => {
5260
<a className="relative text-sm float-right text-white right-2 top-2" href={props.url}>{props.score}%</a>
5361
<div className="flex flex-row items-start">
5462
<div className="relative w-[60px] h-[60px]">
55-
{ProfilePic(props.author_image_url, props.platform as Platform, props.type)}
63+
{ResultImage(props.platform as Platform, props.type, props.author_image_url)}
5664
</div>
5765
<p className='p-2 pt-0 ml-1 text-[#A3A3A3] text-sm font-poppins'>
5866
<a className="text-[24px] text-[#A78BF6] text-xl font-poppins font-medium hover:underline hover:cursor-pointer" href={props.url} target='_blank'>
@@ -110,7 +118,7 @@ export const SearchResult = (props: SearchResultProps) => {
110118
);
111119
}
112120

113-
export function getPlatformDisplayName(platform: Platfom) {
121+
export function getPlatformDisplayName(platform: Platform) {
114122
// This converts the platform name to title case for display purposes.
115123
// example input : "google drive"
116124
// example output: "Google Drive"
@@ -142,33 +150,27 @@ function getSmallIconByPlatform(platform: Platform) {
142150
}
143151

144152

145-
function ProfilePic(profilePicture, platform, ResultType) {
153+
function ResultImage(platform: Platform, resultType: ResultType, profilePicture = ProfileDefault) {
146154
/*
147155
This function displays an image: either a profile picture or a logo.
148-
The first parameter is the path/url to the profile picture.
149-
The second parameter is the platform name.
156+
The first parameter is the platform name.
157+
The second parameter is
150158
*/
151-
platform = platform.toLowerCase();
152-
let profileStyle = "rounded-full w-full h-full object-cover";
153-
let lilLogoStyle = "company-logo rounded-full w-1/2 h-1/2 absolute object-cover -right-1.5 -bottom-1.5 bg-white"
154-
if (platform === "slack" && ResultType === "comment") {
159+
const profileStyle = "rounded-full w-full h-full object-cover";
160+
const lilLogoStyle = "company-logo rounded-full w-1/2 h-1/2 absolute object-cover -right-1.5 -bottom-1.5 bg-white";
161+
const full = "w-full h-full"
162+
if (resultType === "message") {
155163
return (
156-
<div className="w-full h-full">
164+
<div className={full}>
157165
<img className={profileStyle} alt="Profile" src={profilePicture} />
158166
<img src={Slack} alt={platform} className={lilLogoStyle} />
159167
</div>
160168
);
161169
}
162170
else {
163-
let classes = "w-full h-full"
164-
if (platform === "confluence") {
165-
return (
166-
<img className={classes} alt="Profile" src={Confluence} />
167-
);
168-
}
169-
if (platform === "google drive") {
170-
return <img className={classes} alt="Profile" src={GoogleDrive} />
171-
}
171+
return (
172+
<img src={paths[platform]} className={full} alt={platform} />
173+
);
172174
}
173175
}
174176

0 commit comments

Comments
 (0)