Skip to content

Commit 15ae2a1

Browse files
committed
added HoverText component
1 parent ab6a3a5 commit 15ae2a1

File tree

2 files changed

+41
-8
lines changed

2 files changed

+41
-8
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import { FC, ReactNode } from "react";
2+
3+
interface HoverTextProps {
4+
label: string;
5+
children: ReactNode;
6+
className?: string;
7+
}
8+
9+
const HoverText: FC<HoverTextProps> = (props) => {
10+
return (
11+
<div className={`${props.className} relative group`}>
12+
<div
13+
className="absolute whitespace-nowrap left-1/2 -translate-x-1/2 -top-7
14+
text-[.8rem] bg-gh-bg-secondary border border-solid border-gh-border pointer-events-none
15+
px-2 py-1 leading-none rounded-md shadow-xl text-gh-text-secondary z-[5]
16+
before:content-[''] before:w-2 before:h-2 before:bg-gh-bg-secondary
17+
before:absolute before:top-full before:left-1/2 before:-translate-x-1/2
18+
before:rotate-45 before:-translate-y-1/2 before:border-solid before:border-gh-border
19+
before:border-b before:border-r scale-80 opacity-0 group-hover:scale-100
20+
group-hover:opacity-100 transition-all duration-200"
21+
>
22+
{props.label}
23+
</div>
24+
25+
{props.children}
26+
</div>
27+
);
28+
};
29+
30+
export default HoverText;

client/src/components/input/LineInput.tsx

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { Badge, Line } from "../../types/line";
33
import { AiOutlinePlus } from "react-icons/ai";
44
import BlurOverlay from "../popups/BlurOverlay";
55
import LinePopup from "../popups/LinePopup";
6+
import HoverText from "../hover/HoverText";
67

78
interface InputProps {
89
line: string;
@@ -47,14 +48,16 @@ const LineInput: FC<InputProps> = (props) => {
4748
>
4849
<span>Badges: {badges.length}</span>
4950

50-
<button
51-
type="button"
52-
className="cursor-pointer ml-auto text-gh-text-secondary
53-
hover:text-gh-blue transition-all duration-150"
54-
onClick={() => setIsPopupOpen(true)}
55-
>
56-
<AiOutlinePlus />
57-
</button>
51+
<HoverText label="Add badge" className="ml-auto">
52+
<button
53+
type="button"
54+
className="cursor-pointer text-gh-text-secondary
55+
hover:text-gh-blue transition-all duration-150"
56+
onClick={() => setIsPopupOpen(true)}
57+
>
58+
<AiOutlinePlus />
59+
</button>
60+
</HoverText>
5861
</div>
5962
</div>
6063
);

0 commit comments

Comments
 (0)