Skip to content

Commit 170de07

Browse files
committed
feat: expand db tile on info icon hover
1 parent b09bf4d commit 170de07

2 files changed

Lines changed: 43 additions & 9 deletions

File tree

src/Visualizer/components/DatabaseMenuSidebar.tsx

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { useState, useEffect } from "react";
22
import { markdown } from "../helpers";
3-
import { CloseIcon } from "../components";
3+
import { CloseIcon, InfoIcon } from "../components";
44
import { DatabaseMenuPopupProps } from "../types";
55
import databases from "../../config/databases";
66

@@ -9,6 +9,7 @@ export function DatabaseMenuSidebar(props: DatabaseMenuPopupProps) {
99
const [parsedSubheadline, setParsedSubheadline] = useState<string>("");
1010
const [parsedTeasers, setParsedTeasers] = useState<Map<string, string>>(new Map());
1111
const [parsedDescriptions, setParsedDescriptions] = useState<Map<string, string>>(new Map());
12+
const [expandedTile, setExpandedTile] = useState<string | null>(null);
1213

1314
useEffect(() => {
1415
// Load headline
@@ -56,11 +57,14 @@ export function DatabaseMenuSidebar(props: DatabaseMenuPopupProps) {
5657

5758
<div className="database-menu-sidebar__body">
5859
{Object.keys(databases).map((databaseName, index) => {
60+
const isExpanded = expandedTile === databaseName;
61+
5962
return (
6063
<a
6164
href={databaseHref(databaseName)}
6265
key={databaseName}
63-
className="database-tile">
66+
className={`database-tile ${isExpanded ? 'database-tile--expanded' : ''}`}
67+
onMouseLeave={() => setExpandedTile(null)}>
6468
<div className="database-tile__index">
6569
{String(index + 1).padStart(2, '0')}
6670
</div>
@@ -75,6 +79,14 @@ export function DatabaseMenuSidebar(props: DatabaseMenuPopupProps) {
7579
className="database-tile__description"
7680
dangerouslySetInnerHTML={{__html: parsedDescriptions.get(databaseName) || "" }} />
7781
</div>
82+
<div
83+
className="database-tile__info-icon"
84+
onMouseEnter={(e) => {
85+
e.preventDefault();
86+
setExpandedTile(databaseName);
87+
}}>
88+
<InfoIcon />
89+
</div>
7890
</a>
7991
)
8092
})}

src/Visualizer/style/database-menu-sidebar.scss

Lines changed: 29 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -72,16 +72,20 @@
7272
color: inherit;
7373
transition: all 0.3s ease;
7474
overflow: visible;
75+
background: none;
7576

76-
&:hover {
77+
&--expanded {
7778
transform: translateY(-4px);
7879
box-shadow: 0 8px 16px rgba(0, 0, 0, 0.15);
7980
border-color: #4A90E2;
81+
border-radius: 12px 12px 0 0;
8082
z-index: 10;
8183

8284
.database-tile__description {
8385
max-height: 500px;
8486
opacity: 1;
87+
padding: 12px 20px;
88+
pointer-events: auto;
8589
}
8690
}
8791

@@ -110,16 +114,37 @@
110114
font-size: 15px;
111115
line-height: 1.5;
112116
color: #555;
117+
padding-right: 30px;
113118

114119
p {
115120
margin: 0;
116121
}
117122
}
118123

124+
&__info-icon {
125+
position: absolute;
126+
bottom: 12px;
127+
right: 12px;
128+
width: 20px;
129+
height: 20px;
130+
cursor: pointer;
131+
fill: #999;
132+
transition: fill 0.2s ease;
133+
134+
&:hover {
135+
fill: #4A90E2;
136+
}
137+
138+
svg {
139+
width: 100%;
140+
height: 100%;
141+
}
142+
}
143+
119144
&__description {
120145
position: absolute;
121-
left: 0;
122-
right: 0;
146+
left: -2px;
147+
right: -2px;
123148
top: 100%;
124149
max-height: 0;
125150
opacity: 0;
@@ -134,6 +159,7 @@
134159
border-radius: 0 0 12px 12px;
135160
padding: 0 20px;
136161
box-shadow: 0 8px 16px rgba(0, 0, 0, 0.15);
162+
pointer-events: none;
137163

138164
p {
139165
margin: 8px 0;
@@ -147,8 +173,4 @@
147173
}
148174
}
149175
}
150-
151-
&:hover &__description {
152-
padding: 12px 20px;
153-
}
154176
}

0 commit comments

Comments
 (0)