Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
sagemathinc
GitHub Repository: sagemathinc/cocalc
Path: blob/master/src/packages/frontend/components/dnd/drag-overlay-content.tsx
10799 views
1
// Generic drag overlay label shown next to the cursor during DnD.
2
// Used by both file explorer and frame editor for consistent appearance.
3
4
import { Icon, type IconName } from "@cocalc/frontend/components/icon";
5
import { COLORS } from "@cocalc/util/theme";
6
import { DRAG_OVERLAY_STYLE } from "./config";
7
8
type Variant = "valid" | "neutral" | "invalid";
9
10
const VARIANT_COLORS: Record<Variant, string> = {
11
valid: `${COLORS.ANTD_LINK_BLUE}e0`,
12
neutral: `${COLORS.GRAY_D}d0`,
13
invalid: `${COLORS.ANTD_RED}e0`,
14
};
15
16
interface Props {
17
icon: IconName;
18
text: string;
19
variant: Variant;
20
}
21
22
export function DragOverlayContent({ icon, text, variant }: Props) {
23
return (
24
<div
25
style={{
26
...DRAG_OVERLAY_STYLE,
27
background: VARIANT_COLORS[variant],
28
color: COLORS.WHITE,
29
}}
30
>
31
<Icon name={icon} style={{ marginRight: 6 }} />
32
{text}
33
</div>
34
);
35
}
36
37