Skip to content

Commit 4199852

Browse files
authored
Use the same title attribute for both download count widget. (#9004)
1 parent 8ab0fa4 commit 4199852

File tree

7 files changed

+22
-10
lines changed

7 files changed

+22
-10
lines changed

app/lib/frontend/templates/_consts.dart

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ const myPackagesTabTitle = 'Packages';
1111
const myLikedPackagesTabTitle = 'Likes';
1212
const myActivityLogTabTitle = 'Activity log';
1313

14+
/// Text to display when the mouse pointer is hovering over the download count number.
15+
const titleFor30DaysDownloadCounts =
16+
'Number of downloads of this package during the past 30 days';
17+
1418
class SdkDict {
1519
final String topSdkPackages;
1620
final String searchPackagesLabel;

app/lib/frontend/templates/views/pkg/labeled_scores.dart

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import 'package:_pub_shared/format/number_format.dart';
66

77
import '../../../dom/dom.dart' as d;
8+
import '../../_consts.dart';
89

910
d.Node labeledScoresNode({
1011
required String package,
@@ -36,10 +37,7 @@ d.Node labeledScoresNode({
3637
child: _labeledScore('points', grantedPubPoints?.toString(), sign: ''),
3738
),
3839
d.div(
39-
attributes: {
40-
'title':
41-
'Number of downloads of this package during the past 30 days',
42-
},
40+
attributes: {'title': titleFor30DaysDownloadCounts},
4341
classes: ['packages-score', 'packages-score-downloads'],
4442
child: _labeledScore(
4543
'downloads',

app/lib/frontend/templates/views/pkg/score_tab.dart

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,15 @@ import 'dart:convert';
77
import 'package:_pub_shared/data/download_counts_data.dart';
88
import 'package:_pub_shared/format/number_format.dart';
99
import 'package:pana/models.dart';
10-
import 'package:pub_dev/frontend/dom/material.dart';
1110
import 'package:pub_dev/service/download_counts/backend.dart';
1211
import 'package:pub_dev/shared/utils.dart';
1312

1413
import '../../../../scorecard/models.dart' hide ReportStatus;
1514
import '../../../../shared/urls.dart' as urls;
1615
import '../../../dom/dom.dart' as d;
16+
import '../../../dom/material.dart';
1717
import '../../../static_files.dart';
18+
import '../../_consts.dart';
1819

1920
/// Renders the score page content.
2021
d.Node scoreTabNode({
@@ -337,14 +338,20 @@ d.Node _likeKeyFigureNode(int? likeCount) {
337338

338339
d.Node _downloadCountsKeyFigureNode(int? downloadCounts) {
339340
if (downloadCounts == null) {
340-
return _keyFigureNode(value: '--', supplemental: '', label: 'downloads');
341+
return _keyFigureNode(
342+
value: '--',
343+
supplemental: '',
344+
label: 'downloads',
345+
title: titleFor30DaysDownloadCounts,
346+
);
341347
}
342348
return _keyFigureNode(
343349
value:
344350
'${compactFormat(downloadCounts).value}'
345351
'${compactFormat(downloadCounts).suffix}',
346352
supplemental: '',
347353
label: 'downloads',
354+
title: titleFor30DaysDownloadCounts,
348355
);
349356
}
350357

@@ -373,10 +380,13 @@ d.Node _keyFigureNode({
373380
required String value,
374381
required String supplemental,
375382
required String label,
383+
String? title,
376384
List<String>? classes,
377385
}) {
386+
final attributes = title == null ? null : {'title': title};
378387
return d.div(
379388
classes: ['score-key-figure', ...?classes],
389+
attributes: attributes,
380390
children: [
381391
d.div(
382392
classes: ['score-key-figure-title'],

app/test/frontend/golden/pkg_score_page.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ <h3 class="detail-lead-title">Metadata</h3>
228228
</div>
229229
<div class="score-key-figure-label">pub points</div>
230230
</div>
231-
<div class="score-key-figure">
231+
<div class="score-key-figure" title="Number of downloads of this package during the past 30 days">
232232
<div class="score-key-figure-title">
233233
<span class="score-key-figure-value">--</span>
234234
<span class="score-key-figure-supplemental"></span>

app/test/frontend/golden/pkg_score_page_with_downloads_chart.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ <h3 class="detail-lead-title">Metadata</h3>
228228
</div>
229229
<div class="score-key-figure-label">pub points</div>
230230
</div>
231-
<div class="score-key-figure">
231+
<div class="score-key-figure" title="Number of downloads of this package during the past 30 days">
232232
<div class="score-key-figure-title">
233233
<span class="score-key-figure-value">--</span>
234234
<span class="score-key-figure-supplemental"></span>

app/test/task/testdata/goldens/packages/oxygen/score.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ <h3 class="detail-lead-title">Metadata</h3>
219219
</div>
220220
<div class="score-key-figure-label">pub points</div>
221221
</div>
222-
<div class="score-key-figure">
222+
<div class="score-key-figure" title="Number of downloads of this package during the past 30 days">
223223
<div class="score-key-figure-title">
224224
<span class="score-key-figure-value">--</span>
225225
<span class="score-key-figure-supplemental"></span>

app/test/task/testdata/goldens/packages/oxygen/versions/1.0.0/score.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ <h3 class="detail-lead-title">Metadata</h3>
223223
</div>
224224
<div class="score-key-figure-label">pub points</div>
225225
</div>
226-
<div class="score-key-figure">
226+
<div class="score-key-figure" title="Number of downloads of this package during the past 30 days">
227227
<div class="score-key-figure-title">
228228
<span class="score-key-figure-value">--</span>
229229
<span class="score-key-figure-supplemental"></span>

0 commit comments

Comments
 (0)