refactor(admin): use CSS custom properties for bar chart heights

Refactors the admin dashboard bar charts to use CSS custom properties (`--bar-height`) instead of fragile inline `height` styles.

Changes include:
- Updating the HTML templates to pass the height as a CSS variable.
- Converting the `.bar-chart` layout from Flexbox to CSS Grid for more consistent column distribution.
- Using absolute positioning for `.bar-chart-bar` inside `.bar-chart-track`.
- Adding a Go test to verify that the dashboard renders the CSS variable and no longer uses inline height styles.
This commit is contained in:
2026-06-01 12:01:39 +03:00
parent 48722f0aab
commit 9a5be44a7f
3 changed files with 55 additions and 19 deletions

View File

@@ -724,6 +724,28 @@ func TestAdminOverviewChartsUseZeroAndFullHeights(t *testing.T) {
}
}
func TestAdminOverviewRendersBarHeightVariables(t *testing.T) {
app, cleanup := newTestApp(t)
defer cleanup()
adminToken := createAdminSession(t, app)
uploadThroughApp(t, app)
request := httptest.NewRequest(http.MethodGet, "/admin", nil)
request.AddCookie(&http.Cookie{Name: userSessionCookieName, Value: adminToken})
response := httptest.NewRecorder()
app.AdminDashboard(response, request)
if response.Code != http.StatusOK {
t.Fatalf("AdminDashboard status = %d, body = %s", response.Code, response.Body.String())
}
body := response.Body.String()
if !strings.Contains(body, "--bar-height: 100%") {
t.Fatalf("admin overview did not render a full-height bar: %s", body)
}
if strings.Contains(body, `style="height:`) {
t.Fatalf("admin overview still uses fragile percent height styles: %s", body)
}
}
func TestAdminStorageProviderPagesOnlyRenderRelevantFields(t *testing.T) {
app, cleanup := newTestApp(t)
defer cleanup()