Skip to content

refactor: extract shared Navbar and Footer components#2

Merged
bokiko merged 3 commits intomainfrom
auto/improve-2026-03-18
Mar 18, 2026
Merged

refactor: extract shared Navbar and Footer components#2
bokiko merged 3 commits intomainfrom
auto/improve-2026-03-18

Conversation

@bokiko
Copy link
Owner

@bokiko bokiko commented Mar 18, 2026

Summary

The navigation bar and footer were copy-pasted across 4 pages, totaling ~200 lines of duplicated JSX with no single source of truth.

Changes

  • New: web/src/components/Navbar.tsx โ€” shared nav component with:

    • usePathname-based active link highlighting (automatic, no per-page hardcoding)
    • Declarative NAV_LINKS config array โ€” add a nav link in one place
    • Mobile menu with ARIA aria-expanded and aria-controls attributes
    • Sticky top bar, backdrop blur, focus rings โ€” identical to previous markup
  • New: web/src/components/Footer.tsx โ€” shared footer with logo, copyright, and links

  • Refactored: page.tsx, dashboard/page.tsx, community/page.tsx, download/page.tsx

    • Replaced 45-50 lines of inline nav JSX per page with <Navbar />
    • Replaced 25-line inline footer with <Footer />
    • Removed now-unused mobileMenuOpen state and Menu/X/Activity icon imports

Result

  • Net: -338 lines / +157 lines (181 lines eliminated)
  • Build: passing
  • Lint: 0 errors (pre-existing <img> warnings unchanged)
  • Zero behavior change โ€” visual output is identical

bokiko added 3 commits March 17, 2026 18:25
Add the first test suite to the project โ€” 68 pure unit tests covering
the two core Python modules (ping_tester.py and cli.py).

Tests are network-free and subprocess-free; they run in ~50ms and work
offline, making them safe to run in CI before any network access.

Coverage includes:
- validate_ip: valid/invalid IPv4/IPv6, hostnames, injection strings
- calculate_jitter: empty, single-value, zero, alternating, high-jitter cases
- get_best_server: empty list, all-timeout, lowest-ping selection,
  packet-loss-beats-ping ordering, 100% loss exclusion
- get_connection_quality: all 5 quality tiers with boundary value checks
- sort_results: all 5 sort keys, timeout-last guarantee, unknown-key fallback
- filter_by_max_ping: pass-all, block-all, timeout exclusion, boundary edge cases
- results_to_json: valid JSON, field correctness, best-only, error case, empty
- results_to_csv: parseable output, header row, best-only, multiple rows
- Color helpers: no-color mode, format_ping, format_loss
- build_parser: defaults, flags, region/sort validation, type coercion

Files: desktop/tests/__init__.py, desktop/tests/test_ping_tester.py,
       desktop/tests/test_cli.py, desktop/pytest.ini
The navigation bar and footer were copy-pasted identically across 4 pages
(home, dashboard, community, download), totaling ~200 lines of duplicated JSX.

Changes:
- Add web/src/components/Navbar.tsx: shared nav with usePathname-based active
  state highlighting, mobile menu toggle, ARIA attributes, and declarative
  NAV_LINKS config array โ€” single source of truth for site navigation
- Add web/src/components/Footer.tsx: shared footer with logo, copyright,
  and Privacy/Terms/GitHub links
- Refactor page.tsx, dashboard/page.tsx, community/page.tsx, download/page.tsx:
  replace inline nav/footer blocks with <Navbar /> and <Footer /> imports
- Remove now-unused mobileMenuOpen state and Menu/X/Activity imports from
  each page file

Benefits:
- Any nav change (new link, style update) now requires editing one file
- Active page highlighting (text-white font-medium) is now automatic via
  usePathname โ€” previously each page hardcoded its own active link
- Eliminates ~180 lines of net duplicated code (-338 / +157)
- No behavior changes โ€” visual output is identical
@bokiko bokiko merged commit 6fbabfe into main Mar 18, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant