mirror of
https://github.com/sqlchat/sqlchat.git
synced 2025-09-24 16:46:05 +08:00
chore: update select kit component
This commit is contained in:
@ -228,7 +228,7 @@ const ConnectionSidebar = () => {
|
||||
{databaseList.length > 0 && (
|
||||
<div className="w-full sticky top-0 z-1 my-4">
|
||||
<Select
|
||||
className="w-full px-4 py-3"
|
||||
className="w-full px-4 py-3 text-base"
|
||||
value={currentConnectionCtx?.database?.name}
|
||||
itemList={databaseList.map((database) => {
|
||||
return {
|
||||
|
@ -32,7 +32,7 @@ const ThemeSelector = () => {
|
||||
settingStore.setTheme(theme);
|
||||
};
|
||||
|
||||
return <Select className="w-40" value={theme} itemList={themeItemList} onValueChange={handleThemeChange} />;
|
||||
return <Select className="w-auto min-w-[120px]" value={theme} itemList={themeItemList} onValueChange={handleThemeChange} />;
|
||||
};
|
||||
|
||||
export default ThemeSelector;
|
||||
|
@ -1,5 +1,5 @@
|
||||
import React, { ReactNode, forwardRef } from "react";
|
||||
import * as SelectUI from "@radix-ui/react-select";
|
||||
import React from "react";
|
||||
import Icon from "../Icon";
|
||||
|
||||
interface Props<T = any> {
|
||||
@ -21,7 +21,7 @@ const Select = (props: Props) => {
|
||||
<SelectUI.Trigger
|
||||
className={`${
|
||||
className || ""
|
||||
} flex flex-row justify-between items-center dark:text-gray-300 bg-white dark:bg-zinc-700 border dark:border-zinc-800 px-3 py-2 rounded-lg`}
|
||||
} flex flex-row justify-between items-center text-sm whitespace-nowrap dark:text-gray-300 bg-white dark:bg-zinc-700 border dark:border-zinc-800 px-3 py-2 rounded-lg`}
|
||||
>
|
||||
<SelectUI.Value placeholder={placeholder} />
|
||||
<SelectUI.Icon className="ml-1 w-5 h-auto shrink-0">
|
||||
@ -32,7 +32,7 @@ const Select = (props: Props) => {
|
||||
<SelectUI.Content
|
||||
className="z-[999] mt-1"
|
||||
style={{
|
||||
width: "var(--radix-select-trigger-width)",
|
||||
minWidth: "var(--radix-select-trigger-width)",
|
||||
}}
|
||||
position="popper"
|
||||
>
|
||||
@ -40,9 +40,18 @@ const Select = (props: Props) => {
|
||||
<SelectUI.Group>
|
||||
{placeholder && <SelectUI.Label className="w-full px-3 mt-2 mb-1 text-sm text-gray-400">{placeholder}</SelectUI.Label>}
|
||||
{itemList.map((item) => (
|
||||
<SelectItem key={item.label} className="whitespace-nowrap" value={item.value}>
|
||||
{item.label}
|
||||
</SelectItem>
|
||||
<SelectUI.Item
|
||||
key={item.label}
|
||||
className={`${
|
||||
className || ""
|
||||
} w-full px-3 py-2 whitespace-nowrap truncate text-ellipsis overflow-x-hidden text-sm rounded-lg flex flex-row justify-between items-center cursor-pointer hover:bg-gray-100 dark:hover:bg-zinc-800`}
|
||||
value={item.value}
|
||||
>
|
||||
<SelectUI.ItemText className="truncate">{item.label}</SelectUI.ItemText>
|
||||
<SelectUI.ItemIndicator className="w-5 h-auto">
|
||||
<Icon.BiCheck className="w-full h-auto" />
|
||||
</SelectUI.ItemIndicator>
|
||||
</SelectUI.Item>
|
||||
))}
|
||||
</SelectUI.Group>
|
||||
</SelectUI.Viewport>
|
||||
@ -52,29 +61,4 @@ const Select = (props: Props) => {
|
||||
);
|
||||
};
|
||||
|
||||
interface SelectItemProps {
|
||||
value: string;
|
||||
children: ReactNode;
|
||||
disabled?: boolean;
|
||||
className?: string;
|
||||
}
|
||||
|
||||
const SelectItem = forwardRef<HTMLDivElement, SelectItemProps>(({ children, className, ...props }, forwardedRef) => {
|
||||
return (
|
||||
<SelectUI.Item
|
||||
className={`${
|
||||
className || ""
|
||||
} w-full px-3 py-2 rounded-lg flex flex-row justify-between items-center cursor-pointer hover:bg-gray-100 dark:hover:bg-zinc-800`}
|
||||
{...props}
|
||||
ref={forwardedRef}
|
||||
>
|
||||
<SelectUI.ItemText>{children}</SelectUI.ItemText>
|
||||
<SelectUI.ItemIndicator className="w-5 h-auto">
|
||||
<Icon.BiCheck className="w-full h-auto" />
|
||||
</SelectUI.ItemIndicator>
|
||||
</SelectUI.Item>
|
||||
);
|
||||
});
|
||||
SelectItem.displayName = "SelectItem";
|
||||
|
||||
export default Select;
|
||||
|
Reference in New Issue
Block a user