From 4da270396671ea8b5e19cb0e7270a22ab6c58f40 Mon Sep 17 00:00:00 2001 From: Lukas Date: Tue, 21 Apr 2026 18:47:18 +0200 Subject: [PATCH] Move constant inline styles into makeStyles --- Docs/Tasks.md | 6 +++- frontend/src/layouts/MainLayout.tsx | 12 +++++++- frontend/src/pages/DashboardPage.tsx | 8 ++++- frontend/src/pages/MapPage.tsx | 34 ++++++++++++++++++--- frontend/src/pages/jail/PatternsSection.tsx | 15 ++++++--- frontend/src/pages/jails/BanUnbanForm.tsx | 3 +- frontend/src/pages/jails/jailsPageStyles.ts | 3 ++ 7 files changed, 67 insertions(+), 14 deletions(-) diff --git a/Docs/Tasks.md b/Docs/Tasks.md index 9f4ae19..4aa6019 100644 --- a/Docs/Tasks.md +++ b/Docs/Tasks.md @@ -354,7 +354,11 @@ const source = timeRange === "24h" ? "fail2ban" : "archive"; --- -### TASK-018 — Move inline `style={{…}}` objects to `makeStyles` +### TASK-018 — Move inline `style={{…}}` objects to `makeStyles` (done) + +**Where fixed:** `frontend/src/pages/MapPage.tsx`, `frontend/src/pages/DashboardPage.tsx`, `frontend/src/pages/jail/PatternsSection.tsx`, `frontend/src/pages/jails/BanUnbanForm.tsx`, `frontend/src/layouts/MainLayout.tsx`, `frontend/src/pages/jails/jailsPageStyles.ts` + +**Summary:** Moved constant inline style objects into `makeStyles` classes and used `mergeClasses` for dynamic button layout in `MainLayout`. Kept runtime-dependent opacity and collapse state as conditional class application. **Where found:** 30+ instances across `frontend/src/pages/MapPage.tsx`, `frontend/src/pages/map/MapBansTable.tsx`, `frontend/src/pages/DashboardPage.tsx`, `frontend/src/pages/jail/PatternsSection.tsx`, `frontend/src/pages/jails/BanUnbanForm.tsx`, `frontend/src/layouts/MainLayout.tsx`, and others. diff --git a/frontend/src/layouts/MainLayout.tsx b/frontend/src/layouts/MainLayout.tsx index eb2b287..88799fd 100644 --- a/frontend/src/layouts/MainLayout.tsx +++ b/frontend/src/layouts/MainLayout.tsx @@ -145,6 +145,13 @@ const useStyles = makeStyles({ padding: tokens.spacingVerticalS, flexShrink: 0, }, + logoutButton: { + width: "100%", + justifyContent: "flex-start", + }, + logoutButtonCollapsed: { + justifyContent: "center", + }, versionText: { display: "block", color: tokens.colorNeutralForeground4, @@ -326,7 +333,10 @@ export function MainLayout(): React.JSX.Element { icon={} onClick={() => void handleLogout()} aria-label="Sign out" - style={{ width: "100%", justifyContent: collapsed ? "center" : "flex-start" }} + className={mergeClasses( + styles.logoutButton, + collapsed && styles.logoutButtonCollapsed, + )} > {!collapsed && "Sign out"} diff --git a/frontend/src/pages/DashboardPage.tsx b/frontend/src/pages/DashboardPage.tsx index a7cd5ca..a4c3d56 100644 --- a/frontend/src/pages/DashboardPage.tsx +++ b/frontend/src/pages/DashboardPage.tsx @@ -31,6 +31,12 @@ const useStyles = makeStyles({ flexDirection: "column", gap: tokens.spacingVerticalM, }, + filterRow: { + display: "flex", + alignItems: "center", + gap: tokens.spacingHorizontalM, + flexWrap: "wrap", + }, sectionHeader: { display: "flex", alignItems: "center", @@ -89,7 +95,7 @@ export function DashboardPage(): React.JSX.Element { {/* ------------------------------------------------------------------ */} {/* Global filter bar */} {/* ------------------------------------------------------------------ */} -
+
-
+
{ @@ -193,7 +217,7 @@ export function MapPage(): React.JSX.Element { {/* Initial load spinner — only shown before the first data arrives. */} {loading && !error && !hasLoadedOnce && ( -
+
)} @@ -242,8 +266,8 @@ export function MapPage(): React.JSX.Element { {/* Summary line */} {/* ---------------------------------------------------------------- */} {!error && hasLoadedOnce && ( -
- +
+ {String(total)} total ban{total !== 1 ? "s" : ""} in the selected period {" · "} {String(Object.keys(countries).length)} countr{Object.keys(countries).length !== 1 ? "ies" : "y"} affected @@ -256,7 +280,7 @@ export function MapPage(): React.JSX.Element { {/* Companion bans table */} {/* ---------------------------------------------------------------- */} {!error && hasLoadedOnce && ( -
+
@@ -23,19 +30,19 @@ export function PatternsSection({ jail }: PatternsSectionProps): React.JSX.Eleme - + Fail Regex - + Ignore Regex {jail.actions.length > 0 && ( <> - + Actions diff --git a/frontend/src/pages/jails/BanUnbanForm.tsx b/frontend/src/pages/jails/BanUnbanForm.tsx index c128fef..20ecb55 100644 --- a/frontend/src/pages/jails/BanUnbanForm.tsx +++ b/frontend/src/pages/jails/BanUnbanForm.tsx @@ -7,7 +7,6 @@ import { MessageBarBody, Select, Text, - tokens, } from "@fluentui/react-components"; import { LockClosedRegular, LockOpenRegular } from "@fluentui/react-icons"; import { useCommonSectionStyles } from "../../components/commonStyles"; @@ -142,7 +141,7 @@ export function BanUnbanForm({ jailNames, onBan, onUnban }: BanUnbanFormProps):
- + Unban an IP
diff --git a/frontend/src/pages/jails/jailsPageStyles.ts b/frontend/src/pages/jails/jailsPageStyles.ts index 73ed484..4506c1c 100644 --- a/frontend/src/pages/jails/jailsPageStyles.ts +++ b/frontend/src/pages/jails/jailsPageStyles.ts @@ -43,4 +43,7 @@ export const useJailsPageStyles = makeStyles({ alignItems: "center", }, lookupLabel: { fontWeight: tokens.fontWeightSemibold }, + sectionHeadingSpacing: { + marginTop: tokens.spacingVerticalS, + }, });