Skip to content

Commit

Permalink
chore(ejs): minor style fixes and update sections
Browse files Browse the repository at this point in the history
[skip ci]
  • Loading branch information
leomp12 committed Apr 3, 2020
1 parent db0f56c commit 49f0ab1
Show file tree
Hide file tree
Showing 7 changed files with 63 additions and 34 deletions.
Original file line number Diff line number Diff line change
@@ -1,29 +1,24 @@
<div class="collection-shelf my-lg-5">
<%
if (opt.collection_id) {
const res = await _.ecomClient.store({
url: `/collections/${opt.collection_id}.json`
})
const collection = res.data
let items = []
if (Array.isArray(collection.products) && collection.products.length) {
const search = new _.EcomSearch()
await search.setProductIds(collection.products).fetch()
items = search.getItems()
}
const { title, link } = opt
%>
<%- await include('/@/sections/inc/products-carousel', {
_, opt: { items, collection, title, link }
}) %>
<%
} else {
%>
<%- await include('/@/sections/inc/products-carousel', {
_, opt: { items: _.items }
}) %>
<%
<%
const { title, link, shuffle } = opt
let items, collection
if (opt.collection_id) {
const res = await _.ecomClient.store({
url: `/collections/${opt.collection_id}.json`
})
collection = res.data
items = []
if (Array.isArray(collection.products) && collection.products.length) {
const search = new _.EcomSearch()
await search.setProductIds(collection.products).fetch()
items = search.getItems()
}
%>
} else {
items = _.items
}
%>

<div class="collection-shelf my-lg-5">
<%- await include('/@/sections/inc/products-carousel', {
_, opt: { items, collection, title, link, shuffle }
}) %>
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<div class="custom-content">
<%- await include('/@/sections/inc/md-content') %>
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<% if (typeof opt.html === 'string') { %>
<section class="custom-html my-4 my-lg-5">
<div class="container">
<div class="html-clearfix">
<%- opt.html %>
</div>
</div>
</section>
<% } %>
Original file line number Diff line number Diff line change
@@ -1,7 +1,22 @@
<%
let dimensions
if (opt.img.startsWith('/')) {
try {
dimensions = _.imageSize(`template/public${opt.img}`)
} catch (e) {
dimensions = null
}
}
%>

<div class="banner">
<a href="<%= opt.link || 'javascript:;' %>">
<img
class="lozad fade img-fluid"
<% if (dimensions) { %>
data-width="<%= dimensions.width %>"
data-height="<%= dimensions.height %>"
<% } %>
data-src="<%= opt.img %>"
alt="<%= opt.alt %>"
>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
<%
if (_.state.body) {
%>
<% if (_.state.body) { %>
<section class="md-content mb-5 pt-1 pt-sm-2 pt-lg-3">
<div class="container">
<%- _.md.render(_.state.body) %>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,18 @@
<% if (Array.isArray(opt.items) && opt.items.length) { %>
<%
<% if (Array.isArray(opt.items) && opt.items.length) {
const title = opt.title ||
(opt.collection && opt.collection.name) ||
_.dictionary('popularProducts')
const link = opt.link || (opt.collection && opt.collection.slug)
if (opt.shuffle) {
let m = opt.items.length, t, i
while (m) {
i = Math.floor(Math.random() * m--)
t = opt.items[m]
opt.items[m] = opt.items[i]
opt.items[i] = t
}
}
%>
<section
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<section id="search" class="container">
<div id="search-engine">
<section id="search">
<div id="search-engine" class="container my-4 my-md-5">
<!--
No prerender for search, `SearchEngine` should be rendered here:
https://developers.e-com.plus/storefront/@ecomplus/storefront-components/docs/SearchEngine.html
Expand Down

0 comments on commit 49f0ab1

Please sign in to comment.