Skip to content

Commit

Permalink
Simplify dashboard widget
Browse files Browse the repository at this point in the history
  • Loading branch information
aristath committed Nov 11, 2024
1 parent 0efd9f4 commit b264738
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 25 deletions.
4 changes: 4 additions & 0 deletions assets/css/dashboard-widgets/score.css
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
grid-gap: calc(var(--prpl-gap) / 2);
}

.prpl-gauge-number {
font-size: var(--prpl-font-size-4xl);
}

h3 {
font-weight: 500;
}
Expand Down
38 changes: 13 additions & 25 deletions views/dashboard-widgets/score.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,31 +16,19 @@
<?php \progress_planner()->get_widgets__activity_scores()->print_score_gauge(); ?>
</div>
<?php
foreach ( [ 'monthly', 'content', 'maintenance' ] as $prpl_category ) {
if ( 'monthly' !== $prpl_category && 100 <= (int) \progress_planner()->get_admin__dashboard_widget_score()->get_badge_details( $prpl_category )['progress']['progress'] ) {
continue;
}

$prpl_widget = \progress_planner()->get_admin__page()->get_widget( 'badge-streak' );
$prpl_gauge_details = [
'value' => 'monthly' === $prpl_category
? \progress_planner()->get_admin__page()->get_widget( 'suggested-tasks' )->get_score() / \Progress_Planner\Badges\Monthly::TARGET_POINTS
: $prpl_widget->get_details( $prpl_category )->get_progress()['progress'] / 100,
'max' => 'monthly' === $prpl_category ? \Progress_Planner\Badges\Monthly::TARGET_POINTS : 100,
'background' => 'monthly' === $prpl_category
? 'var(--prpl-background-orange)'
: $prpl_widget->get_details( $prpl_category )->get_background(),
'color' => 'monthly' === $prpl_category
? 'var(--prpl-color-accent-orange)'
: 'var(--prpl-color-accent-orange)',
'badge' => 'monthly' === $prpl_category
? \progress_planner()->get_badges()->get_badge( 'monthly-' . gmdate( 'Y' ) . '-m' . (int) gmdate( 'm' ) )
: $prpl_widget->get_details( $prpl_category ),
'badge_completed' => true,
];

\progress_planner()->the_view( 'page-widgets/parts/gauge.php', [ 'prpl_gauge_details' => $prpl_gauge_details ] );
}
\progress_planner()->the_view(
'page-widgets/parts/gauge.php',
[
'prpl_gauge_details' => [
'value' => \progress_planner()->get_admin__page()->get_widget( 'suggested-tasks' )->get_score() / \Progress_Planner\Badges\Monthly::TARGET_POINTS,
'max' => \Progress_Planner\Badges\Monthly::TARGET_POINTS,
'background' => 'var(--prpl-background-orange)',
'color' => 'var(--prpl-color-accent-orange)',
'badge' => \progress_planner()->get_badges()->get_badge( 'monthly-' . gmdate( 'Y' ) . '-m' . (int) gmdate( 'm' ) ),
'badge_completed' => true,
],
]
);
?>
</div>

Expand Down

0 comments on commit b264738

Please sign in to comment.