Skip to content

Commit 4b37a34

Browse files
committed
fix: adjust layout in BaseItem and BaseList components
1 parent 1bc2391 commit 4b37a34

File tree

6 files changed

+40
-21
lines changed

6 files changed

+40
-21
lines changed

apps/nextjs-app/src/features/app/blocks/base/base-side-bar/BaseNodeTree.tsx

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ type TreeMode = 'view' | 'edit';
119119
interface IBaseNodeTreeProps {
120120
mode?: TreeMode;
121121
emptyText?: string;
122+
skeleton?: React.ReactNode;
122123
}
123124

124125
export const BaseNodeTree = (props: IBaseNodeTreeProps) => {
@@ -549,14 +550,20 @@ export const BaseNodeTree = (props: IBaseNodeTreeProps) => {
549550
if (Object.keys(treeItems).length === 0) {
550551
if (isLoading) {
551552
return (
552-
<div className="flex w-full flex-col gap-2 px-2">
553-
<Skeleton className="h-7 w-full" />
554-
<Skeleton className="h-7 w-full" />
555-
<Skeleton className="h-7 w-full" />
556-
<Skeleton className="h-7 w-full" />
557-
<Skeleton className="h-7 w-full" />
558-
<Skeleton className="h-7 w-full" />
559-
</div>
553+
<>
554+
{props.skeleton ? (
555+
props.skeleton
556+
) : (
557+
<div className="flex w-full flex-col gap-2 px-2">
558+
<Skeleton className="h-7 w-full" />
559+
<Skeleton className="h-7 w-full" />
560+
<Skeleton className="h-7 w-full" />
561+
<Skeleton className="h-7 w-full" />
562+
<Skeleton className="h-7 w-full" />
563+
<Skeleton className="h-7 w-full" />
564+
</div>
565+
)}
566+
</>
560567
);
561568
} else if (emptyText) {
562569
return (

apps/nextjs-app/src/features/app/blocks/space/BaseItem.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ export const BaseItem: FC<IBaseItemProps> = (props) => {
165165
</div>
166166

167167
{/* Last Opened Column */}
168-
<div className="w-60 shrink-0 text-xs">
168+
<div className="w-40 shrink-0 text-xs lg:w-60">
169169
{lastVisitTime ? dayjs(lastVisitTime).fromNow() : '-'}
170170
</div>
171171

apps/nextjs-app/src/features/app/blocks/space/BaseList.tsx

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { useQueryClient, useMutation } from '@tanstack/react-query';
22
import { deleteBase, permanentDeleteBase, updateBase, type IGetBaseVo } from '@teable/openapi';
33
import { ReactQueryKeys } from '@teable/sdk/config';
44
import { AnchorContext } from '@teable/sdk/context';
5-
import { Collapsible, CollapsibleContent, ScrollArea } from '@teable/ui-lib/shadcn';
5+
import { Collapsible, CollapsibleContent, ScrollArea, Skeleton } from '@teable/ui-lib/shadcn';
66
import { keyBy } from 'lodash';
77
import { useRouter } from 'next/router';
88
import { useTranslation } from 'next-i18next';
@@ -14,7 +14,6 @@ import { BaseNodeTree } from '../base/base-side-bar/BaseNodeTree';
1414
import { useLastVisitBase } from '../base/hooks';
1515
import { BaseItem } from './BaseItem';
1616
import { useBaseList } from './useBaseList';
17-
1817
interface IBaseListProps {
1918
baseIds: string[];
2019
}
@@ -121,7 +120,19 @@ export const BaseList = (props: IBaseListProps) => {
121120
<CollapsibleContent>
122121
<AnchorContext.Provider value={{ baseId: base.id }}>
123122
<BaseNodeProvider>
124-
<BaseNodeTree mode="view" emptyText={t('space:baseList.empty')} />
123+
<div className="bg-muted">
124+
<BaseNodeTree
125+
mode="view"
126+
emptyText={t('space:baseList.empty')}
127+
skeleton={
128+
<div className="flex w-full flex-col gap-2 px-2">
129+
<Skeleton className="h-7 w-full" />
130+
<Skeleton className="h-7 w-full" />
131+
<Skeleton className="h-7 w-full" />
132+
</div>
133+
}
134+
/>
135+
</div>
125136
</BaseNodeProvider>
126137
</AnchorContext.Provider>
127138
</CollapsibleContent>
@@ -134,7 +145,7 @@ export const BaseList = (props: IBaseListProps) => {
134145
<div className="sticky top-0 z-10 flex h-8 items-center border-b bg-background text-xs font-medium text-muted-foreground">
135146
<div className="flex-1 truncate pl-6 pr-2">{t('space:baseList.allBases')}</div>
136147
<div className="w-40 shrink-0">{t('space:baseList.owner')}</div>
137-
<div className="w-60 shrink-0">{t('space:baseList.lastOpened')}</div>
148+
<div className="w-40 shrink-0 lg:w-60">{t('space:baseList.lastOpened')}</div>
138149
</div>
139150

140151
{/* Rows */}

apps/nextjs-app/src/features/app/blocks/space/space-side-bar/SpaceSwitcher.tsx

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -152,19 +152,15 @@ export const SpaceSwitcher = () => {
152152
<>
153153
<Popover open={open} onOpenChange={setOpen}>
154154
<PopoverTrigger asChild>
155-
<Button
156-
variant="ghost"
157-
size="sm"
158-
className="h-10 min-w-0 flex-1 justify-start p-2 text-base"
159-
>
155+
<Button variant="ghost" size="sm" className="h-10 min-w-0 justify-start p-2 text-base">
160156
<SpaceAvatar name={currentSpace?.name ?? ''} className="size-8" />
161157
<p className="truncate text-left font-semibold ">{currentSpace?.name}</p>
162158
<ChevronDown className="size-4 shrink-0" />
163159
</Button>
164160
</PopoverTrigger>
165161

166162
<PopoverContent className="min-w-[360px] p-0" align="start">
167-
<Command>
163+
<Command value="">
168164
<div className="px-4 pb-2 pt-4">
169165
<p className="pb-2 text-sm font-semibold ">
170166
{t('space:allSpaces')} ({spaceList?.length || 0})

apps/nextjs-app/src/features/app/components/sidebar/Sidebar.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { Button, cn } from '@teable/ui-lib';
44
import type { FC, PropsWithChildren, ReactNode } from 'react';
55
import { useEffect, useState } from 'react';
66
import { useHotkeys } from 'react-hotkeys-hook';
7+
import { useMedia } from 'react-use';
78
import { SIDE_BAR_WIDTH } from '../toggle-side-bar/constant';
89
import { HoverWrapper } from '../toggle-side-bar/HoverWrapper';
910
import { SheetWrapper } from '../toggle-side-bar/SheetWrapper';
@@ -20,7 +21,7 @@ export const Sidebar: FC<PropsWithChildren<ISidebarProps>> = (props) => {
2021
const { headerLeft, children, className } = props;
2122
const isMobile = useIsMobile();
2223
const [leftVisible, setLeftVisible] = useState(true);
23-
24+
const isLargeScreen = useMedia('(min-width: 1024px)');
2425
const { setVisible } = useSidebarStore();
2526

2627
const { status } = useChatPanelStore();
@@ -35,6 +36,10 @@ export const Sidebar: FC<PropsWithChildren<ISidebarProps>> = (props) => {
3536
setVisible(leftVisible);
3637
}, [leftVisible, setVisible]);
3738

39+
useEffect(() => {
40+
setLeftVisible(isLargeScreen);
41+
}, [isLargeScreen]);
42+
3843
return (
3944
<>
4045
{isMobile ? (

packages/ui-lib/src/shadcn/ui/tree.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ function TreeItemLabel<T = any>({
145145
data-drag-target={isDragTarget ? 'true' : undefined}
146146
data-search-match={isSearchMatch ? 'true' : undefined}
147147
className={cn(
148-
'flex items-center gap-1 rounded-md border border-transparent bg-background px-2 py-1 text-sm transition-colors hover:bg-accent group-focus-visible:ring-[3px] group-focus-visible:ring-ring/50 [&_svg]:pointer-events-none [&_svg]:shrink-0',
148+
'flex items-center gap-1 rounded-md border border-transparent px-2 py-1 text-sm transition-colors hover:bg-accent group-focus-visible:ring-[3px] group-focus-visible:ring-ring/50 [&_svg]:pointer-events-none [&_svg]:shrink-0',
149149
!isFolder && 'ps-7',
150150
isDragTarget && 'border-dashed border-foreground bg-foreground/[0.06]',
151151
isSearchMatch && 'bg-blue-400/20',

0 commit comments

Comments
 (0)