From 3ec72b21645883abc28e117efe476761ddd90318 Mon Sep 17 00:00:00 2001 From: AkiraFukushima Date: Sun, 3 Dec 2023 21:27:31 +0900 Subject: [PATCH 1/2] refs #4653 Fold sidebar when screen is narrow --- renderer/app.css | 29 +++++++++++++++++-- renderer/components/layouts/timelines.tsx | 27 +++++++++++++---- .../components/timelines/Notifications.tsx | 2 +- renderer/components/timelines/Timeline.tsx | 2 +- 4 files changed, 50 insertions(+), 10 deletions(-) diff --git a/renderer/app.css b/renderer/app.css index 7f10060c..7fcd5a54 100644 --- a/renderer/app.css +++ b/renderer/app.css @@ -8,11 +8,15 @@ height: 1.2rem; } + +.timeline-wrapper { + width: calc(100% - 16rem); +} + .timeline { width: 100%; } - .timeline-with-drawer { width: calc(100% - 384px); } @@ -21,9 +25,30 @@ width: 384px; } +@media screen and (max-width: 1112px) { + .sidebar-menu { + display: none; + } + + .my-profile { + visibility: hidden; + } + + .sidebar { + width: 64px; + } + + .timeline-wrapper { + width: calc(100% - 64px); + } + + .sidebar-menu-item > span { + display: none; + } +} + @media screen and (max-width: 996px) { .timeline-with-drawer { - width: 0; display: none; } diff --git a/renderer/components/layouts/timelines.tsx b/renderer/components/layouts/timelines.tsx index ef6a0db3..0f7cf364 100644 --- a/renderer/components/layouts/timelines.tsx +++ b/renderer/components/layouts/timelines.tsx @@ -2,6 +2,7 @@ import { Account, db } from '@/db' import { CustomFlowbiteTheme, Flowbite, Sidebar } from 'flowbite-react' import { useRouter } from 'next/router' import { useEffect, useState } from 'react' +import { FaBell, FaGlobe, FaHouse, FaUsers } from 'react-icons/fa6' import { useIntl } from 'react-intl' type LayoutProps = { @@ -15,7 +16,11 @@ const customTheme: CustomFlowbiteTheme = { }, item: { base: 'flex items-center justify-center rounded-lg p-2 text-base font-normal text-blue-200 hover:bg-blue-900 dark:text-blue-200 dark:hover:bg-blue-900 cursor-pointer', - active: 'bg-blue-400 text-gray-800 hover:bg-blue-300' + active: 'bg-blue-400 text-gray-800 hover:bg-blue-300', + icon: { + base: 'h-5 w-5 flex-shrink-0 text-gray-500 transition duration-75 text-blue-200 group-hover:text-blue-900 dark:text-blue-200 dark:group-hover:text-blue-900', + active: 'text-gray-800' + } } } } @@ -40,38 +45,48 @@ export default function Layout({ children }: LayoutProps) { { id: 'home', title: formatMessage({ id: 'timeline.home' }), + icon: FaHouse, path: `/accounts/${router.query.id}/home` }, { id: 'notifications', title: formatMessage({ id: 'timeline.notifications' }), + icon: FaBell, path: `/accounts/${router.query.id}/notifications` }, { id: 'local', title: formatMessage({ id: 'timeline.local' }), + icon: FaUsers, path: `/accounts/${router.query.id}/local` }, { id: 'public', title: formatMessage({ id: 'timeline.public' }), + icon: FaGlobe, path: `/accounts/${router.query.id}/public` } ] return ( -
+
- -
+ +

{account?.username}

@{account?.domain}

{pages.map(page => ( - router.push(page.path)}> - {page.title} + router.push(page.path)} + icon={page.icon} + className="sidebar-menu-item" + > + {page.title} ))} diff --git a/renderer/components/timelines/Notifications.tsx b/renderer/components/timelines/Notifications.tsx index 39348213..620c2a1a 100644 --- a/renderer/components/timelines/Notifications.tsx +++ b/renderer/components/timelines/Notifications.tsx @@ -100,7 +100,7 @@ export default function Notifications(props: Props) { }, [firstItemIndex, notifications, setNotifications, unreads]) return ( -
+
diff --git a/renderer/components/timelines/Timeline.tsx b/renderer/components/timelines/Timeline.tsx index c3f3922d..e1186977 100644 --- a/renderer/components/timelines/Timeline.tsx +++ b/renderer/components/timelines/Timeline.tsx @@ -156,7 +156,7 @@ export default function Timeline(props: Props) { } return ( -
+
From a068ed76bd491b19366e0122075f4872d7475127 Mon Sep 17 00:00:00 2001 From: AkiraFukushima Date: Sun, 3 Dec 2023 21:49:03 +0900 Subject: [PATCH 2/2] refs #4653 Fold sidebar for notifications --- renderer/components/timelines/Notifications.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/renderer/components/timelines/Notifications.tsx b/renderer/components/timelines/Notifications.tsx index 620c2a1a..a3fa88d7 100644 --- a/renderer/components/timelines/Notifications.tsx +++ b/renderer/components/timelines/Notifications.tsx @@ -100,7 +100,7 @@ export default function Notifications(props: Props) { }, [firstItemIndex, notifications, setNotifications, unreads]) return ( -
+
@@ -119,6 +119,7 @@ export default function Notifications(props: Props) { }} firstItemIndex={firstItemIndex} atTopStateChange={prependUnreads} + className="timeline-scrollable" data={notifications} endReached={loadMore} itemContent={(_, notification) => (