Skip to content

Commit 9dc6b41

Browse files
committed
refactor(ui): lazy-init object refs and use size-* for equal height and width
useRef(new X()) built a throwaway X on every render; the refs now lazy-init through ??= as sim-react-performance.md prescribes. Equal h-N w-N pairs become size-N per sim-styling.md.
1 parent 1dfa35d commit 9dc6b41

60 files changed

Lines changed: 154 additions & 152 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎apps/docs/components/ui/video-placeholder.tsx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ export function VideoPlaceholder({
113113
pendingSeek.current = null
114114
}
115115
}}
116-
className='h-full w-full border-0'
116+
className='size-full border-0'
117117
>
118118
<track
119119
kind='captions'

‎apps/docs/components/workflow-preview/block-preview.tsx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ export function BlockPreview({ type }: BlockPreviewProps) {
6363
panOnDrag={false}
6464
panOnScroll={false}
6565
preventScrolling={false}
66-
className='h-full w-full [--text-muted:var(--text-secondary)]! [--xy-background-color:var(--bg)]'
66+
className='size-full [--text-muted:var(--text-secondary)]! [--xy-background-color:var(--bg)]'
6767
/>
6868
</ReactFlowProvider>
6969
</LazyMotion>

‎apps/docs/components/workflow-preview/docs-container-node.tsx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ export const DocsContainerNode = memo(function DocsContainerNode({
3939
}
4040

4141
return (
42-
<div className={cn('h-full w-full', data.isDimmed && DIMMED_PREVIEW_CLASS)}>
42+
<div className={cn('size-full', data.isDimmed && DIMMED_PREVIEW_CLASS)}>
4343
<SubflowNodeView
4444
id={id}
4545
data={subflowData}

‎apps/docs/components/workflow-preview/workflow-preview.tsx‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ function PreviewFlow({
224224
autoPanOnNodeDrag={false}
225225
proOptions={PRO_OPTIONS}
226226
minZoom={0.1}
227-
className='h-full w-full [--text-muted:var(--text-secondary)]! [--xy-background-color:var(--bg)]'
227+
className='size-full [--text-muted:var(--text-secondary)]! [--xy-background-color:var(--bg)]'
228228
>
229229
<FitViewAfterInit options={interactive ? LIGHTBOX_FIT_VIEW_OPTIONS : FIT_VIEW_OPTIONS} />
230230
</ReactFlow>
@@ -329,7 +329,7 @@ export function WorkflowPreview({
329329
className='fixed inset-0 m-auto h-[86dvh] max-h-none w-[92vw] max-w-none overflow-hidden rounded-xl border border-[var(--border)] bg-[var(--bg)] p-0 text-[var(--text-body)] backdrop:bg-black/70 backdrop:backdrop-blur-sm'
330330
>
331331
{expanded && (
332-
<div className='relative flex h-full w-full flex-col sm:flex-row'>
332+
<div className='relative flex size-full flex-col sm:flex-row'>
333333
<div className='relative min-h-0 min-w-0 flex-1'>
334334
<div className='pointer-events-none absolute top-0 right-0 left-0 z-10 flex items-center justify-between px-4 py-3'>
335335
<span className='text-[var(--text-muted)] text-small'>{workflow.name}</span>

‎apps/sim/app/(interfaces)/chat/components/input/input.tsx‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -177,10 +177,10 @@ export const ChatInput: React.FC<{
177177
<img
178178
src={file.dataUrl}
179179
alt={file.name}
180-
className='h-full w-full object-cover'
180+
className='size-full object-cover'
181181
/>
182182
) : (
183-
<div className='flex h-full w-full flex-col items-center justify-center gap-0.5 text-[var(--text-muted)]'>
183+
<div className='flex size-full flex-col items-center justify-center gap-0.5 text-[var(--text-muted)]'>
184184
<Paperclip className='size-[18px]' />
185185
<span className='max-w-[48px] truncate px-[2px] text-[9px]'>
186186
{file.name.split('.').pop()}

‎apps/sim/app/(landing)/components/hero/components/hero-chat-loop/hero-chat-loop.tsx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ export function HeroChatLoop({
179179

180180
return (
181181
<div
182-
className='relative flex h-full w-full flex-col bg-[var(--bg)]'
182+
className='relative flex size-full flex-col bg-[var(--bg)]'
183183
data-chat-view={welcome ? 'welcome' : 'conversation'}
184184
data-chat-phase={phase}
185185
>

‎apps/sim/app/(landing)/components/hero/components/hero-platform-loop/hero-platform-loop.tsx‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ export function HeroPlatformLoop() {
266266
>
267267
<div
268268
ref={previewContainerRef}
269-
className='relative flex h-full w-full overflow-hidden rounded-[6px] border border-[var(--border)] bg-[var(--bg)] [--preview-resource-width:50%]'
269+
className='relative flex size-full overflow-hidden rounded-[6px] border border-[var(--border)] bg-[var(--bg)] [--preview-resource-width:50%]'
270270
>
271271
<div className={cn('relative h-full min-w-0 flex-1', stageOpen && 'max-lg:hidden')}>
272272
<HeroChatLoop
@@ -338,7 +338,7 @@ export function HeroPlatformLoop() {
338338
>
339339
<div
340340
className={cn(
341-
'h-full w-full transition-[transform,opacity] duration-[480ms] ease-[cubic-bezier(0.22,1,0.36,1)] motion-reduce:transition-none',
341+
'size-full transition-[transform,opacity] duration-[480ms] ease-[cubic-bezier(0.22,1,0.36,1)] motion-reduce:transition-none',
342342
stageOpen ? 'translate-x-0 opacity-100' : 'translate-x-6 opacity-0'
343343
)}
344344
>

‎apps/sim/app/(landing)/components/hero/components/hero-platform-loop/stage-block-card.tsx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,7 @@ export function StageBlockCard({
350350
if (onSelect) handleKeyboardActivation(event, () => onSelect(block.id))
351351
}}
352352
className={cn(
353-
'relative h-full w-full rounded-2xl',
353+
'relative size-full rounded-2xl',
354354
onSelect && 'cursor-pointer focus-visible:outline-none'
355355
)}
356356
>

‎apps/sim/app/(landing)/components/navbar/components/nav-menu-chip/components/nav-menu-preview/components/workflow-menu-preview/workflow-menu-preview.tsx‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,13 @@ interface WorkflowMenuPreviewProps {
3131

3232
/** A cropped production canvas with a clear center and progressively softened inner edges. */
3333
export function WorkflowMenuPreview({ layout = 'menu', onReady }: WorkflowMenuPreviewProps) {
34-
const readyBlocksRef = useRef(new Set<string>())
34+
const readyBlocksRef = useRef<Set<string> | null>(null)
35+
const readyBlocks = (readyBlocksRef.current ??= new Set())
3536

3637
const handleBlockReady = (blockId: string) => {
37-
if (readyBlocksRef.current.has(blockId)) return
38-
readyBlocksRef.current.add(blockId)
39-
if (readyBlocksRef.current.size === BLOCKS.length) onReady?.()
38+
if (readyBlocks.has(blockId)) return
39+
readyBlocks.add(blockId)
40+
if (readyBlocks.size === BLOCKS.length) onReady?.()
4041
}
4142

4243
return (

‎apps/sim/app/(landing)/components/platform-hero-visual/platform-hero-visual.tsx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ interface PlatformHeroVisualProps {
2020
*/
2121
export function PlatformHeroVisual({ children }: PlatformHeroVisualProps) {
2222
return (
23-
<div className='relative h-full w-full'>
23+
<div className='relative size-full'>
2424
<Image
2525
fill
2626
priority

0 commit comments

Comments
 (0)