All checks were successful
Deploy / deploy (push) Successful in 3m8s
Big design pass across Home + tokens + components. — globals.css: new data-* palette (cool/warm/hot/good/info/rose/violet/mood) with theme-aware variants, .grain overlay utility, .num-display typography helper, .hit-zone 44px wrapper, .eyebrow label, .focus-card base, focus-visible outline-offset 3px, space/touch scale vars. — FocusCard.tsx: context engine — пять состояний (morning-outfit, tram-imminent, event-upcoming, countdown, bill-due, night, quiet). Auto-rotates by hour + live data. 96px display numbers, accent-mixed surfaces, grain overlay. — CountdownCard.tsx + /api/countdowns: rotating 8s list, persistent /data/tablet-countdowns.json, full CRUD. Default seeded with Токио. — HomeTab: replaced plain Weather hero with FocusCard, added Row 4 with CountdownCard. Pulls trams + countdowns for the Focus context. — Swipe between tabs: pointer-level detection on <main>, data-swipe-ignore bails out inside modals + note swipe-to-delete + voice overlay. — Touch-target sweep: TopBar HA dot → 44px hit-zone, sensor chip 44px min-height, forecast day buttons 92px min, DeviceCard toggle 60x36, CalendarTab prev/next/close/list all 44x44, NotesTab buttons 44x44, TimerHomeWidget + 44x44, WeatherDayModal chevrons 48x48, close 48. — Hardcoded hex → data-* tokens: TopBar sensors, TransportWidget routes (via color-mix), DeviceCard full rewrite (per-kind accent, glass removed in favor of color-mix surfaces + proper mock-state treatment), NotesTab palette refreshed to match dark theme. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
135 lines
4.5 KiB
TypeScript
135 lines
4.5 KiB
TypeScript
'use client'
|
|
|
|
import { useState, useEffect } from 'react'
|
|
import { Droplets, Wind, Thermometer } from 'lucide-react'
|
|
|
|
interface SensorData {
|
|
temperature: number
|
|
humidity: number
|
|
pm25: number
|
|
}
|
|
|
|
interface TopBarProps {
|
|
sensors: SensorData | null
|
|
haConnected?: boolean
|
|
}
|
|
|
|
|
|
function formatTime(date: Date): string {
|
|
return date.toLocaleTimeString('ru-RU', { hour: '2-digit', minute: '2-digit' })
|
|
}
|
|
|
|
function formatDate(date: Date): string {
|
|
const weekday = date.toLocaleDateString('ru-RU', { weekday: 'long' })
|
|
const day = date.getDate()
|
|
const month = date.toLocaleDateString('ru-RU', { month: 'long' })
|
|
return `${weekday}, ${day} ${month}`
|
|
}
|
|
|
|
function getGreeting(h: number): string {
|
|
if (h >= 5 && h < 12) return 'Доброе утро'
|
|
if (h >= 12 && h < 17) return 'Добрый день'
|
|
if (h >= 17 && h < 22) return 'Добрый вечер'
|
|
return 'Доброй ночи'
|
|
}
|
|
|
|
|
|
export default function TopBar({ sensors, haConnected }: TopBarProps) {
|
|
const [time, setTime] = useState(() => new Date())
|
|
|
|
useEffect(() => {
|
|
const t = setInterval(() => setTime(new Date()), 1000)
|
|
return () => clearInterval(t)
|
|
}, [])
|
|
|
|
return (
|
|
<>
|
|
<header
|
|
style={{
|
|
height: 72,
|
|
display: 'grid',
|
|
gridTemplateColumns: '1fr auto 1fr',
|
|
alignItems: 'center',
|
|
padding: '0 24px',
|
|
borderBottom: '1px solid var(--hairline)',
|
|
background: 'transparent',
|
|
flexShrink: 0,
|
|
position: 'relative',
|
|
zIndex: 5,
|
|
gap: 16,
|
|
}}
|
|
>
|
|
{/* Left: time + date */}
|
|
<div style={{ display: 'flex', alignItems: 'baseline', gap: 12 }}>
|
|
<span style={{
|
|
fontSize: 28, fontWeight: 700, color: 'var(--text-primary)',
|
|
letterSpacing: '-1px', fontVariantNumeric: 'tabular-nums',
|
|
}}>
|
|
{formatTime(time)}
|
|
</span>
|
|
<span style={{
|
|
fontSize: 14, color: 'var(--text-secondary)',
|
|
fontWeight: 400, textTransform: 'capitalize',
|
|
}}>
|
|
{formatDate(time)}
|
|
</span>
|
|
</div>
|
|
|
|
{/* Center: greeting */}
|
|
<div style={{
|
|
fontSize: 17, fontWeight: 700, color: 'var(--text-primary)',
|
|
letterSpacing: '-0.3px', justifySelf: 'center',
|
|
whiteSpace: 'nowrap', overflow: 'hidden', textOverflow: 'ellipsis',
|
|
maxWidth: '100%',
|
|
}}>
|
|
{getGreeting(time.getHours())} <span style={{ fontSize: 16 }}>👋</span>
|
|
</div>
|
|
|
|
{/* Right: sensors + weather */}
|
|
<div style={{ display: 'flex', alignItems: 'center', gap: 8, justifySelf: 'end' }}>
|
|
{/* HA status — 44px hit-zone wrapping 14px dot */}
|
|
<div
|
|
title={haConnected ? 'Home Assistant подключён' : 'Home Assistant недоступен'}
|
|
className="hit-zone"
|
|
style={{ width: 44, height: 44 }}
|
|
>
|
|
<div style={{
|
|
width: 14, height: 14, borderRadius: '50%',
|
|
background: haConnected ? 'var(--data-good)' : 'var(--data-danger)',
|
|
boxShadow: haConnected
|
|
? '0 0 10px color-mix(in srgb, var(--data-good) 55%, transparent)'
|
|
: '0 0 10px color-mix(in srgb, var(--data-danger) 55%, transparent)',
|
|
transition: 'all 0.5s ease',
|
|
flexShrink: 0,
|
|
}} />
|
|
</div>
|
|
|
|
{sensors && (
|
|
<div style={{
|
|
display: 'flex', alignItems: 'center', gap: 6,
|
|
padding: '10px 16px', borderRadius: 16,
|
|
minHeight: 44,
|
|
background: 'var(--surface-2)', border: '1px solid var(--border-subtle)',
|
|
}}>
|
|
<Thermometer size={18} color="var(--data-hot)" strokeWidth={1.8} />
|
|
<span className="num" style={{ fontSize: 14, fontWeight: 700, color: 'var(--text-primary)', marginRight: 10 }}>
|
|
{sensors.temperature}°
|
|
</span>
|
|
<Droplets size={18} color="var(--data-cool)" strokeWidth={1.8} />
|
|
<span className="num" style={{ fontSize: 14, fontWeight: 700, color: 'var(--text-primary)', marginRight: 10 }}>
|
|
{sensors.humidity}%
|
|
</span>
|
|
<Wind size={18} color="var(--text-tertiary)" strokeWidth={1.8} />
|
|
<span className="num" style={{ fontSize: 14, color: 'var(--text-secondary)' }}>
|
|
{sensors.pm25}
|
|
</span>
|
|
</div>
|
|
)}
|
|
|
|
</div>
|
|
</header>
|
|
|
|
</>
|
|
)
|
|
}
|