feat: add icon for URL ctx item peek
This commit is contained in:
parent
ac9ab2719b
commit
e901cfdf4a
1 changed files with 8 additions and 2 deletions
|
|
@ -11,6 +11,7 @@ import { getIconFromDropdownItem } from "./MentionList";
|
|||
import { getBasename } from "core/util";
|
||||
import { RootState } from "../../redux/store";
|
||||
import { useSelector } from "react-redux";
|
||||
import { ArrowTopRightOnSquareIcon } from "@heroicons/react/24/outline";
|
||||
|
||||
interface ContextItemsPeekProps {
|
||||
contextItems?: ContextItemWithId[];
|
||||
|
|
@ -23,11 +24,12 @@ interface ContextItemsPeekItemProps {
|
|||
|
||||
function ContextItemsPeekItem({ contextItem }: ContextItemsPeekItemProps) {
|
||||
const ideMessenger = useContext(IdeMessengerContext);
|
||||
const isUrl = contextItem.uri?.type === "url";
|
||||
|
||||
function openContextItem() {
|
||||
const { uri, name, description, content } = contextItem;
|
||||
|
||||
if (uri?.type === "url") {
|
||||
if (isUrl) {
|
||||
ideMessenger.post("openUrl", uri.value);
|
||||
} else if (uri) {
|
||||
const isRangeInFile = name.includes(" (") && name.endsWith(")");
|
||||
|
|
@ -97,7 +99,7 @@ function ContextItemsPeekItem({ contextItem }: ContextItemsPeekItemProps) {
|
|||
return (
|
||||
<div
|
||||
onClick={openContextItem}
|
||||
className="mr-2 flex cursor-pointer items-center overflow-hidden text-ellipsis whitespace-nowrap rounded px-1.5 py-1 text-xs hover:bg-white/10"
|
||||
className="group mr-2 flex cursor-pointer items-center overflow-hidden text-ellipsis whitespace-nowrap rounded px-1.5 py-1 text-xs hover:bg-white/10"
|
||||
>
|
||||
<div className="flex w-full items-center">
|
||||
{getContextItemIcon()}
|
||||
|
|
@ -113,6 +115,10 @@ function ContextItemsPeekItem({ contextItem }: ContextItemsPeekItemProps) {
|
|||
: contextItem.description}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{isUrl && (
|
||||
<ArrowTopRightOnSquareIcon className="mx-2 h-4 w-4 flex-shrink-0 text-gray-400 opacity-0 group-hover:opacity-100" />
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue