From b883ffc31cdcd5f8d576b3c32982f41787870ef5 Mon Sep 17 00:00:00 2001 From: Nate Kelley Date: Fri, 28 Feb 2025 17:11:40 -0700 Subject: [PATCH] make page layout better --- .../ChatItemsContainer.tsx | 23 +++++-------- .../_ChatsListContainer/ChatListContainer.tsx | 33 ++----------------- .../_ChatsListContainer/ChatListHeader.tsx | 15 +++------ .../app/app/(primary_layout)/chats/page.tsx | 8 ++++- .../features/sidebars/SidebarPrimary.tsx | 30 +++++++++++++++-- .../components/ui/layouts/AppContentPage.tsx | 4 +-- .../components/ui/layouts/AppPageLayout.tsx | 4 +-- web/src/components/ui/layouts/index.ts | 6 +++- .../ui/list/ListEmptyStateWithButton.tsx | 10 +++--- .../components/ui/typography/Paragraph.tsx | 2 +- web/src/components/ui/typography/Text.tsx | 4 +-- web/src/components/ui/typography/Title.tsx | 2 +- web/src/components/ui/typography/index.ts | 3 ++ 13 files changed, 70 insertions(+), 74 deletions(-) create mode 100644 web/src/components/ui/typography/index.ts diff --git a/web/src/app/app/(primary_layout)/chats/_ChatsListContainer/ChatItemsContainer.tsx b/web/src/app/app/(primary_layout)/chats/_ChatsListContainer/ChatItemsContainer.tsx index 9a011af8f..40e7d226f 100644 --- a/web/src/app/app/(primary_layout)/chats/_ChatsListContainer/ChatItemsContainer.tsx +++ b/web/src/app/app/(primary_layout)/chats/_ChatsListContainer/ChatItemsContainer.tsx @@ -10,17 +10,16 @@ import { BusterListColumn, BusterListRow } from '@/components/ui/list'; import { ChatSelectedOptionPopup } from './ChatItemsSelectedPopup'; import { BusterList, ListEmptyStateWithButton } from '@/components/ui/list'; import { useCreateListByDate } from '@/components/ui/list/useCreateListByDate'; +import { cn } from '@/lib/utils'; export const ChatItemsContainer: React.FC<{ chats: BusterChatListItem[]; className?: string; - openNewMetricModal: () => void; loading: boolean; -}> = ({ chats = [], className = '', loading, openNewMetricModal }) => { +}> = ({ chats = [], className = '', loading }) => { const [selectedRowKeys, setSelectedRowKeys] = useState([]); const renderedDates = useRef>({}); const renderedOwners = useRef>({}); - const tableContainerRef = useRef(null); const onSelectChange = useMemoizedFn((selectedRowKeys: string[]) => { setSelectedRowKeys(selectedRowKeys); @@ -106,15 +105,13 @@ export const ChatItemsContainer: React.FC<{ ); return ( -
+ <> } + emptyState={} /> -
+ ); }; const EmptyState: React.FC<{ loading: boolean; - openNewMetricModal: () => void; -}> = React.memo(({ loading, openNewMetricModal }) => { +}> = React.memo(({ loading }) => { if (loading) { return <>; } - return ; + return ; }); EmptyState.displayName = 'EmptyState'; -const ChatsEmptyState: React.FC<{ - openNewMetricModal: () => void; -}> = ({ openNewMetricModal }) => { +const ChatsEmptyState: React.FC<{}> = ({}) => { return ( ); }; diff --git a/web/src/app/app/(primary_layout)/chats/_ChatsListContainer/ChatListContainer.tsx b/web/src/app/app/(primary_layout)/chats/_ChatsListContainer/ChatListContainer.tsx index c6405ef17..5379e10aa 100644 --- a/web/src/app/app/(primary_layout)/chats/_ChatsListContainer/ChatListContainer.tsx +++ b/web/src/app/app/(primary_layout)/chats/_ChatsListContainer/ChatListContainer.tsx @@ -1,44 +1,15 @@ 'use client'; import React, { useState } from 'react'; -import { AppContentPage } from '@/components/ui/layouts/AppContentPage'; -import { useAppLayoutContextSelector } from '@/context/BusterAppLayout'; -import { useMemoizedFn, useMount } from 'ahooks'; import { useBusterChatListByFilter } from '@/context/Chats'; -import { ChatListHeader } from './ChatListHeader'; import { ChatItemsContainer } from './ChatItemsContainer'; -export const ChatListContainer: React.FC<{ - className?: string; -}> = ({ className = '' }) => { - const onToggleChatsModal = useAppLayoutContextSelector((s) => s.onToggleChatsModal); +export const ChatListContainer: React.FC<{}> = ({}) => { const [filters, setFilters] = useState[0]>({ admin_view: false }); const { list, isFetched } = useBusterChatListByFilter(filters); - const onSetFilters = useMemoizedFn( - (newFilters: Parameters[0]) => { - setFilters(newFilters); - } - ); - - useMount(async () => { - onSetFilters({ admin_view: false }); - }); - - return ( -
- - - - -
- ); + return ; }; diff --git a/web/src/app/app/(primary_layout)/chats/_ChatsListContainer/ChatListHeader.tsx b/web/src/app/app/(primary_layout)/chats/_ChatsListContainer/ChatListHeader.tsx index dac9a9149..64851cc9f 100644 --- a/web/src/app/app/(primary_layout)/chats/_ChatsListContainer/ChatListHeader.tsx +++ b/web/src/app/app/(primary_layout)/chats/_ChatsListContainer/ChatListHeader.tsx @@ -1,17 +1,10 @@ -'use client'; - import React from 'react'; -import { AppContentHeader } from '@/components/ui/layouts/AppContentHeader'; -import { Text } from '@/components/ui'; +import { Text } from '@/components/ui/typography'; export const ChatListHeader: React.FC<{}> = ({}) => { return ( - -
-
- {'Chats'} -
-
-
+ <> + {'Chats'} + ); }; diff --git a/web/src/app/app/(primary_layout)/chats/page.tsx b/web/src/app/app/(primary_layout)/chats/page.tsx index d9b62aeb5..33497fc61 100644 --- a/web/src/app/app/(primary_layout)/chats/page.tsx +++ b/web/src/app/app/(primary_layout)/chats/page.tsx @@ -1,5 +1,11 @@ +import { AppPageLayout } from '@/components/ui/layouts/AppPageLayout'; import { ChatListContainer } from './_ChatsListContainer'; +import { ChatListHeader } from './_ChatsListContainer/ChatListHeader'; export default function ChatsPage() { - return ; + return ( + }> + + + ); } diff --git a/web/src/components/features/sidebars/SidebarPrimary.tsx b/web/src/components/features/sidebars/SidebarPrimary.tsx index bea5d9ff0..1691db50f 100644 --- a/web/src/components/features/sidebars/SidebarPrimary.tsx +++ b/web/src/components/features/sidebars/SidebarPrimary.tsx @@ -14,6 +14,9 @@ import { Tooltip } from '@/components/ui/tooltip/Tooltip'; import Link from 'next/link'; import { useUserConfigContextSelector } from '@/context/Users'; import { useAppLayoutContextSelector } from '@/context/BusterAppLayout'; +import { SupportModal } from '../modal/SupportModal'; +import { InvitePeopleModal } from '../modal/InvitePeopleModal'; +import { useMemoizedFn } from 'ahooks'; const topItems: ISidebarList = { items: [ @@ -126,7 +129,11 @@ export const SidebarPrimary = React.memo(() => { }, [isAdmin, favorites, currentRoute]); return ( - } activeItem={currentRoute} /> + <> + } activeItem={currentRoute} /> + + + ); }); @@ -148,7 +155,7 @@ const SidebarPrimaryHeader = React.memo(() => { size="tall" rounding={'large'} prefix={ -
+
} @@ -162,6 +169,25 @@ const SidebarPrimaryHeader = React.memo(() => { SidebarPrimaryHeader.displayName = 'SidebarPrimaryHeader'; +const GlobalModals = React.memo(() => { + const onToggleSupportModal = useAppLayoutContextSelector((s) => s.onToggleSupportModal); + const onToggleInviteModal = useAppLayoutContextSelector((s) => s.onToggleInviteModal); + const openSupportModal = useAppLayoutContextSelector((s) => s.openSupportModal); + const openInviteModal = useAppLayoutContextSelector((s) => s.openInviteModal); + const isAnonymousUser = useUserConfigContextSelector((state) => state.isAnonymousUser); + + const onCloseInviteModal = useMemoizedFn(() => onToggleInviteModal(false)); + const onCloseSupportModal = useMemoizedFn(() => onToggleSupportModal(false)); + + if (isAnonymousUser) return null; + + return ( + <> + + + + ); +}); const favoritesDropdown = (favorites: BusterUserFavorite[]): ISidebarGroup => { return { label: 'Favorites', diff --git a/web/src/components/ui/layouts/AppContentPage.tsx b/web/src/components/ui/layouts/AppContentPage.tsx index e146668a4..b64171167 100644 --- a/web/src/components/ui/layouts/AppContentPage.tsx +++ b/web/src/components/ui/layouts/AppContentPage.tsx @@ -1,6 +1,5 @@ import React, { PropsWithChildren } from 'react'; import { cn } from '@/lib/utils'; -import { cva, type VariantProps } from 'class-variance-authority'; export const AppContentPage: React.FC< PropsWithChildren<{ @@ -11,7 +10,8 @@ export const AppContentPage: React.FC< return (
diff --git a/web/src/components/ui/layouts/AppPageLayout.tsx b/web/src/components/ui/layouts/AppPageLayout.tsx index f9e884a3b..89ea196e8 100644 --- a/web/src/components/ui/layouts/AppPageLayout.tsx +++ b/web/src/components/ui/layouts/AppPageLayout.tsx @@ -1,5 +1,5 @@ -import { cn } from '@/lib/utils'; import React from 'react'; +import { cn } from '@/lib/utils'; import { AppContentHeader } from './AppContentHeader'; import { AppContentPage } from './AppContentPage'; @@ -18,7 +18,7 @@ export const AppPageLayout: React.FC< className?: string; headerVariant?: 'default' | 'list'; }> -> = ({ children, header, scrollable = true, className = '', headerVariant = 'default' }) => { +> = ({ children, header, scrollable = false, className = '', headerVariant = 'default' }) => { return (
void; + onClick?: () => void; buttonText: string; loading?: boolean; + linkButton?: string; }> = React.memo(({ isAdmin = true, title, buttonText, description, onClick, loading = false }) => { return (
@@ -27,8 +29,8 @@ export const ListEmptyStateWithButton: React.FC<{ {isAdmin && (