-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2540 from exadel-inc/tech/site-utils
refactor(site): introduce missing common utilities and enhancements from presentation branch
- Loading branch information
Showing
9 changed files
with
141 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
const findParent = (list, parent) => { | ||
if (!parent) return null; | ||
return list.find((item) => item.fileSlug === parent || item.data.id === parent || item.data.title === parent); | ||
}; | ||
|
||
/** Group items into a tree structure using given property */ | ||
function treeBuilder(items) { | ||
const root = []; | ||
items.forEach((item, index) => { | ||
item.children = []; | ||
item.data.index = index; | ||
}); | ||
items.forEach((item) => { | ||
const parent = findParent(items, item.data.parent); | ||
if (parent) { | ||
parent.children.push(item); | ||
} else { | ||
root.push(item); | ||
} | ||
}); | ||
return root; | ||
} | ||
|
||
module.exports = (config) => { | ||
config.addFilter('tree', treeBuilder); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
{% macro grid(collection, options = {}) %} | ||
<link href="https://fonts.googleapis.com/css2?family=Ubuntu:wght@500&display=swap" rel="stylesheet"> | ||
|
||
<ul class="collection-grid unstyled-list {{ 'collection-grid-column' if options.isList }} {{ options.classes or ''}}"> | ||
{% for item in collections[collection] | released | exclude('data.hidden') | sortBy('order', 'name') %} | ||
{% set badgeAllowed = not options.noBadge %} | ||
{% set isDraft = badgeAllowed and [].concat(item.data.tags).includes('draft') %} | ||
{% set isBeta = badgeAllowed and [].concat(item.data.tags).includes('beta') %} | ||
{% set isNew = badgeAllowed and [].concat(item.data.tags).includes('new') %} | ||
<li> | ||
<a class="collection-grid-item {{ 'draft' if isDraft }}" | ||
href="{{ item.url | url }}"> | ||
<div class="collection-grid-title collection-grid-box"> | ||
<span>{{ item.data.name }} | ||
{% if isBeta %} | ||
<sup class="badge badge-sup badge-warning">beta</sup> | ||
{% endif %} | ||
{% if isDraft %} | ||
<sup class="badge badge-sup badge-danger">draft</sup> | ||
{% endif %} | ||
{% if isNew %} | ||
<sup class="badge badge-sup badge-success">new</sup> | ||
{% endif %} | ||
</span> | ||
</div> | ||
<hr class="collection-grid-divider" /> | ||
<div class="collection-grid-box collection-grid-svg"> | ||
{% if item.data.icon %} | ||
{% include "static/assets/" + item.data.icon %} | ||
{% elseif options.isList %} | ||
<span class="arrows-icon right"></span> | ||
{% elseif item.data.iconAlt %} | ||
<div class="collection-grid-alt {{ 'collection-grid-alt-small' if item.data.iconAlt.length >= 20 }}"> | ||
{{ item.data.iconAlt }} | ||
</div> | ||
{% endif %} | ||
</div> | ||
</a> | ||
</li> | ||
{% endfor %} | ||
</ul> | ||
{% endmacro %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters