Skip to content

Commit 15e5a02

Browse files
committed
[frontend] improve tooltip css
1 parent 3e20139 commit 15e5a02

File tree

1 file changed

+42
-18
lines changed

1 file changed

+42
-18
lines changed

frontend/src/components/TabStrip.tsx

Lines changed: 42 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,20 @@ import html2canvas from "html2canvas";
1515
import { setContextMenu } from "./Menu";
1616
import { browser } from "../main";
1717

18-
export const DragTab: Component<{
19-
active: boolean;
20-
id: number;
21-
tab: Tab;
22-
mousedown: (e: MouseEvent) => void;
23-
destroy: () => void;
24-
transitionend: () => void;
25-
}> = function (cx) {
18+
export const DragTab: Component<
19+
{
20+
active: boolean;
21+
id: number;
22+
tab: Tab;
23+
mousedown: (e: MouseEvent) => void;
24+
destroy: () => void;
25+
transitionend: () => void;
26+
},
27+
{
28+
tooltipActive: boolean;
29+
}
30+
> = function (cx) {
31+
this.tooltipActive = false;
2632
cx.mount = () => {
2733
setContextMenu(cx.root, [
2834
{
@@ -51,6 +57,9 @@ export const DragTab: Component<{
5157
},
5258
]);
5359
};
60+
61+
let hoverTimeout: number;
62+
5463
return (
5564
<div
5665
style="z-index: 0;"
@@ -62,19 +71,29 @@ export const DragTab: Component<{
6271
e.preventDefault();
6372
}}
6473
on:transitionend={() => {
65-
console.log("tr end");
6674
cx.root.style.transition = "";
6775
cx.root.style.zIndex = "0";
6876
this.transitionend();
6977
}}
78+
on:mouseenter={() => {
79+
if (hoverTimeout) clearTimeout(hoverTimeout);
80+
hoverTimeout = window.setTimeout(() => {
81+
this.tooltipActive = true;
82+
}, 500);
83+
}}
84+
on:mouseleave={() => {
85+
if (hoverTimeout) clearTimeout(hoverTimeout);
86+
this.tooltipActive = false;
87+
}}
7088
>
71-
<div class="tooltip">
72-
<span>{use(this.tab.title)}</span>
73-
<img src={use(this.tab.screenshot)} class="img" />
74-
{/* <div
89+
<div class="tooltip" class:active={use(this.tooltipActive)}>
90+
<span class="title">{use(this.tab.title)}</span>
91+
<span class="hostname">{use(this.tab.url.hostname)}</span>
92+
{/*<img src={use(this.tab.screenshot)} class="img" />*/}
93+
<div
7594
style={use`background: -moz-element(#tab${this.tab.id})`}
7695
class="img"
77-
></div> */}
96+
></div>
7897
</div>
7998
<div
8099
class="dragroot"
@@ -121,20 +140,25 @@ DragTab.style = css`
121140
top: 5em;
122141
left: 0;
123142
z-index: 1000;
124-
background: white;
125-
border: 5px solid red;
143+
background: var(--aboutbrowser-frame-bg);
144+
border-radius: 4px;
126145
width: 20em;
127146
/* height: 10em; */
128147
flex-direction: column;
129148
display: none;
130149
border-radius: 4px;
150+
padding: 0.5em;
151+
}
152+
.tooltip .hostname {
153+
font-size: 12px;
131154
}
132-
:scope:hover .tooltip {
155+
.tooltip.active {
133156
display: flex;
134157
}
158+
135159
.tooltip .img {
136160
width: 100%;
137-
/* height: 5em; */
161+
height: 5em;
138162
}
139163
140164
.main {

0 commit comments

Comments
 (0)