toggle div icon
This commit is contained in:
parent
d2cbbbe86a
commit
5b58a81ca4
2 changed files with 26 additions and 13 deletions
|
|
@ -1,14 +1,16 @@
|
|||
import { ChevronDownIcon, ChevronRightIcon } from "@heroicons/react/24/outline";
|
||||
import { useState } from "react";
|
||||
import { ComponentType, useState } from "react";
|
||||
import { lightGray, vscBackground } from ".";
|
||||
|
||||
interface ToggleProps {
|
||||
children: React.ReactNode;
|
||||
title: React.ReactNode;
|
||||
icon?: ComponentType<React.SVGProps<SVGSVGElement>>;
|
||||
}
|
||||
|
||||
function ToggleDiv({ children, title }: ToggleProps) {
|
||||
function ToggleDiv({ children, title, icon: Icon }: ToggleProps) {
|
||||
const [open, setOpen] = useState(false);
|
||||
const [isHovered, setIsHovered] = useState(false);
|
||||
|
||||
return (
|
||||
<div
|
||||
|
|
@ -20,19 +22,27 @@ function ToggleDiv({ children, title }: ToggleProps) {
|
|||
<div
|
||||
className="flex cursor-pointer items-center justify-start text-xs text-gray-300"
|
||||
onClick={() => setOpen((prev) => !prev)}
|
||||
onMouseEnter={() => setIsHovered(true)}
|
||||
onMouseLeave={() => setIsHovered(false)}
|
||||
data-testid="context-items-peek"
|
||||
>
|
||||
<div className="relative mr-1 h-4 w-4">
|
||||
<ChevronRightIcon
|
||||
className={`absolute h-4 w-4 transition-all duration-200 ease-in-out text-[${lightGray}] ${
|
||||
open ? "rotate-90 opacity-0" : "rotate-0 opacity-100"
|
||||
}`}
|
||||
/>
|
||||
<ChevronDownIcon
|
||||
className={`absolute h-4 w-4 transition-all duration-200 ease-in-out text-[${lightGray}] ${
|
||||
open ? "rotate-0 opacity-100" : "-rotate-90 opacity-0"
|
||||
}`}
|
||||
/>
|
||||
{Icon && !isHovered ? (
|
||||
<Icon className={`absolute h-4 w-4 text-[${lightGray}]`} />
|
||||
) : (
|
||||
<>
|
||||
<ChevronRightIcon
|
||||
className={`absolute h-4 w-4 transition-all duration-200 ease-in-out text-[${lightGray}] ${
|
||||
open ? "rotate-90 opacity-0" : "rotate-0 opacity-100"
|
||||
}`}
|
||||
/>
|
||||
<ChevronDownIcon
|
||||
className={`absolute h-4 w-4 transition-all duration-200 ease-in-out text-[${lightGray}] ${
|
||||
open ? "rotate-0 opacity-100" : "-rotate-90 opacity-0"
|
||||
}`}
|
||||
/>
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
<span className="ml-1 text-xs text-gray-400 transition-colors duration-200">
|
||||
{title}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ import { ArrowTopRightOnSquareIcon } from "@heroicons/react/24/outline";
|
|||
import { ContextItemWithId } from "core";
|
||||
import { ctxItemToRifWithContents } from "core/commands/util";
|
||||
import { getUriPathBasename } from "core/util/uri";
|
||||
import { useContext, useMemo } from "react";
|
||||
import { ComponentType, useContext, useMemo } from "react";
|
||||
import { AnimatedEllipsis } from "../..";
|
||||
import { IdeMessengerContext } from "../../../context/IdeMessenger";
|
||||
import { useAppSelector } from "../../../redux/hooks";
|
||||
|
|
@ -16,6 +16,7 @@ import { NAMED_ICONS } from "../icons";
|
|||
interface ContextItemsPeekProps {
|
||||
contextItems?: ContextItemWithId[];
|
||||
isCurrentContextPeek: boolean;
|
||||
icon?: ComponentType<React.SVGProps<SVGSVGElement>>;
|
||||
}
|
||||
|
||||
interface ContextItemsPeekItemProps {
|
||||
|
|
@ -150,6 +151,7 @@ function ContextItemsPeekItem({ contextItem }: ContextItemsPeekItemProps) {
|
|||
function ContextItemsPeek({
|
||||
contextItems,
|
||||
isCurrentContextPeek,
|
||||
icon,
|
||||
}: ContextItemsPeekProps) {
|
||||
const ctxItems = useMemo(() => {
|
||||
return contextItems?.filter((ctxItem) => !ctxItem.hidden) ?? [];
|
||||
|
|
@ -165,6 +167,7 @@ function ContextItemsPeek({
|
|||
|
||||
return (
|
||||
<ToggleDiv
|
||||
icon={icon}
|
||||
title={
|
||||
isGatheringContext ? (
|
||||
<>
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue