@@ -72,34 +72,13 @@ d.Node renderLikeButtonAndLabel(
7272 return d.div (
7373 classes: ['like-button-and-label' ],
7474 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),
9676 d.span (
9777 classes: ['like-button-and-label--count-wrapper' ],
9878 child: d.span (
9979 classes: ['like-button-and-label--count' ],
10080 text: _formatPackageLikes (likeCount),
10181 attributes: {
102- 'data-package' : package,
10382 'data-value' : likeCount.toString (),
10483 },
10584 ),
@@ -108,6 +87,31 @@ d.Node renderLikeButtonAndLabel(
10887 );
10988}
11089
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+
111115// keep in-sync with pkg/web_app/lib/src/likes.dart
112116String ? _formatPackageLikes (int ? likesCount) {
113117 if (likesCount == null ) return null ;
0 commit comments