Vulcan/packages/vulcan-lib/lib/modules/icons.js

63 lines
1.5 KiB
JavaScript
Raw Normal View History

2018-06-17 08:00:19 +09:00
// TODO: get rid of this?
2016-11-26 11:17:01 +09:00
/*
Utilities for displaying icons.
*/
2016-12-12 11:34:28 +09:00
import { Utils } from './utils.js';
2016-08-08 11:18:21 +09:00
// ------------------------------ Dynamic Icons ------------------------------ //
2015-05-10 13:37:42 +09:00
/**
* @summary Take an icon name (such as "open") and return the HTML code to display the icon
2015-05-10 13:37:42 +09:00
* @param {string} iconName - the name of the icon
* @param {string} [iconClass] - an optional class to assign to the icon
*/
2016-12-12 11:34:28 +09:00
Utils.getIcon = function (iconName, iconClass) {
var icons = Utils.icons;
var iconCode = !!icons[iconName] ? icons[iconName] : iconName;
iconClass = (typeof iconClass === 'string') ? ' '+iconClass : '';
2015-08-21 10:20:48 +09:00
return '<i class="icon fa fa-fw fa-' + iconCode + ' icon-' + iconName + iconClass+ '" aria-hidden="true"></i>';
};
2015-05-10 13:37:42 +09:00
/**
* @summary A directory of icon keys and icon codes
2015-05-10 13:37:42 +09:00
*/
2016-12-12 11:34:28 +09:00
Utils.icons = {
2018-09-12 11:59:00 +09:00
expand: 'angle-right',
collapse: 'angle-down',
next: 'angle-right',
close: 'times',
upvote: 'chevron-up',
voted: 'check',
downvote: 'chevron-down',
facebook: 'facebook-square',
twitter: 'twitter',
googleplus: 'google-plus',
linkedin: 'linkedin-square',
comment: 'comment-o',
share: 'share-square-o',
more: 'ellipsis-h',
menu: 'bars',
subscribe: 'envelope-o',
delete: 'trash-o',
edit: 'pencil',
popularity: 'fire',
time: 'clock-o',
best: 'star',
search: 'search',
approve: 'check-circle-o',
reject: 'times-circle-o',
views: 'eye',
clicks: 'mouse-pointer',
score: 'line-chart',
reply: 'reply',
spinner: 'spinner',
new: 'plus',
user: 'user',
like: 'heart',
image: 'picture-o',
};