Skip to content

Commit 321dc0a

Browse files
Merge pull request #44 from move-elevator/fix/disk-space-icon-tooltip
fix: restore full-width disk space bar and fix icon tooltip clipping off-screen
2 parents 7fcfa6b + c57ccfa commit 321dc0a

2 files changed

Lines changed: 77 additions & 13 deletions

File tree

deployer/feature/dist/index/assets/css/style.css

Lines changed: 66 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -71,27 +71,86 @@ kbd[data-tooltip], .status[data-tooltip] {
7171
progress {
7272
height: .125rem;
7373
}
74+
.disk-space-bar {
75+
position: fixed;
76+
top: 0;
77+
left: 0;
78+
width: 100%;
79+
height: .3rem;
80+
background: rgba(0, 0, 0, .08);
81+
z-index: 9;
82+
}
83+
.disk-space-bar-fill {
84+
height: 100%;
85+
}
7486
.disk-space {
7587
position: fixed;
76-
top: .75rem;
88+
top: .65rem;
7789
left: .75rem;
7890
z-index: 10;
7991
}
8092
.disk-space-icon {
93+
position: relative;
8194
display: flex;
8295
align-items: center;
8396
justify-content: center;
84-
width: 2rem;
85-
height: 2rem;
86-
padding: 0;
87-
margin: 0;
88-
border: 0;
97+
width: 2.25rem;
98+
height: 2.25rem;
8999
border-radius: 50%;
90-
cursor: pointer;
100+
cursor: default;
101+
box-shadow: 0 2px 6px rgba(0, 0, 0, .28), 0 0 0 3px #fff;
102+
}
103+
.disk-space-icon:hover,
104+
.disk-space-icon:focus-visible {
105+
box-shadow: 0 2px 10px rgba(0, 0, 0, .4), 0 0 0 3px #fff;
106+
}
107+
.disk-space-icon:focus-visible {
108+
outline: 2px solid #fff;
109+
outline-offset: 2px;
91110
}
92111
.disk-space-icon svg {
93112
pointer-events: none;
94113
}
114+
.disk-space-icon[data-info]::after {
115+
content: attr(data-info);
116+
position: absolute;
117+
left: 0;
118+
top: calc(100% + .6rem);
119+
opacity: 0;
120+
pointer-events: none;
121+
background: #1d1d1b;
122+
color: #fff;
123+
font-size: .72rem;
124+
line-height: 1.45;
125+
padding: .5rem .65rem;
126+
border-radius: .4rem;
127+
width: max-content;
128+
max-width: 15.5rem;
129+
white-space: normal;
130+
box-shadow: 0 4px 14px rgba(0, 0, 0, .25);
131+
z-index: 20;
132+
}
133+
.disk-space-icon[data-info]:hover::after,
134+
.disk-space-icon[data-info]:focus-visible::after {
135+
opacity: 1;
136+
}
137+
@media (prefers-reduced-motion: no-preference) {
138+
.disk-space-icon {
139+
transition: transform .15s ease, box-shadow .15s ease;
140+
}
141+
.disk-space-icon:hover,
142+
.disk-space-icon:focus-visible {
143+
transform: scale(1.08);
144+
}
145+
.disk-space-icon[data-info]::after {
146+
transform: translateY(-4px);
147+
transition: opacity .15s ease, transform .15s ease;
148+
}
149+
.disk-space-icon[data-info]:hover::after,
150+
.disk-space-icon[data-info]:focus-visible::after {
151+
transform: translateY(0);
152+
}
153+
}
95154
h3 {
96155
width: max-content;
97156
}

deployer/feature/dist/index/src/Service/TemplateService.php

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,23 +43,28 @@ public function renderEntries(array $entries): string
4343
public function renderDiskSpace(IOService $ioService): string
4444
{
4545
$status = $ioService->getDiskSpaceStatus();
46-
$info = $ioService->getDiskFullSpacePercent() . "% used (" . $ioService->getDiskTotalFree() . " GB free of " . $ioService->getDiskTotalSpace() . " GB)";
46+
$percent = $ioService->getDiskFullSpacePercent();
47+
$color = $ioService->getDiskSpaceColor();
48+
$info = $percent . "% used (" . $ioService->getDiskTotalFree() . " GB free of " . $ioService->getDiskTotalSpace() . " GB)";
4749
if ($status !== 'green') {
4850
$info .= ". Low disk space, above " . $ioService->getDiskSpaceThreshold() . "%";
4951
}
5052
$info = htmlspecialchars($info, ENT_QUOTES);
5153

52-
return "<div class='disk-space'>" .
53-
"<button type='button' class='disk-space-icon' style='background-color:" . $ioService->getDiskSpaceColor() . "' data-tooltip='$info' aria-label='Disk space: $info'>" .
54+
return "<div class='disk-space-bar'><div class='disk-space-bar-fill' style='width:$percent%;background-color:$color'></div></div>" .
55+
"<div class='disk-space'>" .
56+
"<span class='disk-space-icon' role='img' tabindex='0' style='background-color:$color' data-info='$info' aria-label='Disk space: $info'>" .
5457
$this->getDiskIcon() .
55-
"</button>" .
58+
"</span>" .
5659
"</div>";
5760
}
5861

5962
private function getDiskIcon(): string
6063
{
61-
return "<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' width='16' height='16'>" .
62-
"<path fill='#fff' d='M12,3C7.58,3,4,4.79,4,7v10c0,2.21,3.58,4,8,4s8-1.79,8-4V7C20,4.79,16.42,3,12,3z M12,5c3.87,0,6,1.5,6,2c0,0.5-2.13,2-6,2S6,7.5,6,7C6,6.5,8.13,5,12,5z M18,17c0,0.5-2.13,2-6,2s-6-1.5-6-2v-2.35C7.61,15.5,9.72,16,12,16s4.39-0.5,6-1.35V17z M18,12c0,0.5-2.13,2-6,2s-6-1.5-6-2V9.65C7.61,10.5,9.72,11,12,11s4.39-0.5,6-1.35V12z'/>" .
64+
return "<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' width='18' height='18' fill='none' stroke='#fff' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'>" .
65+
"<ellipse cx='12' cy='5' rx='9' ry='3'/>" .
66+
"<path d='M21 12c0 1.66-4 3-9 3s-9-1.34-9-3'/>" .
67+
"<path d='M3 5v14c0 1.66 4 3 9 3s9-1.34 9-3V5'/>" .
6368
"</svg>";
6469
}
6570

0 commit comments

Comments
 (0)