Skip to content

Commit

Permalink
Merge pull request #11780 from bdach/daily-challenge-completion-marker
Browse files Browse the repository at this point in the history
Add completion marker to daily challenge profile counter
  • Loading branch information
nanaya authored Jan 16, 2025
2 parents f7d0f0b + 3c70a3c commit d9f4860
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 3 deletions.
26 changes: 24 additions & 2 deletions resources/css/bem/daily-challenge.less
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,31 @@
background: hsl(var(--hsl-b4));
border-radius: @border-radius-large;
min-width: 0;
position: relative;
display: flex;
align-items: center;
padding: 3px;
padding: 1px;
border: 2px solid transparent;

&--played-today {
border-color: @osu-colour-lime-1;

&::before {
.fas();
.center-content();
background-color: @osu-colour-lime-1;
border-radius: 50%;
color: @osu-colour-b6;
content: @fa-var-check;
font-size: 8px; // icon size
height: 16px;
position: absolute;
right: 0;
top: 0;
transform: translate(50%, -50%);
width: $height;
}
}

&__name {
font-size: @font-size--normal;
Expand All @@ -20,7 +42,7 @@
}

&__value-box {
border-radius: @border-radius-large;
border-radius: @border-radius-small;
background: hsl(var(--hsl-b6));
padding: 5px 10px;
}
Expand Down
7 changes: 6 additions & 1 deletion resources/js/profile-page/daily-challenge.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
import DailyChallengeUserStatsJson from 'interfaces/daily-challenge-user-stats-json';
import { autorun } from 'mobx';
import { observer } from 'mobx-react';
import * as moment from 'moment';
import core from 'osu-core-singleton';
import * as React from 'react';
import { renderToStaticMarkup } from 'react-dom/server';
import { classWithModifiers, Modifiers } from 'utils/css';
Expand Down Expand Up @@ -122,10 +124,13 @@ export default class DailyChallenge extends React.Component<Props> {
return null;
}

const playedToday = this.props.stats.last_update !== null && moment.utc(this.props.stats.last_update).isSame(Date.now(), 'day');
const userIsOnOwnProfile = this.props.stats.user_id === core.currentUser?.id;

return (
<div
ref={this.valueRef}
className='daily-challenge'
className={classWithModifiers('daily-challenge', { 'played-today': playedToday && userIsOnOwnProfile })}
onMouseOver={this.onMouseOver}
>
<div className='daily-challenge__name'>
Expand Down

0 comments on commit d9f4860

Please sign in to comment.