Skip to content

Instantly share code, notes, and snippets.

@bbody
Created November 11, 2019 21:18
Show Gist options
  • Save bbody/edd58cdf424b184fd264d477c1fdcbeb to your computer and use it in GitHub Desktop.
Save bbody/edd58cdf424b184fd264d477c1fdcbeb to your computer and use it in GitHub Desktop.
'use strict';
/**
* @ngdoc directive
* @name portfolioApp.directive:socialMediaItem
* @description
* # socialMediaItem
*/
angular.module('portfolioApp')
.directive('socialMediaItem', function () {
return {
restrict: 'A',
scope: {
link: '@href',
network: '@socialMediaItem'
},
link: function ($scope) {
var key = $scope.network.replace(/ /g, '-').toLowerCase();
$scope.iconClass = 'fa fa-globe';
if (['bitbucket', 'github', 'twitter', 'stack-overflow', 'linkedin', 'hacker-news'].indexOf(key) >= 0){
$scope.iconClass = 'fab fa-' + key;
} else if (key === 'email'){
$scope.iconClass = 'fa fa-at';
}
},
template: '' +
'<a href="{{link}}" class="btn btn-default" alt="{{network}}">' +
' <i class="{{iconClass}}" aria-hidden="true"></i>' +
' <span class="sr-only">{{network}}{{\'\' | translate}}</span>' +
'</a>'
};
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment