From e967924f1fe7f41415490661a7b8974784b94d5e Mon Sep 17 00:00:00 2001 From: Cosmo Date: Thu, 23 Apr 2026 08:38:41 +0000 Subject: [PATCH] ui(topbar): move greeting from Home body to TopBar center MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The big Доброе утро line on Home ate one row for marginal value. Moved it into TopBar as a center column via 3-col grid (1fr auto 1fr), so it appears on all tabs and leaves the Home body denser. --- app/page.tsx | 14 -------------- components/TopBar.tsx | 24 +++++++++++++++++++++--- 2 files changed, 21 insertions(+), 17 deletions(-) diff --git a/app/page.tsx b/app/page.tsx index 7b1a90a..0fd6435 100644 --- a/app/page.tsx +++ b/app/page.tsx @@ -368,7 +368,6 @@ function HomeTab({ weather, sensors }: { weather: WeatherData | null; sensors: S const [todayEvents, setTodayEvents] = useState([]) const [tomorrowEvents, setTomorrowEvents] = useState([]) const [calLoading, setCalLoading] = useState(true) - const [greeting, setGreeting] = useState(getGreeting()) const [pinnedNotes, setPinnedNotes] = useState([]) const [selectedDay, setSelectedDay] = useState(null) @@ -411,11 +410,6 @@ function HomeTab({ weather, sensors }: { weather: WeatherData | null; sensors: S .catch(() => {}) }, []) - useEffect(() => { - const t = setInterval(() => setGreeting(getGreeting()), 60000) - return () => clearInterval(t) - }, []) - return ( @@ -424,14 +418,6 @@ function HomeTab({ weather, sensors }: { weather: WeatherData | null; sensors: S padding: '18px 22px 24px', display: 'flex', flexDirection: 'column', gap: 14, }}> - {/* ───── Greeting ───── */} -

- {greeting} 👋 -

- {/* ───── Bento row: Hero weather + Tram ───── */}
diff --git a/components/TopBar.tsx b/components/TopBar.tsx index a3464a9..3b9b0e8 100644 --- a/components/TopBar.tsx +++ b/components/TopBar.tsx @@ -26,6 +26,13 @@ function formatDate(date: Date): string { 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()) @@ -40,15 +47,16 @@ export default function TopBar({ sensors, haConnected }: TopBarProps) {
{/* Left: time + date */} @@ -67,8 +75,18 @@ export default function TopBar({ sensors, haConnected }: TopBarProps) {
+ {/* Center: greeting */} +
+ {getGreeting(time.getHours())} 👋 +
+ {/* Right: sensors + weather */} -
+
{/* HA status */}