Refactor: Replace inline style objects with makeStyles classes
Moved all static layout properties (display, gap, margin, padding, colour) from inline style props to makeStyles classes in: - MapBansTable.tsx: Pagination row flexbox layout - JailDetailPage.tsx: Link styling for textDecoration - HistoryPage.tsx: Summary text styling - IpDetailView.tsx: Loading container and text formatting Kept inline styles only for genuinely dynamic values: - WorldMap.tsx: Tooltip position (follows mouse) - TopCountriesPieChart.tsx: Legend color (from recharts data) - TopCountriesBarChart.tsx: Chart height (derives from data length) This change improves performance by leveraging Griffel's atomic CSS cache and ensures consistency with the established Fluent UI pattern. Updated Docs/Web-Development.md with explicit rule: inline styles only for runtime-dynamic values, all static properties go in makeStyles. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
@@ -1,23 +1,3 @@
|
||||
### T-19 · Move `DashboardFilterProvider` — page-scoped provider in wrong directory
|
||||
|
||||
**Where found:** `frontend/src/providers/DashboardFilterProvider.tsx` — instantiated only inside `DashboardPage.tsx`
|
||||
|
||||
**Why this is needed:** The `providers/` directory implies app-wide providers (alongside `AuthProvider`, `ThemeProvider`, `TimezoneProvider`). `DashboardFilterProvider` wraps only `DashboardPageContent` and is not used anywhere else. Its placement implies reuse that doesn't exist, misleading future contributors about its scope.
|
||||
|
||||
**Goal:** Co-located with its only consumer.
|
||||
|
||||
**What to do:**
|
||||
1. Move `DashboardFilterProvider.tsx` to `frontend/src/pages/` (alongside `DashboardPage.tsx`) or to `frontend/src/pages/dashboard/` if the page is split into a subdirectory.
|
||||
2. Update imports in `DashboardPage.tsx` and any tests.
|
||||
|
||||
**Possible traps and issues:** Only `DashboardPage.tsx` imports it — confirm with grep before moving.
|
||||
|
||||
**Docs changes needed:** `Docs/Web-Development.md` — document what belongs in `providers/` (app-wide) vs co-located.
|
||||
|
||||
**Doc references:** `Docs/Web-Development.md`
|
||||
|
||||
---
|
||||
|
||||
### T-20 · Replace inline `style={{}}` objects with `makeStyles` classes
|
||||
|
||||
**Where found:** `frontend/src/pages/map/MapBansTable.tsx` (multiple), `pages/JailDetailPage.tsx`, `pages/HistoryPage.tsx`, `pages/history/IpDetailView.tsx`, `components/WorldMap.tsx`, `components/TopCountriesPieChart.tsx`, `components/TopCountriesBarChart.tsx`
|
||||
|
||||
@@ -257,6 +257,7 @@ export const darkTheme: Theme = createDarkTheme(brandColors);
|
||||
- Co-locate styles in the same file as the component they belong to, defined above the component function.
|
||||
- Use `mergeClasses` when combining multiple style sets conditionally.
|
||||
- Reference Fluent **design tokens** (`tokens.colorBrandBackground`, `tokens.fontSizeBase300`, etc.) instead of hard-coded values — this ensures consistency and automatic theme support.
|
||||
- **Inline styles are only allowed for genuinely dynamic values** (e.g., tooltip position calculated from mouse position, or height derived from data count). All static layout properties (`display`, `gap`, `margin`, `padding`, colour) must go in `makeStyles`.
|
||||
|
||||
```tsx
|
||||
import { makeStyles, tokens, mergeClasses } from "@fluentui/react-components";
|
||||
|
||||
Reference in New Issue
Block a user