Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stats: use svg country flags instead of gravatar hosted flags. #11412

Merged
merged 2 commits into from
Feb 17, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion client/my-sites/stats/stats-list/stats-list-item.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ module.exports = React.createClass( {
}

if ( labelItem.icon ) {
avatar = ( <span className='icon'><img alt="" src={ labelItem.icon } width="20" height="20" className={ classNames( iconClassSetOptions ) } /></span> );
avatar = ( <span className='icon'><img alt="" src={ labelItem.icon } className={ classNames( iconClassSetOptions ) } /></span> );
}

icon = avatar;
Expand Down
14 changes: 10 additions & 4 deletions client/my-sites/stats/stats-list/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -190,12 +190,10 @@
}

.icon {
$icon-size: 24px;

position: relative;
display: inline-block;
width: $icon-size;
height: $icon-size;
width: 24px;
height: 24px;
overflow: hidden;
vertical-align: middle;
min-width: 24px;
Expand All @@ -205,6 +203,14 @@
display: block;
background: $white;
position: relative;
width: 20px;
height: 20px;

&.is-flag {
width: 24px;
height: 18px;
padding-top: 2px;
}
}

// Hide for user avatars
Expand Down
54 changes: 12 additions & 42 deletions client/state/stats/lists/test/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -524,7 +524,8 @@ describe( 'utils', () => {
label: 'United States',
value: 1,
region: '021',
icon: 'https://secure.gravatar.com/blavatar/9f4faa5ad0c723474f7a6d810172447c?s=48'
icon: '/calypso/images/flags/us.svg',
iconClassName: 'is-flag'
}
] );
} );
Expand Down Expand Up @@ -560,7 +561,8 @@ describe( 'utils', () => {
label: 'United States',
value: 10,
region: '021',
icon: 'https://secure.gravatar.com/blavatar/9f4faa5ad0c723474f7a6d810172447c?s=48'
icon: '/calypso/images/flags/us.svg',
iconClassName: 'is-flag'
}
] );
} );
Expand Down Expand Up @@ -595,7 +597,8 @@ describe( 'utils', () => {
label: 'United States',
value: 100,
region: '021',
icon: 'https://secure.gravatar.com/blavatar/9f4faa5ad0c723474f7a6d810172447c?s=48'
icon: '/calypso/images/flags/us.svg',
iconClassName: 'is-flag'
}
] );
} );
Expand Down Expand Up @@ -631,43 +634,8 @@ describe( 'utils', () => {
label: 'United States',
value: 100,
region: '021',
icon: 'https://secure.gravatar.com/blavatar/9f4faa5ad0c723474f7a6d810172447c?s=48'
}
] );
} );

it( 'should ignore missing grey flag icons', () => {
const parsedData = normalizers.statsCountryViews( {
date: '2015-12-25',
days: {
'2015-12-01': {
views: [ {
country_code: 'US',
views: 100
} ],
other_views: 0,
total_views: 100
}
},
'country-info': {
US: {
flag_icon: 'https://secure.gravatar.com/blavatar/5a83891a81b057fed56930a6aaaf7b3c?s=48',
flat_flag_icon: 'https://s-ssl.wordpress.com/i/stats/square-grey.png',
country_full: 'United States',
map_region: '021'
}
}
}, {
period: 'month',
date: '2015-12-25'
} );

expect( parsedData ).to.eql( [
{
label: 'United States',
value: 100,
region: '021',
icon: null
icon: '/calypso/images/flags/us.svg',
iconClassName: 'is-flag'
}
] );
} );
Expand Down Expand Up @@ -703,7 +671,8 @@ describe( 'utils', () => {
label: 'US\'A',
value: 100,
region: '021',
icon: null
icon: '/calypso/images/flags/us.svg',
iconClassName: 'is-flag'
}
] );
} );
Expand Down Expand Up @@ -742,7 +711,8 @@ describe( 'utils', () => {
label: 'United States',
value: 100,
region: '021',
icon: 'https://secure.gravatar.com/blavatar/9f4faa5ad0c723474f7a6d810172447c?s=48'
icon: '/calypso/images/flags/us.svg',
iconClassName: 'is-flag'
}
] );
} );
Expand Down
5 changes: 3 additions & 2 deletions client/state/stats/lists/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -227,14 +227,15 @@ export const normalizers = {

return map( countryData, ( viewData ) => {
const country = countryInfo[ viewData.country_code ];
const icon = country.flat_flag_icon.match( /grey\.png/ ) ? null : country.flat_flag_icon;
const icon = `/calypso/images/flags/${ viewData.country_code.toLowerCase() }.svg`;

// ’ in country names causes google's geo viz to break
return {
label: country.country_full.replace( /’/, "'" ),
value: viewData.views,
region: country.map_region,
icon: icon
icon: icon,
iconClassName: 'is-flag'
};
} );
},
Expand Down