forked from cvat-ai/cvat
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
105 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
102 changes: 100 additions & 2 deletions
102
cvat-ui/src/components/gamification/badges/badge-overview.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,108 @@ | ||
// Copyright (C) 2022 Intel Corporation | ||
// | ||
// SPDX-License-Identifier: MIT | ||
import '../gamif-styles.scss'; | ||
import React from 'react'; | ||
import { BadgeIcon, BadgeGreyIcon } from 'icons'; | ||
import { | ||
Row, | ||
Col, | ||
Progress, | ||
Button, | ||
Tabs, | ||
} from 'antd'; | ||
|
||
type Badge = { | ||
title: string; | ||
instruction: string; | ||
progress: number; | ||
goal: number; | ||
goalunit: string; | ||
got: boolean; | ||
}; | ||
|
||
interface Props { | ||
// visible: boolean; | ||
allBadges: Badge[]; | ||
currentBadge?: Badge; | ||
} | ||
|
||
const showBadges = (badges: Badge[]): JSX.Element => ( | ||
<Row> | ||
{badges.map((badge: Badge) => ( | ||
<Col span={4}> | ||
<Button | ||
icon={badge.got ? <BadgeIcon /> : <BadgeGreyIcon />} | ||
onClick={(): void => { | ||
// TODO: Change selectedBadge through reducer | ||
}} | ||
/> | ||
</Col> | ||
))} | ||
</Row> | ||
); | ||
|
||
const showSelectedBadge = (badge: Badge): JSX.Element => ( | ||
<> | ||
<div className='gamif-badge-icon'> | ||
{badge.got ? <BadgeIcon /> : <BadgeGreyIcon />} | ||
</div> | ||
<div className='gamif-badge-details'> | ||
<strong>{badge.title}</strong> | ||
{badge.instruction} | ||
<Progress percent={badge.progress / badge.goal} /> | ||
{`Current Progress: ${badge.progress} / ${badge.goal} ${badge.goalunit}`} | ||
</div> | ||
</> | ||
); | ||
|
||
export default function BadgeOverview(props: Props): JSX.Element { | ||
let { allBadges, currentBadge } = props; | ||
const badge1: Badge = { | ||
title: 'Badge 1', | ||
instruction: 'Annotate 5 livers', | ||
progress: 5, | ||
goal: 5, | ||
goalunit: 'Livers', | ||
got: true, | ||
}; | ||
const badge2: Badge = { | ||
title: 'Badge 2', | ||
instruction: 'Annotate ten images', | ||
progress: 1, | ||
goal: 10, | ||
goalunit: 'Images', | ||
got: false, | ||
}; | ||
|
||
allBadges = [badge1, badge2]; | ||
currentBadge = badge1; | ||
|
||
export default function BadgeOverview(): JSX.Element { | ||
return ( | ||
<>Badge Overview</> | ||
<Tabs type='card' defaultActiveKey='1' className='badge-overview-tabs'> | ||
<Tabs.TabPane tab='Permanent Badges' key='1'> | ||
<div className='gamif-badge-overview-container'> | ||
<div className='gamif-badge-overview-header' /> | ||
<div className='gamif-badge-overview-content'> | ||
{showBadges(allBadges)} | ||
</div> | ||
<div className='gamif-badge-detail-view'> | ||
{showSelectedBadge(currentBadge)} | ||
</div> | ||
</div> | ||
</Tabs.TabPane> | ||
{ /* TODO: Refactor */} | ||
<Tabs.TabPane tab='Seasonal Badges' key='2'> | ||
<div className='gamif-badge-overview-container'> | ||
<div className='gamif-badge-overview-header' /> | ||
<div className='gamif-badge-overview-content'> | ||
{showBadges(allBadges)} | ||
</div> | ||
<div className='gamif-badge-detail-view'> | ||
{showSelectedBadge(currentBadge)} | ||
</div> | ||
</div> | ||
</Tabs.TabPane> | ||
</Tabs> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters