Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added XP table in rewards page #10568

Merged
merged 2 commits into from
Feb 18, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -109,16 +109,20 @@ const RewardsPage = () => {

<div className="rewards-tab-container">
<CWTabsRow>
{Object.values(TableType).map((type) => (
<CWTab
key={type}
label={type}
isSelected={tableTab === type}
onClick={() => {
setTableTab(type);
}}
/>
))}
{Object.values(TableType).map((type) =>
type === TableType.XPEarnings && !xpEnabled ? (
<></>
) : (
<CWTab
key={type}
label={type}
isSelected={tableTab === type}
onClick={() => {
setTableTab(type);
}}
/>
),
)}
</CWTabsRow>
</div>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
gap: 8px;
width: 100%;

>.CWSelectList>.SelectList {
> .CWSelectList > .SelectList {
padding: 4px 8px !important;
line-height: initial;
min-height: initial;
Expand Down Expand Up @@ -39,4 +39,4 @@
border-bottom: 1px solid $neutral-50;
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
@import '../../../../../../styles/shared';

.XPTable {
.table-header {
display: flex;
gap: 4px;
justify-content: center;
align-items: center;
}

tr {
td,
th {
&:first-of-type {
width: 80px;
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
import { APIOrderDirection } from 'helpers/constants';
import React from 'react';
import { CWIcon } from 'views/components/component_kit/cw_icons/cw_icon';
import { CWText } from 'views/components/component_kit/cw_text';
import { CWTable } from 'views/components/component_kit/new_designs/CWTable';
import { CWTableColumnInfo } from 'views/components/component_kit/new_designs/CWTable/CWTable';
import { useCWTableState } from 'views/components/component_kit/new_designs/CWTable/useCWTableState';
import './XPTable.scss';

const columns: CWTableColumnInfo[] = [
{
key: 'rank',
header: 'Rank',
numeric: false,
sortable: true,
},
{
key: 'username',
header: 'Username',
numeric: false,
sortable: true,
},
{
key: 'xp',
header: () => (
<CWText className="table-header">
<CWIcon iconName="help" iconSize="regular" /> XP
</CWText>
),
numeric: true,
sortable: true,
},
];

const sampleData = [
{
rank: 1,
username: 'Commoner.eth',
xp: 126,
},
{
rank: 2,
username: 'Commoner.eth',
xp: 125,
},
{
rank: 3,
username: 'Commoner.eth',
xp: 124,
},
{
rank: 4,
username: 'Commoner.eth',
xp: 123,
},
{
rank: 5,
username: 'Commoner.eth',
xp: 122,
},
{
rank: 6,
username: 'Commoner.eth',
xp: 121,
},
{
rank: 7,
username: 'Commoner.eth',
xp: 120,
},
{
rank: 8,
username: 'Commoner.eth',
xp: 119,
},
];

const XPTable = () => {
const tableState = useCWTableState({
columns,
initialSortColumn: 'rank',
initialSortDirection: APIOrderDirection.Asc,
});

return (
<section className="XPTable">
<CWTable
columnInfo={tableState.columns}
sortingState={tableState.sorting}
setSortingState={tableState.setSorting}
rowData={sampleData}
/>
</section>
);
};

export default XPTable;
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import XPTable from './XPTable';

export default XPTable;
Loading