Skip to content

Commit dd6284d

Browse files
committed
shared.tsx
1 parent c24bcda commit dd6284d

File tree

1 file changed

+76
-31
lines changed
  • gui/src/components/AssistantAndOrgListbox

1 file changed

+76
-31
lines changed

gui/src/components/AssistantAndOrgListbox/shared.tsx

Lines changed: 76 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,8 @@ import {
66
} from "@heroicons/react/24/outline";
77
import { useState } from "react";
88
import styled from "styled-components";
9-
import {
10-
defaultBorderRadius,
11-
lightGray,
12-
vscCommandCenterInactiveBorder,
13-
} from "..";
9+
import { lightGray } from "..";
10+
import { cn } from "../../util/cn";
1411
import { ToolTip } from "../gui/Tooltip";
1512

1613
export const OptionDiv = styled.div<{
@@ -47,11 +44,6 @@ export const OptionDiv = styled.div<{
4744

4845
export const MAX_HEIGHT_PX = 300;
4946

50-
export const Divider = styled.div`
51-
height: 0.5px;
52-
background-color: ${vscCommandCenterInactiveBorder};
53-
`;
54-
5547
interface ModelOptionProps {
5648
children: React.ReactNode;
5749
idx: number;
@@ -64,28 +56,81 @@ interface ModelOptionProps {
6456
onClickError?: (e: any) => void;
6557
}
6658

67-
const IconBase = styled.div<{ $hovered: boolean }>`
68-
width: 1.2em;
69-
height: 1.2em;
70-
cursor: pointer;
71-
padding: 4px;
72-
border-radius: ${defaultBorderRadius};
73-
opacity: ${(props) => (props.$hovered ? 0.75 : 0)};
74-
visibility: ${(props) => (props.$hovered ? "visible" : "hidden")};
75-
76-
&:hover {
77-
opacity: 1;
78-
background-color: ${lightGray}33;
79-
}
80-
`;
59+
interface IconBaseProps {
60+
$hovered: boolean;
61+
onClick?: (e: any) => void;
62+
className?: string;
63+
children?: React.ReactNode;
64+
[key: string]: any;
65+
}
66+
67+
function IconBase({
68+
$hovered,
69+
onClick,
70+
className,
71+
children,
72+
...props
73+
}: IconBaseProps) {
74+
return (
75+
<div
76+
className={cn(
77+
"rounded-default h-[1.2em] w-[1.2em] cursor-pointer p-1",
78+
$hovered ? "visible opacity-75" : "invisible opacity-0",
79+
"hover:bg-lightgray/20 hover:opacity-100",
80+
className,
81+
)}
82+
onClick={onClick}
83+
{...props}
84+
>
85+
{children}
86+
</div>
87+
);
88+
}
8189

82-
const StyledCog6ToothIcon = styled(IconBase).attrs({ as: Cog6ToothIcon })``;
83-
const StyledArrowTopRightOnSquareIcon = styled(IconBase).attrs({
84-
as: ArrowTopRightOnSquareIcon,
85-
})``;
86-
const StyledExclamationTriangleIcon = styled(IconBase).attrs({
87-
as: ExclamationTriangleIcon,
88-
})``;
90+
const StyledCog6ToothIcon = ({
91+
$hovered,
92+
onClick,
93+
}: {
94+
$hovered: boolean;
95+
onClick?: (e: any) => void;
96+
}) => (
97+
<IconBase $hovered={$hovered} onClick={onClick}>
98+
<Cog6ToothIcon />
99+
</IconBase>
100+
);
101+
102+
const StyledArrowTopRightOnSquareIcon = ({
103+
$hovered,
104+
onClick,
105+
}: {
106+
$hovered: boolean;
107+
onClick?: (e: any) => void;
108+
}) => (
109+
<IconBase $hovered={$hovered} onClick={onClick}>
110+
<ArrowTopRightOnSquareIcon />
111+
</IconBase>
112+
);
113+
114+
const StyledExclamationTriangleIcon = ({
115+
$hovered,
116+
onClick,
117+
className,
118+
...props
119+
}: {
120+
$hovered: boolean;
121+
onClick?: (e: any) => void;
122+
className?: string;
123+
[key: string]: any;
124+
}) => (
125+
<IconBase
126+
$hovered={$hovered}
127+
onClick={onClick}
128+
className={className}
129+
{...props}
130+
>
131+
<ExclamationTriangleIcon />
132+
</IconBase>
133+
);
89134

90135
export function Option({
91136
children,

0 commit comments

Comments
 (0)