@@ -72,34 +72,13 @@ d.Node renderLikeButtonAndLabel(
72
72
return d.div (
73
73
classes: ['like-button-and-label' ],
74
74
children: [
75
- material.iconButton (
76
- classes: ['like-button-and-label--button' ],
77
- isOn: isLiked,
78
- onIcon: d.Image (
79
- src: staticUrls.getAssetUrl ('/static/img/like-active.svg' ),
80
- alt: 'liked status: active' ,
81
- width: 18 ,
82
- height: 18 ,
83
- ),
84
- offIcon: d.Image (
85
- src: staticUrls.getAssetUrl ('/static/img/like-inactive.svg' ),
86
- alt: 'liked status: inactive' ,
87
- width: 18 ,
88
- height: 18 ,
89
- ),
90
- title: isLiked ? 'Unlike this package' : 'Like this package' ,
91
- attributes: {
92
- 'data-ga-click-event' : 'toggle-like' ,
93
- 'aria-pressed' : isLiked ? 'true' : 'false' ,
94
- },
95
- ),
75
+ _renderLikeButton (package, isLiked),
96
76
d.span (
97
77
classes: ['like-button-and-label--count-wrapper' ],
98
78
child: d.span (
99
79
classes: ['like-button-and-label--count' ],
100
80
text: _formatPackageLikes (likeCount),
101
81
attributes: {
102
- 'data-package' : package,
103
82
'data-value' : likeCount.toString (),
104
83
},
105
84
),
@@ -108,6 +87,31 @@ d.Node renderLikeButtonAndLabel(
108
87
);
109
88
}
110
89
90
+ d.Node _renderLikeButton (String package, bool isLiked) {
91
+ return material.iconButton (
92
+ classes: ['like-button-and-label--button' ],
93
+ isOn: isLiked,
94
+ onIcon: d.Image (
95
+ src: staticUrls.getAssetUrl ('/static/img/like-active.svg' ),
96
+ alt: 'liked status: active' ,
97
+ width: 18 ,
98
+ height: 18 ,
99
+ ),
100
+ offIcon: d.Image (
101
+ src: staticUrls.getAssetUrl ('/static/img/like-inactive.svg' ),
102
+ alt: 'liked status: inactive' ,
103
+ width: 18 ,
104
+ height: 18 ,
105
+ ),
106
+ title: isLiked ? 'Unlike this package' : 'Like this package' ,
107
+ attributes: {
108
+ 'data-ga-click-event' : 'toggle-like' ,
109
+ 'aria-pressed' : isLiked ? 'true' : 'false' ,
110
+ 'data-package' : package,
111
+ },
112
+ );
113
+ }
114
+
111
115
// keep in-sync with pkg/web_app/lib/src/likes.dart
112
116
String ? _formatPackageLikes (int ? likesCount) {
113
117
if (likesCount == null ) return null ;
0 commit comments