File tree Expand file tree Collapse file tree
packages/unpkg-www/src/components Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -20,7 +20,14 @@ export function RunDemo({ runUrl }: { runUrl: string }): VNode {
2020 }
2121
2222 setState ( "running" ) ;
23- let slowRunTimer = setTimeout ( ( ) => setSlowRun ( true ) , 250 ) ;
23+ // Show the running state only when a run is genuinely slow, and once shown
24+ // keep it up for a minimum time — otherwise runs near the threshold (every
25+ // click does a real /transform round trip) blink the label.
26+ let slowRunShownAt = 0 ;
27+ let slowRunTimer = setTimeout ( ( ) => {
28+ slowRunShownAt = Date . now ( ) ;
29+ setSlowRun ( true ) ;
30+ } , 300 ) ;
2431
2532 try {
2633 // Recreate the example's inline script tag and hand it to the real /run
@@ -42,7 +49,12 @@ export function RunDemo({ runUrl }: { runUrl: string }): VNode {
4249 setState ( "error" ) ;
4350 } finally {
4451 clearTimeout ( slowRunTimer ) ;
45- setSlowRun ( false ) ;
52+ if ( slowRunShownAt === 0 ) {
53+ setSlowRun ( false ) ;
54+ } else {
55+ let remaining = Math . max ( 0 , 500 - ( Date . now ( ) - slowRunShownAt ) ) ;
56+ setTimeout ( ( ) => setSlowRun ( false ) , remaining ) ;
57+ }
4658 }
4759 }
4860
You can’t perform that action at this time.
0 commit comments