Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs(gh-pages): newsline section #1731

Merged
merged 21 commits into from
Jun 29, 2023
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
e0e3f51
docs(gh-pages): news section
fshovchko May 30, 2023
a89caa8
chore(gh-pages): news section refactoring
fshovchko Jun 19, 2023
0479359
chore(gh-pages): news section refactoring
fshovchko Jun 19, 2023
9d6b205
chore(gh-pages): news section refactoring
fshovchko Jun 19, 2023
8840f34
Merge branch 'main' into docs/news-section
fshovchko Jun 19, 2023
7b13f49
chore(gh-pages): news section refactoring
fshovchko Jun 23, 2023
6495d18
Merge branch 'docs/news-section' of https://github.com/exadel-inc/esl…
fshovchko Jun 23, 2023
fec20aa
chore(gh-pages): remove debug log
fshovchko Jun 23, 2023
561a184
chore(gh-pages): remove truncate method
fshovchko Jun 27, 2023
758994b
chore(gh-pages): news section refactoring
fshovchko Jun 27, 2023
406098f
chore(gh-pages): update date semantics
fshovchko Jun 28, 2023
d758413
chore(gh-pages): fix date formatter localization
ala-n Jun 28, 2023
cfe07d9
chore(gh-pages): fix indexing of the 11ty watch
ala-n Jun 28, 2023
00d8636
chore(gh-pages): rework the Newsline component
ala-n Jun 28, 2023
e355303
Merge branch 'main' of github.com:exadel-inc/esl into docs/news-section
ala-n Jun 28, 2023
6afbf9e
docs(gh-pages): "contribute to documentation" note
ala-n Jun 28, 2023
fe7a86d
chore(gh-pages): fix mobile version of newline component
ala-n Jun 28, 2023
15cb7f8
chore(gh-pages): fix filters to properly handle empty collections + a…
ala-n Jun 28, 2023
9180770
docs(gh-pages): replace content with a more realistic one
ala-n Jun 28, 2023
c8dbcb3
chore(gh-pages): simplify `createSortFilter` function
ala-n Jun 28, 2023
a0267e9
chore(gh-pages): small corrections for rendering utils
ala-n Jun 29, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions pages/11ty/date.filter.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module.exports = (config) => {
const date = (timestamp) => {
const date = new Date(timestamp);
return `${date.getDate()}-${date.getMonth() + 1}-${date.getFullYear()}`;
fshovchko marked this conversation as resolved.
Show resolved Hide resolved
};

config.addFilter('date', date);
};
34 changes: 34 additions & 0 deletions pages/11ty/markdown.shortcut.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,38 @@ class MDRenderer {
}
}

static async renderTruncate(content, maxLength = 250) {
fshovchko marked this conversation as resolved.
Show resolved Hide resolved
try {
const {body} = new JSDOM(content).window.document;

let limitReached = false;
let index = 0;

const nodeHandler = (node) => {
if (limitReached) {
node.remove();
return;
}

const childNodes = Array.from(node.childNodes);
if (childNodes.length) {
childNodes.forEach((childNode) => nodeHandler(childNode));
} else {
index += node.textContent.length;
if (index < maxLength) return;
limitReached = true;
node.textContent += `${node.textContent.slice(0, -(index - maxLength))}... `;
node.parentNode.insertAdjacentHTML('beforeend', `<p class="news-content-cta">Read more</p>`);
}
};

nodeHandler(body);
return MDRenderer.renderContent(body);
} catch (e) {
return `Rendering error: ${e}`;
}
}

