Skip to content

Commit 4fe426f

Browse files
committed
different ui for draggable and non draggable tabs
1 parent bf4f506 commit 4fe426f

File tree

1 file changed

+28
-2
lines changed

1 file changed

+28
-2
lines changed

apps/array/src/renderer/features/panels/components/DraggableTab.tsx

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { useSortable } from "@dnd-kit/react/sortable";
22
import { Cross2Icon } from "@radix-ui/react-icons";
3-
import { Box, Flex, IconButton, Text } from "@radix-ui/themes";
3+
import { Box, Button, Flex, IconButton, Text } from "@radix-ui/themes";
44
import type React from "react";
55

66
interface DraggableTabProps {
@@ -40,6 +40,32 @@ export const DraggableTab: React.FC<DraggableTabProps> = ({
4040
disabled: !draggable,
4141
});
4242

43+
if (!draggable) {
44+
return (
45+
<Flex align="center" flexShrink="0" ml="2" mr="2" px="2" py="1">
46+
<Button
47+
variant="ghost"
48+
color="gray"
49+
size="1"
50+
onClick={onSelect}
51+
style={{
52+
backgroundColor: isActive ? "var(--gray-a3)" : undefined,
53+
}}
54+
>
55+
{icon && (
56+
<Box style={{ display: "flex", alignItems: "center" }}>{icon}</Box>
57+
)}
58+
{label}
59+
{hasUnsavedChanges && (
60+
<Text size="1" style={{ color: "var(--amber-9)" }}>
61+
62+
</Text>
63+
)}
64+
</Button>
65+
</Flex>
66+
);
67+
}
68+
4369
return (
4470
<Flex
4571
ref={ref}
@@ -49,7 +75,7 @@ export const DraggableTab: React.FC<DraggableTabProps> = ({
4975
align="center"
5076
gap="2"
5177
px="4"
52-
className={`group relative select-none border-r border-b-2 transition-colors ${draggable ? "cursor-grab" : "cursor-default"}`}
78+
className="group relative cursor-grab select-none border-r border-b-2 transition-colors"
5379
style={{
5480
backgroundColor: isActive ? "var(--accent-3)" : "transparent",
5581
borderRightColor: "var(--gray-6)",

0 commit comments

Comments
 (0)