@@ -134,6 +134,58 @@ function NoEntriesFound(): JSXElement {
134134 ) ;
135135}
136136
137+ const friendsRankColumn = ( ) =>
138+ createColumnHelper < SpeedEntry | XpEntry > ( ) . accessor ( "friendsRank" , {
139+ header : ( ) => < Fa icon = "fa-user-friends" /> ,
140+ cell : ( info ) =>
141+ info . getValue ( ) === 1 ? < Fa icon = "fa-crown" /> : info . getValue ( ) ,
142+ meta : {
143+ align : "center" ,
144+ headerMeta : {
145+ "aria-label" : "Friends rank" ,
146+ "data-balloon-pos" : "down" ,
147+ } ,
148+ } ,
149+ } ) ;
150+
151+ const rankColumn = ( friendsOnly : boolean ) =>
152+ createColumnHelper < SpeedEntry | XpEntry > ( ) . accessor ( "rank" , {
153+ header : ( ) => < Fa icon = { friendsOnly ? "fa-users" : "fa-hashtag" } /> ,
154+ cell : ( info ) =>
155+ info . getValue ( ) === 1 ? < Fa icon = "fa-crown" /> : info . getValue ( ) ,
156+ meta : {
157+ align : "center" ,
158+ headerMeta : {
159+ "aria-label" : "Global rank" ,
160+ "data-balloon-pos" : "down" ,
161+ } ,
162+ } ,
163+ } ) ;
164+
165+ const userColumn = ( {
166+ userOverride,
167+ } : {
168+ userOverride ?: Accessor < JSXElement > ;
169+ } ) =>
170+ createColumnHelper < SpeedEntry | XpEntry > ( ) . accessor ( "uid" , {
171+ header : "name" ,
172+ cell : ( info ) =>
173+ userOverride ?.( ) ?? (
174+ < User
175+ avatarFallback = "user-circle"
176+ avatarColor = "sub"
177+ flagsColor = "sub"
178+ user = { info . row . original }
179+ isFriend = { isFriend ( info . row . original . uid ) }
180+ class = "w-min text-[1em] **:data-[ui-element='button']:[--themable-button-text:var(--text-color)]"
181+ linkToProfile = { true }
182+ />
183+ ) ,
184+ meta : {
185+ cellMeta : ( ) => ( { class : "w-full" } ) ,
186+ } ,
187+ } ) ;
188+
137189function getSpeedColumns ( {
138190 friendsOnly,
139191 format,
@@ -147,48 +199,9 @@ function getSpeedColumns({
147199} ) : DataTableColumnDef < SpeedEntry > [ ] {
148200 const defineColumn = createColumnHelper < SpeedEntry > ( ) . accessor ;
149201 const columns = [
150- defineColumn ( "friendsRank" , {
151- header : ( ) => < Fa icon = "fa-user-friends" /> ,
152- cell : ( info ) =>
153- info . getValue ( ) === 1 ? < Fa icon = "fa-crown" /> : info . getValue ( ) ,
154- meta : {
155- align : "center" ,
156- headerMeta : {
157- "aria-label" : "Friends rank" ,
158- "data-balloon-pos" : "down" ,
159- } ,
160- } ,
161- } ) ,
162- defineColumn ( "rank" , {
163- header : ( ) => < Fa icon = { friendsOnly ? "fa-users" : "fa-hashtag" } /> ,
164- cell : ( info ) =>
165- info . getValue ( ) === 1 ? < Fa icon = "fa-crown" /> : info . getValue ( ) ,
166- meta : {
167- align : "center" ,
168- headerMeta : {
169- "aria-label" : "Global rank" ,
170- "data-balloon-pos" : "down" ,
171- } ,
172- } ,
173- } ) ,
174- defineColumn ( "uid" , {
175- header : "name" ,
176- cell : ( info ) =>
177- userOverride ?.( ) ?? (
178- < User
179- avatarFallback = "user-circle"
180- avatarColor = "sub"
181- flagsColor = "sub"
182- user = { info . row . original }
183- isFriend = { isFriend ( info . row . original . uid ) }
184- class = "w-min text-[1em] **:data-[ui-element='button']:[--themable-button-text:var(--text-color)]"
185- linkToProfile = { true }
186- />
187- ) ,
188- meta : {
189- cellMeta : ( ) => ( { class : "w-full" } ) ,
190- } ,
191- } ) ,
202+ friendsRankColumn ( ) as DataTableColumnDef < SpeedEntry > ,
203+ rankColumn ( friendsOnly ) as DataTableColumnDef < SpeedEntry > ,
204+ userColumn ( { userOverride } ) as DataTableColumnDef < SpeedEntry > ,
192205 defineColumn ( "wpm" , {
193206 header : format . typingSpeedUnit ,
194207 cell : ( info ) =>
@@ -349,45 +362,9 @@ function getXpColumns({
349362} ) : DataTableColumnDef < XpEntry > [ ] {
350363 const defineColumn = createColumnHelper < XpEntry > ( ) . accessor ;
351364 const columns = [
352- defineColumn ( "friendsRank" , {
353- header : ( ) => < Fa icon = "fa-user-friends" /> ,
354- cell : ( info ) =>
355- info . getValue ( ) === 1 ? < Fa icon = "fa-crown" /> : info . getValue ( ) ,
356- meta : {
357- align : "center" ,
358- headerMeta : {
359- "aria-label" : "Friends rank" ,
360- "data-balloon-pos" : "down" ,
361- } ,
362- } ,
363- } ) ,
364- defineColumn ( "rank" , {
365- header : ( ) => < Fa icon = { friendsOnly ? "fa-users" : "fa-hashtag" } /> ,
366- cell : ( info ) =>
367- info . getValue ( ) === 1 ? < Fa icon = "fa-crown" /> : info . getValue ( ) ,
368- meta : {
369- align : "center" ,
370- headerMeta : {
371- "aria-label" : "Global rank" ,
372- "data-balloon-pos" : "down" ,
373- } ,
374- } ,
375- } ) ,
376- defineColumn ( "uid" , {
377- header : "name" ,
378- cell : ( info ) =>
379- userOverride ?.( ) ?? (
380- < User
381- user = { info . row . original }
382- isFriend = { isFriend ( info . row . original . uid ) }
383- class = "text-[1em]"
384- linkToProfile = { true }
385- />
386- ) ,
387- meta : {
388- cellMeta : ( ) => ( { class : "w-full" } ) ,
389- } ,
390- } ) ,
365+ friendsRankColumn ( ) as DataTableColumnDef < XpEntry > ,
366+ rankColumn ( friendsOnly ) as DataTableColumnDef < XpEntry > ,
367+ userColumn ( { userOverride } ) as DataTableColumnDef < XpEntry > ,
391368 defineColumn ( "totalXp" , {
392369 header : "xp gained" ,
393370 cell : ( info ) =>
0 commit comments