Skip to content

Commit

Permalink
quick unification of icons
Browse files Browse the repository at this point in the history
  • Loading branch information
pablonyx committed Dec 1, 2024
1 parent b46d73b commit 7eee68d
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 21 deletions.
16 changes: 3 additions & 13 deletions web/src/app/chat/documentSidebar/ChatDocumentDisplay.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { MetadataBadge } from "@/components/MetadataBadge";
import faviconFetch from "favicon-fetch";
import { useContext } from "react";
import { SettingsContext } from "@/components/settings/SettingsProvider";
import { ResultSearchIcon } from "@/components/SearchIcon";

interface DocumentDisplayProps {
document: DanswerDocument;
Expand Down Expand Up @@ -72,11 +73,6 @@ export function ChatDocumentDisplay({
return null;
}

const faviconUrl =
(isInternet || document.source_type === "web") && document.link
? faviconFetch({ uri: document.link })
: null;

return (
<div className={`opacity-100 ${modal ? "w-[90vw]" : "w-full"}`}>
<div
Expand All @@ -91,14 +87,8 @@ export function ChatDocumentDisplay({
className="cursor-pointer flex flex-col px-2 py-1.5"
>
<div className="line-clamp-1 mb-1 flex h-6 items-center gap-2 text-xs">
{faviconUrl ? (
<img
alt="Favicon"
width="18"
height="18"
className="rounded-full bg-gray-200 object-cover"
src={faviconUrl}
/>
{document.is_internet || document.source_type === "web" ? (
<ResultSearchIcon url={document.link} />
) : (
<SourceIcon sourceType={document.source_type} iconSize={18} />
)}
Expand Down
10 changes: 3 additions & 7 deletions web/src/app/chat/message/Messages.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ import {
GithubIcon,
GlobeIcon,
LikeFeedbackIcon,
SearchIcon,
} from "@/components/icons/icons";
import {
CustomTooltip,
Expand Down Expand Up @@ -70,6 +71,7 @@ import FirstSourceCard, {
SeeMoreBlock,
} from "@/components/chat_search/sources/firstsourcecard";
import { getSourceMetadata, SOURCE_METADATA_MAP } from "@/lib/sources";
import { ResultSearchIcon } from "@/components/SearchIcon";

const TOOLS_WITH_CUSTOM_HANDLING = [
SEARCH_TOOL_NAME,
Expand Down Expand Up @@ -332,13 +334,7 @@ export const AIMessage = ({

const icon =
associatedDoc?.source_type == "web" ? (
<img
className="my-0 py-0"
src={`https://www.google.com/s2/favicons?domain=${
new URL(associatedDoc.link).hostname
}`}
alt="favicon"
/>
<ResultSearchIcon url={associatedDoc.link} />
) : (
getIcon(
associatedDoc?.source_type || "web",
Expand Down
11 changes: 11 additions & 0 deletions web/src/components/SearchIcon.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
export function ResultSearchIcon({ url }: { url: string }) {
return (
<img
className="my-0 py-0"
src={`https://www.google.com/s2/favicons?domain=${new URL(url).hostname}`}
alt="favicon"
height={18}
width={18}
/>
);
}
3 changes: 2 additions & 1 deletion web/src/components/chat_search/sources/firstsourcecard.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { ResultSearchIcon } from "@/components/SearchIcon";
import { SearchResultIcon } from "@/components/SearchResultIcon";
import { SourceIcon } from "@/components/SourceIcon";
import { DanswerDocument } from "@/lib/search/interfaces";
Expand All @@ -13,7 +14,7 @@ export default function FirstSourceCard({ doc }: { doc: DanswerDocument }) {
>
<div className="line-clamp-1 font-semibold text-ellipsis text-text-900 flex h-6 items-center gap-2 text-sm">
{doc.is_internet || doc.source_type === "web" ? (
<SearchResultIcon url={doc.link} />
<ResultSearchIcon url={doc.link} />
) : (
<SourceIcon sourceType={doc.source_type} iconSize={18} />
)}
Expand Down

0 comments on commit 7eee68d

Please sign in to comment.