2 Commits

Author SHA1 Message Date
user
a279cf8583 feat: add mobile viewport detection with friendly unavailable message
Some checks failed
check / check (push) Failing after 3m26s
Detect mobile viewport (window.innerWidth < 768) at startup and show a
centered 'Not yet available on mobile' message instead of the full
monitoring UI. All polling, gateway detection, and network requests are
skipped entirely on mobile viewports.

Desktop behavior is completely unchanged — the mobile check is the very
first thing in init() and returns early before any other setup runs.
2026-03-16 21:18:55 -07:00
1fb3ff2954 feat: responsive mobile layout for host rows (closes #2) (#5)
All checks were successful
check / check (push) Successful in 1m10s
Redesigns host rows for portrait/mobile viewports (<=768px):
- Host info panel stacks on top, full width
- Sparkline renders full width below
- Each host row becomes taller to accommodate vertical layout
- Summary line wraps gracefully
- Header controls stack below title

Desktop layout is unchanged — all changes are inside a `@media (max-width: 768px)` query and CSS class hooks added to the HTML.

Closes #2

Co-authored-by: user <user@Mac.lan guest wan>
Reviewed-on: #5
Co-authored-by: clawbot <clawbot@noreply.example.org>
Co-committed-by: clawbot <clawbot@noreply.example.org>
2026-03-10 19:56:40 +01:00
3 changed files with 115 additions and 15 deletions

View File

@@ -102,6 +102,9 @@ dist/
false outage)
- Clickable service URLs
- Canvas-based sparkline rendering with devicePixelRatio scaling
- Mobile detection: viewports narrower than 768px show a friendly "not yet
available on mobile" message instead of the monitoring UI (no polling or
network requests on mobile)
- Zero runtime dependencies: all resources bundled into build artifacts
## Deployment
@@ -125,6 +128,8 @@ properties.
## Limitations
- **Mobile**: Viewports below 768px wide show a static "not yet available"
message. The full monitoring UI requires a desktop-width browser.
- **CORS**: Some hosts may block cross-origin HEAD requests. The app uses
`no-cors` mode which allows the request but provides opaque responses. Latency
is still measurable based on request timing.

View File

@@ -1126,18 +1126,12 @@ function handleResize(state) {
});
}
// --- Bootstrap ---------------------------------------------------------------
// --- Mobile Detection --------------------------------------------------------
function isMobile() {
// Check both user agent and viewport width for robust detection
const uaMatch =
/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(
navigator.userAgent,
);
const narrowViewport = window.innerWidth <= 768;
return uaMatch || narrowViewport;
const MOBILE_BREAKPOINT = 768;
function isMobileViewport() {
return window.innerWidth < MOBILE_BREAKPOINT;
}
function buildMobileUI() {
@@ -1148,18 +1142,26 @@ function buildMobileUI() {
<h1 class="text-3xl font-bold text-white"><a href="https://git.eeqj.de/sneak/netwatch" target="_blank" rel="noopener" class="underline decoration-dashed decoration-gray-500 underline-offset-4">NetWatch</a> by <a href="https://sneak.berlin" target="_blank" rel="noopener" class="text-blue-400 underline hover:text-blue-300">@sneak</a></h1>
<p class="text-gray-400 text-sm mt-2">Real-time network latency monitor</p>
</header>
<div style="margin: 2rem auto; max-width: 500px; padding: 3rem 2rem; background: rgba(31, 41, 55, 0.7); border: 1px solid rgba(75, 85, 99, 0.5); border-radius: 1rem; text-align: center;">
<p style="font-size: 1.5rem; font-weight: 600; color: #d1d5db;">Not yet available on mobile.</p>
<p style="font-size: 0.875rem; color: #6b7280; margin-top: 1rem;">Please visit on a desktop browser for the full experience.</p>
<div class="flex items-center justify-center min-h-[60vh]">
<div class="bg-gray-800/70 border border-gray-700/50 rounded-lg p-8 max-w-md text-center">
<p class="text-4xl mb-4">📡</p>
<p class="text-xl font-semibold text-white mb-2">Not yet available on mobile</p>
<p class="text-gray-400 text-sm">NetWatch requires a wider viewport to display latency charts and monitoring data. Please visit on a desktop browser.</p>
</div>
</div>
<footer class="mt-8 text-center text-gray-600 text-xs">
<p><a href="https://git.eeqj.de/sneak/netwatch/commit/${__COMMIT_FULL__}" target="_blank" rel="noopener" class="text-gray-600 hover:text-gray-400">${__COMMIT_HASH__}</a></p>
</footer>
</div>`;
}
// --- Bootstrap ---------------------------------------------------------------
async function init() {
log.info("NetWatch starting");
if (isMobile()) {
log.info("Mobile device detected — showing placeholder");
if (isMobileViewport()) {
log.info("Mobile viewport detected — skipping monitoring");
buildMobileUI();
return;
}

View File

@@ -21,3 +21,96 @@ body {
rgba(255, 255, 255, 0) 100%
);
}
/* ---- Mobile responsive layout (portrait / narrow viewports) ---- */
@media (max-width: 768px) {
/* Header: stack title and controls vertically */
header .flex.items-center.justify-between {
flex-direction: column;
align-items: flex-start !important;
gap: 1rem;
}
header .flex.flex-col.items-end {
align-items: flex-start !important;
flex-direction: row;
flex-wrap: wrap;
gap: 0.75rem;
}
/* Pause button: smaller on mobile */
#pause-btn {
padding: 0.5rem 1rem;
}
#pause-btn svg {
width: 1.25rem;
height: 1.25rem;
}
#pause-text {
font-size: 0.875rem;
}
/* Summary box: wrap into a grid for readability */
#summary {
display: flex;
flex-wrap: wrap;
gap: 0.25rem 0.5rem;
justify-content: center;
line-height: 1.6;
}
/* Hide the pipe separators on mobile */
#summary .text-gray-600.mx-3 {
display: none;
}
/* Host row: stack vertically */
.host-row .flex.items-center.gap-4 {
flex-direction: column;
align-items: stretch !important;
gap: 0.5rem;
}
/* Info section: full width, remove fixed width */
.host-row .w-\[420px\] {
width: 100% !important;
display: grid;
grid-template-columns: 1fr auto;
align-items: center;
}
/* Host name row with dot */
.host-row .flex.items-center.gap-2.min-w-\[200px\] {
min-width: 0;
}
/* Latency value: slightly smaller on mobile */
.host-row .latency-value {
font-size: 1.875rem;
line-height: 2.25rem;
}
/* Sparkline: full width below the info */
.host-row .sparkline-container {
width: 100%;
flex-shrink: 0;
}
/* Pin button: inline with the host info */
.host-row .pin-btn {
position: absolute;
right: 0.5rem;
top: 0.5rem;
}
.host-row {
position: relative;
}
/* Footer legend: wrap nicely */
footer p {
line-height: 1.8;
}
}