@@ -52,6 +52,7 @@ import {
52
52
HelpTooltipTrigger ,
53
53
} from "components/HelpTooltip/HelpTooltip" ;
54
54
import { Loader } from "components/Loader/Loader" ;
55
+ import { Stack } from "components/Stack/Stack" ;
55
56
import { UserAvatar } from "components/UserAvatar/UserAvatar" ;
56
57
import { useEmbeddedMetadata } from "hooks/useEmbeddedMetadata" ;
57
58
import { useTemplateLayoutContext } from "pages/TemplatePage/TemplateLayout" ;
@@ -451,7 +452,7 @@ const TemplateUsagePanel: FC<TemplateUsagePanelProps> = ({
451
452
return (
452
453
< div
453
454
key = { usage . slug }
454
- css = { { display : "flex" , gap : 16 , alignItems : "center" } }
455
+ css = { { display : "flex" , gap : 24 , alignItems : "center" } }
455
456
>
456
457
< div
457
458
css = { { display : "flex" , alignItems : "center" , gap : 8 } }
@@ -492,16 +493,27 @@ const TemplateUsagePanel: FC<TemplateUsagePanelProps> = ({
492
493
} ,
493
494
} }
494
495
/>
495
- < div
496
+ < Stack
497
+ spacing = { 0 }
496
498
css = { {
497
499
fontSize : 13 ,
498
500
color : theme . palette . text . secondary ,
499
501
width : 120 ,
500
502
flexShrink : 0 ,
503
+ lineHeight : "1.5" ,
501
504
} }
502
505
>
503
506
{ formatTime ( usage . seconds ) }
504
- </ div >
507
+ < span
508
+ css = { {
509
+ fontSize : 12 ,
510
+ color : theme . palette . text . disabled ,
511
+ } }
512
+ >
513
+ Opened { usage . times_used . toLocaleString ( ) } { " " }
514
+ { usage . times_used === 1 ? "time" : "times" }
515
+ </ span >
516
+ </ Stack >
505
517
</ div >
506
518
) ;
507
519
} ) }
@@ -869,20 +881,35 @@ const TextValue: FC<PropsWithChildren> = ({ children }) => {
869
881
} ;
870
882
871
883
function formatTime ( seconds : number ) : string {
872
- if ( seconds < 60 ) {
873
- return seconds + " seconds" ;
874
- } else if ( seconds >= 60 && seconds < 3600 ) {
875
- const minutes = Math . floor ( seconds / 60 ) ;
876
- return minutes + " minutes" ;
884
+ let value : {
885
+ amount : number ;
886
+ unit : "seconds" | "minutes" | "hours" ;
887
+ } = {
888
+ amount : seconds ,
889
+ unit : "seconds" ,
890
+ } ;
891
+
892
+ if ( seconds >= 60 && seconds < 3600 ) {
893
+ value = {
894
+ amount : Math . floor ( seconds / 60 ) ,
895
+ unit : "minutes" ,
896
+ } ;
877
897
} else {
878
- const hours = seconds / 3600 ;
879
- const minutes = Math . floor ( seconds % 3600 ) ;
880
- if ( minutes === 0 ) {
881
- return hours . toFixed ( 0 ) + " hours" ;
882
- }
898
+ value = {
899
+ amount : seconds / 3600 ,
900
+ unit : "hours" ,
901
+ } ;
902
+ }
883
903
884
- return hours . toFixed ( 1 ) + " hours" ;
904
+ if ( value . amount === 1 ) {
905
+ const singularUnit = value . unit . slice ( 0 , - 1 ) ;
906
+ return `${ value . amount } ${ singularUnit } ` ;
885
907
}
908
+
909
+ return `${ value . amount . toLocaleString ( undefined , {
910
+ maximumFractionDigits : 1 ,
911
+ minimumFractionDigits : 0 ,
912
+ } ) } ${ value . unit } `;
886
913
}
887
914
888
915
function toISOLocal ( d : Date , offset : number ) {
0 commit comments