@@ -6,7 +6,7 @@ import { useSetHeaderContent } from "@posthog/ui/hooks/useSetHeaderContent";
66import { Button } from "@posthog/ui/primitives/Button" ;
77import { navigateToNewLoop } from "@posthog/ui/router/navigationBridge" ;
88import { Flex , Heading , Text } from "@radix-ui/themes" ;
9- import { useMemo } from "react" ;
9+ import { useMemo , useState } from "react" ;
1010import { useLoopLimits , useLoops } from "../hooks/useLoops" ;
1111import { useLoopDraftStore } from "../loopDraftStore" ;
1212import type { LoopTemplate } from "../loopTemplates" ;
@@ -24,6 +24,8 @@ function loopLimitReason(max: number): string {
2424
2525const EMPTY_MEMBERS : UserBasic [ ] = [ ] ;
2626
27+ const SECTION_PREVIEW_COUNT = 5 ;
28+
2729function startBlankLoop ( ) : void {
2830 useLoopDraftStore . getState ( ) . setPrefill ( null ) ;
2931 navigateToNewLoop ( ) ;
@@ -219,13 +221,16 @@ function LoopListSection({
219221 membersError ?: boolean ;
220222 membersComplete ?: boolean ;
221223} ) {
224+ const [ expanded , setExpanded ] = useState ( false ) ;
225+ const visibleLoops = expanded ? loops : loops . slice ( 0 , SECTION_PREVIEW_COUNT ) ;
226+
222227 return (
223228 < Flex direction = "column" gap = "3" >
224229 < Text className = "font-medium text-[12px] text-gray-10 uppercase tracking-wide" >
225230 { title }
226231 </ Text >
227232 < Flex direction = "column" gap = "2" >
228- { loops . map ( ( loop ) => (
233+ { visibleLoops . map ( ( loop ) => (
229234 < LoopRow
230235 key = { loop . id }
231236 loop = { loop }
@@ -236,6 +241,17 @@ function LoopListSection({
236241 />
237242 ) ) }
238243 </ Flex >
244+ { loops . length > SECTION_PREVIEW_COUNT ? (
245+ < Button
246+ variant = "ghost"
247+ color = "gray"
248+ size = "1"
249+ className = "w-fit"
250+ onClick = { ( ) => setExpanded ( ! expanded ) }
251+ >
252+ { expanded ? "Show fewer" : `Show all ${ loops . length } ` }
253+ </ Button >
254+ ) : null }
239255 </ Flex >
240256 ) ;
241257}
0 commit comments