mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-06-16 05:30:11 +02:00
feat: buildCategoryLabel helper (for use in harmony theme)
This commit is contained in:
@@ -12,6 +12,7 @@ module.exports = function (utils, Benchpress, relative_path) {
|
||||
escape,
|
||||
stripTags,
|
||||
buildCategoryIcon,
|
||||
buildCategoryLabel,
|
||||
generateCategoryBackground,
|
||||
generateChildrenCategories,
|
||||
generateTopicClass,
|
||||
@@ -88,6 +89,17 @@ module.exports = function (utils, Benchpress, relative_path) {
|
||||
return `<span class="icon d-inline-flex justify-content-center align-items-center align-middle ${rounded}" style="${generateCategoryBackground(category)} width:${size}; height: ${size}; font-size: ${parseInt(size, 10) / 2}px;">${category.icon ? `<i class="fa fa-fw ${category.icon}"></i>` : ''}</span>`;
|
||||
}
|
||||
|
||||
function buildCategoryLabel(category) {
|
||||
if (!category) {
|
||||
return '';
|
||||
}
|
||||
|
||||
return `<span class="badge px-1" style="${generateCategoryBackground(category)}">
|
||||
${category.icon ? `<i class="fa fa-fw ${category.icon}"></i>` : ''}
|
||||
${category.name}
|
||||
</span>`;
|
||||
}
|
||||
|
||||
function generateCategoryBackground(category) {
|
||||
if (!category) {
|
||||
return '';
|
||||
|
||||
Reference in New Issue
Block a user