Skip to content

Commit dc75035

Browse files
committed
refactor(landing): clean up code quality issues in preview components
- Replace widthMultiplier with explicit width on PreviewColumn - Replace key={i} with key={Icon.name} in connectorIcons - Scope --c-active CSS variable to sidebar container, eliminating hardcoded #363636 duplication - Replace '- - -' fallback with em dash - Type onSelectNav as (id: SidebarView) removing the unsafe cast
1 parent 270de9f commit dc75035

File tree

5 files changed

+16
-18
lines changed

5 files changed

+16
-18
lines changed

apps/sim/app/(home)/components/landing-preview/components/landing-preview-knowledge/landing-preview-knowledge.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ function connectorIcons(icons: React.ComponentType<{ className?: string }>[]) {
2222
return {
2323
content: (
2424
<div className='flex items-center gap-1'>
25-
{icons.map((Icon, i) => (
26-
<Icon key={i} className='h-3.5 w-3.5 flex-shrink-0' />
25+
{icons.map((Icon) => (
26+
<Icon key={Icon.name} className='h-3.5 w-3.5 flex-shrink-0' />
2727
))}
2828
</div>
2929
),

apps/sim/app/(home)/components/landing-preview/components/landing-preview-resource/landing-preview-resource.tsx

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { cn } from '@/lib/core/utils/cn'
88
export interface PreviewColumn {
99
id: string
1010
header: string
11-
widthMultiplier?: number
11+
width?: number
1212
}
1313

1414
export interface PreviewCell {
@@ -135,11 +135,7 @@ export function LandingPreviewResource({
135135
{columns.map((col, i) => (
136136
<col
137137
key={col.id}
138-
style={
139-
i === 0
140-
? { minWidth: 200 * (col.widthMultiplier ?? 1) }
141-
: { width: 160 * (col.widthMultiplier ?? 1) }
142-
}
138+
style={i === 0 ? { minWidth: col.width ?? 200 } : { width: col.width ?? 160 }}
143139
/>
144140
))}
145141
</colgroup>
@@ -199,7 +195,7 @@ export function LandingPreviewResource({
199195
{cell.icon}
200196
</span>
201197
)}
202-
<span className='truncate'>{cell?.label ?? '- - -'}</span>
198+
<span className='truncate'>{cell?.label ?? ''}</span>
203199
</span>
204200
)}
205201
</td>

apps/sim/app/(home)/components/landing-preview/components/landing-preview-scheduled-tasks/landing-preview-scheduled-tasks.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ const CAL_ICON = <Calendar className='h-[14px] w-[14px]' />
99

1010
const COLUMNS: PreviewColumn[] = [
1111
{ id: 'task', header: 'Task' },
12-
{ id: 'schedule', header: 'Schedule', widthMultiplier: 1.5 },
12+
{ id: 'schedule', header: 'Schedule', width: 240 },
1313
{ id: 'nextRun', header: 'Next Run' },
1414
{ id: 'lastRun', header: 'Last Run' },
1515
]

apps/sim/app/(home)/components/landing-preview/components/landing-preview-sidebar/landing-preview-sidebar.tsx

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ interface LandingPreviewSidebarProps {
2828
activeView: SidebarView
2929
onSelectWorkflow: (id: string) => void
3030
onSelectHome: () => void
31-
onSelectNav: (id: string) => void
31+
onSelectNav: (id: SidebarView) => void
3232
}
3333

3434
/**
@@ -87,8 +87,8 @@ function NavItem({
8787
type='button'
8888
onClick={onClick}
8989
className={cn(
90-
'mx-0.5 flex h-[28px] items-center gap-2 rounded-[8px] px-2 transition-colors hover-hover:bg-[#363636]',
91-
isActive && 'bg-[#363636]'
90+
'mx-0.5 flex h-[28px] items-center gap-2 rounded-[8px] px-2 transition-colors hover-hover:bg-[var(--c-active)]',
91+
isActive && 'bg-[var(--c-active)]'
9292
)}
9393
>
9494
<Icon className='h-[14px] w-[14px] flex-shrink-0' style={{ color: C.TEXT_ICON }} />
@@ -117,7 +117,9 @@ export function LandingPreviewSidebar({
117117
return (
118118
<div
119119
className='flex h-full w-[248px] flex-shrink-0 flex-col pt-3'
120-
style={{ backgroundColor: C.SURFACE_1 }}
120+
style={
121+
{ backgroundColor: C.SURFACE_1, '--c-active': C.SURFACE_ACTIVE } as React.CSSProperties
122+
}
121123
>
122124
{/* Workspace Header */}
123125
<div className='flex-shrink-0 px-2.5'>
@@ -151,8 +153,8 @@ export function LandingPreviewSidebar({
151153
type='button'
152154
onClick={onSelectHome}
153155
className={cn(
154-
'mx-0.5 flex h-[28px] items-center gap-2 rounded-[8px] px-2 transition-colors hover-hover:bg-[#363636]',
155-
isHomeActive && 'bg-[#363636]'
156+
'mx-0.5 flex h-[28px] items-center gap-2 rounded-[8px] px-2 transition-colors hover-hover:bg-[var(--c-active)]',
157+
isHomeActive && 'bg-[var(--c-active)]'
156158
)}
157159
>
158160
<Home className='h-[14px] w-[14px] flex-shrink-0' style={{ color: C.TEXT_ICON }} />

apps/sim/app/(home)/components/landing-preview/landing-preview.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,8 @@ export function LandingPreview() {
7878
setActiveView('home')
7979
}, [])
8080

81-
const handleSelectNav = useCallback((id: string) => {
82-
setActiveView(id as SidebarView)
81+
const handleSelectNav = useCallback((id: SidebarView) => {
82+
setActiveView(id)
8383
}, [])
8484

8585
const activeWorkflow =

0 commit comments

Comments
 (0)