Skip to content

Commit 472405b

Browse files
committed
refactor row cell [percy]
Introduce a new `RowCell` component to encapsulate table cell rendering in the leaderboard entries table. This change improves readability and maintainability of the code by separating cell logic from the row structure, enabling reusability of the cell component. Update references in the row template to utilize the new `RowCell`, streamlining the overall layout and ensuring consistent styling across the leaderboard.
1 parent d06ccd5 commit 472405b

File tree

3 files changed

+34
-13
lines changed

3 files changed

+34
-13
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<td class="px-4 py-2 whitespace-nowrap border border-gray-200" ...attributes>
2+
{{yield}}
3+
</td>
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import Component from '@glimmer/component';
2+
3+
interface Signature {
4+
Element: HTMLTableCellElement;
5+
6+
Blocks: {
7+
default: [];
8+
};
9+
}
10+
11+
export default class RowCell extends Component<Signature> {}
12+
13+
declare module '@glint/environment-ember-loose/registry' {
14+
export default interface Registry {
15+
'LeaderboardPage::EntriesTable::RowCell': typeof RowCell;
16+
}
17+
}

app/components/leaderboard-page/entries-table/row.hbs

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
<tr class="{{if this.isCurrentUser 'bg-teal-50 ring ring-teal-500 relative' 'hover:bg-gray-50'}} group/table-row" data-test-leaderboard-entry-row>
2-
<td
3-
class="px-4 py-2 whitespace-nowrap text-xs font-medium
4-
{{if this.isCurrentUser 'text-teal-600' 'text-gray-400'}}
5-
text-right border border-gray-200 w-[8%]"
6-
>
7-
{{@rankText}}
8-
</td>
9-
<td class="px-4 py-2 whitespace-nowrap border border-gray-200">
2+
<LeaderboardPage::EntriesTable::RowCell class="text-right w-[8%]">
3+
<span class="text-xs font-medium {{if this.isCurrentUser 'text-teal-600' 'text-gray-400'}}">
4+
{{@rankText}}
5+
</span>
6+
</LeaderboardPage::EntriesTable::RowCell>
7+
8+
<LeaderboardPage::EntriesTable::RowCell>
109
<div class="flex items-center justify-between gap-x-6">
1110
<div class="flex items-center gap-1.5">
1211
<div class="flex-shrink-0 h-6 w-6">
@@ -35,16 +34,18 @@
3534
{{/each}}
3635
</div>
3736
</div>
38-
</td>
39-
<td class="px-4 py-2 whitespace-nowrap border border-gray-200 hidden md:table-cell">
37+
</LeaderboardPage::EntriesTable::RowCell>
38+
39+
<LeaderboardPage::EntriesTable::RowCell class="hidden md:table-cell">
4040
<div class="flex items-center justify-end">
4141
<div class="text-xs font-mono">
4242
<span class="{{if this.isCurrentUser 'text-teal-600' 'text-gray-700'}}">{{@entry.scoreUpdatesCount}}</span>
4343
<span class="{{if this.isCurrentUser 'text-teal-600' 'text-gray-400'}}">stages</span>
4444
</div>
4545
</div>
46-
</td>
47-
<td class="px-4 py-2 whitespace-nowrap border border-gray-200">
46+
</LeaderboardPage::EntriesTable::RowCell>
47+
48+
<LeaderboardPage::EntriesTable::RowCell>
4849
<div class="flex items-center justify-end">
4950
{{!-- {{#if (eq @entry.score 142)}}
5051
<span class="inline-block align-middle text-teal-500 triangle-up mr-1.5" aria-hidden="true">
@@ -63,5 +64,5 @@
6364
<span class="{{if this.isCurrentUser 'text-teal-600' 'text-gray-400'}}">pts</span>
6465
</div>
6566
</div>
66-
</td>
67+
</LeaderboardPage::EntriesTable::RowCell>
6768
</tr>

0 commit comments

Comments
 (0)