Skip to content

Commit a58de5a

Browse files
committed
fix(sidebar): align collapsed settings skeletons with actual icon positions
1 parent af872df commit a58de5a

File tree

1 file changed

+87
-82
lines changed
  • apps/sim/app/workspace/[workspaceId]/w/components/sidebar/components/settings-sidebar

1 file changed

+87
-82
lines changed

apps/sim/app/workspace/[workspaceId]/w/components/sidebar/components/settings-sidebar/settings-sidebar.tsx

Lines changed: 87 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -205,96 +205,101 @@ export function SettingsSidebar({
205205
!isCollapsed && 'overflow-y-auto overflow-x-hidden'
206206
)}
207207
>
208-
{sessionLoading || orgsLoading
209-
? isCollapsed
210-
? Array.from({ length: 7 }, (_, i) => (
208+
{sessionLoading || orgsLoading ? (
209+
isCollapsed ? (
210+
<div className='flex flex-col gap-[2px] px-[8px]'>
211+
{Array.from({ length: 7 }, (_, i) => (
211212
<div key={i} className='mx-[2px] flex h-[30px] items-center px-[8px]'>
212213
<Skeleton className='h-[16px] w-[16px] rounded-[4px]' />
213214
</div>
214-
))
215-
: Array.from({ length: 3 }, (_, i) => (
216-
<div key={i} className='sidebar-collapse-hide flex flex-shrink-0 flex-col'>
217-
<div className='px-[16px] pb-[6px]'>
218-
<Skeleton className='h-[14px] w-[64px] rounded-[4px]' />
219-
</div>
220-
<div className='flex flex-col gap-[2px] px-[8px]'>
221-
{Array.from({ length: i === 0 ? 3 : 2 }, (_, j) => (
222-
<div key={j} className='mx-[2px] flex h-[30px] items-center px-[8px]'>
223-
<Skeleton className='h-[24px] w-full rounded-[4px]' />
224-
</div>
225-
))}
226-
</div>
215+
))}
216+
</div>
217+
) : (
218+
Array.from({ length: 3 }, (_, i) => (
219+
<div key={i} className='sidebar-collapse-hide flex flex-shrink-0 flex-col'>
220+
<div className='px-[16px] pb-[6px]'>
221+
<Skeleton className='h-[14px] w-[64px] rounded-[4px]' />
227222
</div>
228-
))
229-
: sectionConfig.map(({ key, title }) => {
230-
const sectionItems = navigationItems.filter((item) => item.section === key)
231-
if (sectionItems.length === 0) return null
232-
233-
return (
234-
<div key={key} className='flex flex-shrink-0 flex-col'>
235-
{!isCollapsed && (
236-
<div className='sidebar-collapse-remove px-[16px] pb-[6px]'>
237-
<div className='font-base text-[var(--text-icon)] text-small'>{title}</div>
223+
<div className='flex flex-col gap-[2px] px-[8px]'>
224+
{Array.from({ length: i === 0 ? 3 : 2 }, (_, j) => (
225+
<div key={j} className='mx-[2px] flex h-[30px] items-center px-[8px]'>
226+
<Skeleton className='h-[24px] w-full rounded-[4px]' />
238227
</div>
239-
)}
240-
<div className='flex flex-col gap-[2px] px-[8px]'>
241-
{sectionItems.map((item) => {
242-
const Icon = item.icon
243-
const active = activeSection === item.id
244-
const itemClassName = cn(
245-
'group mx-[2px] flex h-[30px] items-center gap-[8px] rounded-[8px] px-[8px] text-[14px] hover:bg-[var(--surface-active)]',
246-
active && 'bg-[var(--surface-active)]'
247-
)
248-
const content = (
249-
<>
250-
<Icon className='h-[16px] w-[16px] flex-shrink-0 text-[var(--text-icon)]' />
251-
<span className='truncate font-base text-[var(--text-body)]'>
252-
{item.label}
253-
</span>
254-
</>
255-
)
256-
257-
const element = item.externalUrl ? (
258-
<a
259-
href={item.externalUrl}
260-
target='_blank'
261-
rel='noopener noreferrer'
262-
className={itemClassName}
263-
>
264-
{content}
265-
</a>
266-
) : (
267-
<button
268-
type='button'
269-
className={itemClassName}
270-
onMouseEnter={() => handlePrefetch(item.id)}
271-
onFocus={() => handlePrefetch(item.id)}
272-
onClick={() =>
273-
router.replace(
274-
getSettingsHref({ section: item.id as SettingsSection }),
275-
{ scroll: false }
276-
)
277-
}
278-
>
279-
{content}
280-
</button>
281-
)
228+
))}
229+
</div>
230+
</div>
231+
))
232+
)
233+
) : (
234+
sectionConfig.map(({ key, title }) => {
235+
const sectionItems = navigationItems.filter((item) => item.section === key)
236+
if (sectionItems.length === 0) return null
282237

283-
return (
284-
<Tooltip.Root key={`${item.id}-${isCollapsed}`}>
285-
<Tooltip.Trigger asChild>{element}</Tooltip.Trigger>
286-
{showCollapsedContent && (
287-
<Tooltip.Content side='right'>
288-
<p>{item.label}</p>
289-
</Tooltip.Content>
290-
)}
291-
</Tooltip.Root>
292-
)
293-
})}
238+
return (
239+
<div key={key} className='flex flex-shrink-0 flex-col'>
240+
{!isCollapsed && (
241+
<div className='sidebar-collapse-remove px-[16px] pb-[6px]'>
242+
<div className='font-base text-[var(--text-icon)] text-small'>{title}</div>
294243
</div>
244+
)}
245+
<div className='flex flex-col gap-[2px] px-[8px]'>
246+
{sectionItems.map((item) => {
247+
const Icon = item.icon
248+
const active = activeSection === item.id
249+
const itemClassName = cn(
250+
'group mx-[2px] flex h-[30px] items-center gap-[8px] rounded-[8px] px-[8px] text-[14px] hover:bg-[var(--surface-active)]',
251+
active && 'bg-[var(--surface-active)]'
252+
)
253+
const content = (
254+
<>
255+
<Icon className='h-[16px] w-[16px] flex-shrink-0 text-[var(--text-icon)]' />
256+
<span className='truncate font-base text-[var(--text-body)]'>
257+
{item.label}
258+
</span>
259+
</>
260+
)
261+
262+
const element = item.externalUrl ? (
263+
<a
264+
href={item.externalUrl}
265+
target='_blank'
266+
rel='noopener noreferrer'
267+
className={itemClassName}
268+
>
269+
{content}
270+
</a>
271+
) : (
272+
<button
273+
type='button'
274+
className={itemClassName}
275+
onMouseEnter={() => handlePrefetch(item.id)}
276+
onFocus={() => handlePrefetch(item.id)}
277+
onClick={() =>
278+
router.replace(getSettingsHref({ section: item.id as SettingsSection }), {
279+
scroll: false,
280+
})
281+
}
282+
>
283+
{content}
284+
</button>
285+
)
286+
287+
return (
288+
<Tooltip.Root key={`${item.id}-${isCollapsed}`}>
289+
<Tooltip.Trigger asChild>{element}</Tooltip.Trigger>
290+
{showCollapsedContent && (
291+
<Tooltip.Content side='right'>
292+
<p>{item.label}</p>
293+
</Tooltip.Content>
294+
)}
295+
</Tooltip.Root>
296+
)
297+
})}
295298
</div>
296-
)
297-
})}
299+
</div>
300+
)
301+
})
302+
)}
298303
</div>
299304
</>
300305
)

0 commit comments

Comments
 (0)