Skip to content

Commit 1bc2391

Browse files
committed
refactor: improve layout and styling
1 parent c38c8c2 commit 1bc2391

File tree

5 files changed

+34
-31
lines changed

5 files changed

+34
-31
lines changed

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

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -85,27 +85,26 @@ export const BaseItem: FC<IBaseItemProps> = (props) => {
8585

8686
return (
8787
<div
88-
className={cn('group flex h-12 items-center hover:bg-accent', className)}
88+
className={cn('group flex h-12 items-center cursor-pointer hover:bg-accent', className)}
8989
onClick={() => onToggleExpand?.()}
9090
>
91+
<Button
92+
variant="ghost"
93+
size="xs"
94+
className="size-4 shrink-0 p-0"
95+
onClick={(e) => {
96+
stopPropagation(e);
97+
onToggleExpand?.();
98+
}}
99+
>
100+
{isExpanded ? (
101+
<ChevronDown className="size-4 text-muted-foreground" />
102+
) : (
103+
<ChevronRight className="size-4 text-muted-foreground" />
104+
)}
105+
</Button>
91106
{/* Name Column */}
92107
<div className="flex h-8 w-full flex-1 items-center gap-2 overflow-hidden px-2">
93-
<Button
94-
variant="ghost"
95-
size="xs"
96-
className="size-4 shrink-0 p-0"
97-
onClick={(e) => {
98-
stopPropagation(e);
99-
onToggleExpand?.();
100-
}}
101-
>
102-
{isExpanded ? (
103-
<ChevronDown className="size-4 text-muted-foreground" />
104-
) : (
105-
<ChevronRight className="size-4 text-muted-foreground" />
106-
)}
107-
</Button>
108-
109108
<div
110109
className="flex items-center"
111110
onClick={(e) => hasUpdatePermission && stopPropagation(e)}
@@ -157,7 +156,7 @@ export const BaseItem: FC<IBaseItemProps> = (props) => {
157156
</div>
158157

159158
{/* Creator Column */}
160-
<div className="flex w-44 shrink-0 items-center gap-2 px-4">
159+
<div className="flex w-40 shrink-0 items-center gap-2">
161160
<Avatar className="size-6 border">
162161
<AvatarImage src={base.createdUser?.avatar ?? ''} />
163162
<AvatarFallback className="text-xs">{base.createdUser?.name?.slice(0, 1)}</AvatarFallback>
@@ -166,13 +165,13 @@ export const BaseItem: FC<IBaseItemProps> = (props) => {
166165
</div>
167166

168167
{/* Last Opened Column */}
169-
<div className="w-44 shrink-0 px-4 text-xs">
168+
<div className="w-60 shrink-0 text-xs">
170169
{lastVisitTime ? dayjs(lastVisitTime).fromNow() : '-'}
171170
</div>
172171

173172
{/* Actions Column */}
174173
<div
175-
className="w-37 flex shrink-0 items-center justify-end gap-2 px-4 opacity-0 group-hover:opacity-100"
174+
className="absolute right-0 flex shrink-0 items-center justify-end gap-2 bg-accent px-4 opacity-0 group-hover:opacity-100"
176175
onClick={stopPropagation}
177176
onMouseDown={stopPropagation}
178177
>

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

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,6 @@ export const BaseList = (props: IBaseListProps) => {
112112
<BaseItem
113113
base={base}
114114
lastVisitTime={lastVisitBaseMap[base.id]?.lastVisitTime}
115-
className="cursor-pointer"
116115
isExpanded={expandedBases.has(base.id)}
117116
onToggleExpand={() => toggleExpanded(base.id)}
118117
onEnterBase={() => intoBase(base.id)}
@@ -133,10 +132,9 @@ export const BaseList = (props: IBaseListProps) => {
133132
<ScrollArea className="h-full !border-none bg-background [&>[data-radix-scroll-area-viewport]>div]:!block [&>[data-radix-scroll-area-viewport]>div]:!min-h-0 [&>[data-radix-scroll-area-viewport]>div]:!min-w-0">
134133
{/* Header */}
135134
<div className="sticky top-0 z-10 flex h-8 items-center border-b bg-background text-xs font-medium text-muted-foreground">
136-
<div className="flex-1 pl-8 pr-4">{t('space:baseList.allBases')}</div>
137-
<div className="w-44 shrink-0 px-4">{t('space:baseList.owner')}</div>
138-
<div className="w-44 shrink-0 px-4">{t('space:baseList.lastOpened')}</div>
139-
<div className="w-[147px] shrink-0" />
135+
<div className="flex-1 truncate pl-6 pr-2">{t('space:baseList.allBases')}</div>
136+
<div className="w-40 shrink-0">{t('space:baseList.owner')}</div>
137+
<div className="w-60 shrink-0">{t('space:baseList.lastOpened')}</div>
140138
</div>
141139

142140
{/* Rows */}

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,9 @@ export const SpaceInnerPage: React.FC = () => {
121121
isRenaming={renaming}
122122
onChange={(e) => setSpaceName(e.target.value)}
123123
onBlur={(e) => toggleUpdateSpace(e)}
124+
className="h-8"
124125
>
125-
<h1 className="line-clamp-1 text-2xl font-semibold ">{space.name}</h1>
126+
<h1 className="truncate text-2xl font-semibold">{space.name}</h1>
126127
</SpaceRenaming>
127128
<StarButton className="opacity-100" id={space.id} type={PinType.Space} />
128129
{isCloud && (

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

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

apps/nextjs-app/src/features/app/components/space/SpaceRenaming.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
import { Input } from '@teable/ui-lib';
1+
import { cn, Input } from '@teable/ui-lib';
22
import React, { useEffect, useRef } from 'react';
33

44
interface SpaceRenamingProps {
5+
className?: string;
56
spaceName: string;
67
isRenaming: boolean;
78
children: React.ReactNode;
@@ -10,7 +11,7 @@ interface SpaceRenamingProps {
1011
}
1112

1213
export const SpaceRenaming: React.FC<SpaceRenamingProps> = (props) => {
13-
const { spaceName, isRenaming, children, onChange, onBlur } = props;
14+
const { spaceName, isRenaming, children, onChange, onBlur, className } = props;
1415
const inputRef = useRef<HTMLInputElement>(null);
1516

1617
useEffect(() => {
@@ -32,7 +33,7 @@ export const SpaceRenaming: React.FC<SpaceRenamingProps> = (props) => {
3233
{isRenaming ? (
3334
<Input
3435
ref={inputRef}
35-
className="m-0.5 h-6 flex-1"
36+
className={cn('m-0.5 h-6 flex-1', className)}
3637
value={spaceName}
3738
onKeyDown={handleKeyDown}
3839
onChange={onChange}

0 commit comments

Comments
 (0)