From 045e42003c248041bcfa216c63d42b8c5192e361 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?nicole=20miko=C5=82ajczyk?= Date: Mon, 30 Jun 2025 12:35:43 +0200 Subject: [PATCH] pl-fe: layout changes for the deck MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: nicole mikołajczyk --- .../components/sidebar-navigation-link.tsx | 7 +- .../src/components/sidebar-navigation.tsx | 65 +++++++++++++++---- packages/pl-fe/src/components/ui/layout.tsx | 18 +++-- .../features/ui/components/compose-button.tsx | 35 ++++++---- packages/pl-fe/src/features/ui/index.tsx | 9 ++- packages/pl-fe/src/layouts/chats-layout.tsx | 2 +- 6 files changed, 101 insertions(+), 35 deletions(-) diff --git a/packages/pl-fe/src/components/sidebar-navigation-link.tsx b/packages/pl-fe/src/components/sidebar-navigation-link.tsx index 4ccf31f5c..04202d160 100644 --- a/packages/pl-fe/src/components/sidebar-navigation-link.tsx +++ b/packages/pl-fe/src/components/sidebar-navigation-link.tsx @@ -22,11 +22,12 @@ interface ISidebarNavigationLink { to?: string; /** Callback when the link is clicked. */ onClick?: React.EventHandler; + shrink?: boolean; } /** Desktop sidebar navigation link. */ const SidebarNavigationLink = React.memo(React.forwardRef((props: ISidebarNavigationLink, ref: React.ForwardedRef): JSX.Element => { - const { icon, activeIcon, text, to = '', count, countMax, onClick } = props; + const { icon, activeIcon, text, to = '', count, countMax, onClick, shrink } = props; const isActive = location.pathname === to; const { demetricator } = useSettings(); @@ -69,7 +70,9 @@ const SidebarNavigationLink = React.memo(React.forwardRef((props: ISidebarNaviga /> - {text} + {!shrink && ( + {text} + )} ); }), (prevProps, nextProps) => prevProps.count === nextProps.count); diff --git a/packages/pl-fe/src/components/sidebar-navigation.tsx b/packages/pl-fe/src/components/sidebar-navigation.tsx index 7b8416116..2e073c9f3 100644 --- a/packages/pl-fe/src/components/sidebar-navigation.tsx +++ b/packages/pl-fe/src/components/sidebar-navigation.tsx @@ -1,4 +1,5 @@ import { useInfiniteQuery } from '@tanstack/react-query'; +import clsx from 'clsx'; import React, { useMemo } from 'react'; import { defineMessages, FormattedMessage, useIntl } from 'react-intl'; @@ -21,6 +22,7 @@ import DropdownMenu, { Menu } from './dropdown-menu'; import SearchInput from './search-input'; import SidebarNavigationLink from './sidebar-navigation-link'; import SiteLogo from './site-logo'; +import Avatar from './ui/avatar'; const messages = defineMessages({ followRequests: { id: 'navigation_bar.follow_requests', defaultMessage: 'Follow requests' }, @@ -36,8 +38,13 @@ const messages = defineMessages({ interactionRequests: { id: 'navigation.interaction_requests', defaultMessage: 'Interaction requests' }, }); +interface ISidebarNavigation { + /** Whether the sidebar is in shrinked mode. */ + shrink?: boolean; +} + /** Desktop sidebar with links to different views in the app. */ -const SidebarNavigation = React.memo(() => { +const SidebarNavigation: React.FC = React.memo(({ shrink }) => { const intl = useIntl(); const { unreadChatsCount } = useStatContext(); @@ -161,24 +168,41 @@ const SidebarNavigation = React.memo(() => { }, [!!account, features, followRequestsCount, interactionRequestsCount, scheduledStatusCount, draftCount]); return ( - - + + {account && (
- } - disabled - withLinkToProfile={false} - /> + {shrink ? ( + + // className='size-10 bg-gray-50 ring-2 ring-white' + ) : ( + } + disabled + withLinkToProfile={false} + /> + )}
-
- -
+ {!shrink && ( +
+ +
+ )}
)} @@ -188,12 +212,14 @@ const SidebarNavigation = React.memo(() => { icon={require('@tabler/icons/outline/home.svg')} activeIcon={require('@tabler/icons/filled/home.svg')} text={} + shrink={shrink} /> } + shrink={shrink} /> {account && ( @@ -204,6 +230,7 @@ const SidebarNavigation = React.memo(() => { activeIcon={require('@tabler/icons/filled/bell.svg')} count={notificationCount} text={} + shrink={shrink} /> {features.chats && ( @@ -213,6 +240,7 @@ const SidebarNavigation = React.memo(() => { count={unreadChatsCount} countMax={9} text={} + shrink={shrink} /> )} @@ -222,6 +250,7 @@ const SidebarNavigation = React.memo(() => { icon={require('@tabler/icons/outline/mail.svg')} activeIcon={require('@tabler/icons/filled/mail.svg')} text={} + shrink={shrink} /> )} @@ -231,6 +260,7 @@ const SidebarNavigation = React.memo(() => { icon={require('@tabler/icons/outline/circles.svg')} activeIcon={require('@tabler/icons/filled/circles.svg')} text={} + shrink={shrink} /> )} @@ -239,6 +269,7 @@ const SidebarNavigation = React.memo(() => { icon={require('@tabler/icons/outline/user.svg')} activeIcon={require('@tabler/icons/filled/user.svg')} text={} + shrink={shrink} /> { icon={require('@tabler/icons/outline/settings.svg')} activeIcon={require('@tabler/icons/filled/settings.svg')} text={} + shrink={shrink} /> {(account.is_admin || account.is_moderator) && ( @@ -254,6 +286,7 @@ const SidebarNavigation = React.memo(() => { icon={require('@tabler/icons/outline/dashboard.svg')} count={dashboardCount} text={} + shrink={shrink} /> )} @@ -267,6 +300,7 @@ const SidebarNavigation = React.memo(() => { icon={features.federating ? require('@tabler/icons/outline/affiliate.svg') : require('@tabler/icons/outline/world.svg')} activeIcon={features.federating ? require('@tabler/icons/filled/affiliate.svg') : undefined} text={features.federating ? : } + shrink={shrink} /> )} @@ -276,6 +310,7 @@ const SidebarNavigation = React.memo(() => { icon={require('@tabler/icons/outline/chart-bubble.svg')} activeIcon={require('@tabler/icons/filled/chart-bubble.svg')} text={} + shrink={shrink} /> )} @@ -284,6 +319,7 @@ const SidebarNavigation = React.memo(() => { to='/timeline/fediverse' icon={require('@tabler/icons/outline/topology-star-ring-3.svg')} text={} + shrink={shrink} /> )} @@ -294,6 +330,7 @@ const SidebarNavigation = React.memo(() => { } + shrink={shrink} /> )} @@ -304,19 +341,21 @@ const SidebarNavigation = React.memo(() => { to='/login' icon={require('@tabler/icons/outline/login.svg')} text={} + shrink={shrink} /> {isOpen && } + shrink={shrink} />}
)}
{account && ( - + )} ); diff --git a/packages/pl-fe/src/components/ui/layout.tsx b/packages/pl-fe/src/components/ui/layout.tsx index 86e4c29b3..25c84986d 100644 --- a/packages/pl-fe/src/components/ui/layout.tsx +++ b/packages/pl-fe/src/components/ui/layout.tsx @@ -6,6 +6,7 @@ import { useFeatures } from 'pl-fe/hooks/use-features'; interface ISidebar { children: React.ReactNode; + shrink?: boolean; } interface IAside { children?: React.ReactNode; @@ -13,6 +14,7 @@ interface IAside { interface ILayout { children: React.ReactNode; + fullWidth?: boolean; } interface LayoutComponent extends React.FC { @@ -22,17 +24,25 @@ interface LayoutComponent extends React.FC { } /** Layout container, to hold Sidebar, Main, and Aside. */ -const Layout: LayoutComponent = ({ children }) => ( +const Layout: LayoutComponent = ({ children, fullWidth }) => (
-
+
{children}
); /** Left sidebar container in the UI. */ -const Sidebar: React.FC = ({ children }) => ( -
+const Sidebar: React.FC = ({ children, shrink }) => ( +
{children} diff --git a/packages/pl-fe/src/features/ui/components/compose-button.tsx b/packages/pl-fe/src/features/ui/components/compose-button.tsx index 5b7af3e86..9ba254d19 100644 --- a/packages/pl-fe/src/features/ui/components/compose-button.tsx +++ b/packages/pl-fe/src/features/ui/components/compose-button.tsx @@ -10,7 +10,12 @@ import HStack from 'pl-fe/components/ui/hstack'; import { useAppDispatch } from 'pl-fe/hooks/use-app-dispatch'; import { useModalsStore } from 'pl-fe/stores/modals'; -const ComposeButton = () => { +interface IComposeButton { + /** Whether the button should shrink to fit in a smaller space. */ + shrink?: boolean; +} + +const ComposeButton: React.FC = ({ shrink }) => { const location = useLocation(); const isOnGroupPage = location.pathname.startsWith('/group/'); const match = useRouteMatch<{ groupId: string }>('/groups/:groupId'); @@ -18,13 +23,13 @@ const ComposeButton = () => { const isGroupMember = !!group?.relationship?.member; if (isOnGroupPage && isGroupMember) { - return ; + return ; } - return ; + return ; }; -const HomeComposeButton = () => { +const HomeComposeButton: React.FC = ({ shrink }) => { const { openModal } = useModalsStore(); const onOpenCompose = () => openModal('COMPOSE'); @@ -34,13 +39,16 @@ const HomeComposeButton = () => { size='lg' onClick={onOpenCompose} block + icon={shrink ? require('@tabler/icons/outline/plus.svg') : undefined} > - + {!shrink && ( + + )} ); }; -const GroupComposeButton = () => { +const GroupComposeButton: React.FC = ({ shrink }) => { const dispatch = useAppDispatch(); const match = useRouteMatch<{ groupId: string }>('/groups/:groupId'); const { group } = useGroup(match?.params.groupId || ''); @@ -57,13 +65,16 @@ const GroupComposeButton = () => { size='lg' onClick={onOpenCompose} block + icon={shrink ? require('@tabler/icons/outline/plus.svg') : undefined} > - - - - - - + {!shrink && ( + + + + + + + )} ); }; diff --git a/packages/pl-fe/src/features/ui/index.tsx b/packages/pl-fe/src/features/ui/index.tsx index 64217dbd3..0d5f608dd 100644 --- a/packages/pl-fe/src/features/ui/index.tsx +++ b/packages/pl-fe/src/features/ui/index.tsx @@ -488,6 +488,9 @@ const UI: React.FC = React.memo(({ children }) => { pointerEvents: isDropdownMenuOpen ? 'none' : undefined, }; + // to be used with the deck + const fullWidth = false; + return (
@@ -500,9 +503,9 @@ const UI: React.FC = React.memo(({ children }) => {
- - - {!(standalone && !me) && } + + + {!(standalone && !me) && } diff --git a/packages/pl-fe/src/layouts/chats-layout.tsx b/packages/pl-fe/src/layouts/chats-layout.tsx index 45b057b34..ac8bcf78b 100644 --- a/packages/pl-fe/src/layouts/chats-layout.tsx +++ b/packages/pl-fe/src/layouts/chats-layout.tsx @@ -6,7 +6,7 @@ interface IChatsLayout { /** Custom layout for chats on desktop. */ const ChatsLayout: React.FC = ({ children }) => ( -
+
{children}
);