/** Read file and render markdown */
static async parseFile(filePath) {
const absolutePath = path.resolve(__dirname, '../../', filePath);
Expand Down Expand Up @@ -74,6 +106,8 @@ class MDRenderer {
}

module.exports = (config) => {
console.log(config)
config.addNunjucksAsyncShortcode('mdRender', MDRenderer.render);
config.addNunjucksAsyncShortcode('mdRenderTruncate', MDRenderer.renderTruncate);
};
module.exports.MDRenderer = MDRenderer;
104 changes: 74 additions & 30 deletions pages/src/landing/blogs/blogs.less
Original file line number Diff line number Diff line change
@@ -1,50 +1,94 @@
@import (reference) "../../common/variables.less";

.blogs {
.newsline {
position: relative;
margin-bottom: 2rem;
margin: 5rem auto;

&-item {
display: flex;
flex: 1 0 0px;
align-items: center;
padding: 30px 45px;
list-style: none;
@media @sm-xl {
display: block;
}

&-content {
width: 100%;
padding: 10px 45px;
color: white;
background-size: 0% 100%;
transition: color .2s ease-in, background-size 1.5s, background-color 1.5s;

&::before {
content: '';
position: absolute;
top: 0;
left: 1px;
height: 100%;
border-left: 3px solid @nav-dark-fg;
transition: border-color .2s ease-in-out;
}
@media @sm {
min-width: 300px;
max-width: 350px;

&-cta {
display: inline-block;
color: @nav-dark-hover;
font-weight: bold;

opacity: 0;
transition: opacity .2s ease-in;
}
@media @md-lg {
min-width: 340px;
max-width: 500px;

&-date {
font-size: .7em;
}
@media @xl {
min-width: 400px;
max-width: 500px;

&-name {
padding-bottom: 5px;
font-size: 1.5rem;
}
}

&-container {
margin: 0 -45px;
padding-bottom: 35px;
&-text {
font-size: 1rem;

@media @sm-xl {
padding-bottom: 50px;
display: flex;
flex-wrap: wrap;
h1, .h1 {
font-size: 1.6rem;
}
h2, .h2 {
font-size: 1.4rem;
margin-bottom: 1rem;
}
h3, .h3 {
font-size: 1.3rem;
}
h4, .h4 {
font-size: 1.2rem;
}
h5, .h5 {
font-size: 1.1rem;
}
}
}

&-content-name {
margin-bottom: 20px;
font-size: 1.5rem;
}
&:hover {
color: @nav-dark-hover;
text-decoration: none;

background-color: rgba(@nav-dark-selected, .1);
background-image: linear-gradient(to right, #fff0 0%, #fff0 50%, #fff3 100%);
background-size: 200% 100%;
background-repeat: no-repeat;

&-content-text {
margin-bottom: 20px;
font-size: 1rem;
&::before {
border-color: @nav-dark-accent;
}

.newsline-content {
&-cta {
opacity: 1;
}

&-text {
color: @nav-dark-accent;
}
}
}
}
}
19 changes: 0 additions & 19 deletions pages/views/_includes/landing/blogs.njk

This file was deleted.

22 changes: 22 additions & 0 deletions pages/views/_includes/landing/newsline.njk
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{% set releasedNews = collections.news | released %}
{% if releasedNews.length %}
<div class="newsline container">
<h2>{{ landing.news.title }}</h2>
<esl-animate target="::next::child" group></esl-animate>
<ul class="newsline-container">
{% for item in releasedNews | reverse | limit(3) %}
<li class="esl-animate-slide-down newsline-item">
<a class="newsline-content" href="{{ item.data.link or (item.url | url) }}">
<h4 class="newsline-content-name">{{ item.data.emoji }}{{ item.data.name }}</h4>
{% if item.data.date %}
<p class="newsline-content-date">{{ item.date | date }}</p>
{% endif %}
<div class="newsline-content-text">
{% mdRenderTruncate item.templateContent %}
</div>
</a>
</li>
{% endfor %}
</ul>
</div>
{% endif %}
3 changes: 2 additions & 1 deletion pages/views/blogs/ESL v4.0.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
layout: content
name: ESL v4.0.0
title: ESL v4.0.0
tags: [blogs, draft]
tags: [blogs, news, draft]
date: 2022-10-01
emoji: ⚡️
containerCls: container markdown-container
---

Expand Down
7 changes: 4 additions & 3 deletions pages/views/index.11tydata.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,11 @@ landing:
Our UI component library doesn't introduce any additional restrictions — only benefits, as it offers
utilities and framework-agnostic web components that work with any tech stack.

blogs:
title: Articles
news:
title: Articles & Blogs
cta:
text: Read More
text: Read more

support:
title: Browser Support
text:
Expand Down
2 changes: 1 addition & 1 deletion pages/views/index.njk
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ layout: landing
{#{% include 'landing/overview.njk/'%}#}
{% include 'landing/browser-support.njk/'%}
{% include 'landing/promo-banner.njk/'%}
{% include 'landing/blogs.njk/'%}
{% include 'landing/newsline.njk/'%}