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 20 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
6 changes: 6 additions & 0 deletions pages/11ty/date.filter.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
const date = (timestamp) =>
new Intl.DateTimeFormat('en-GB', { timeZone: 'UTC', month: 'long', day: '2-digit', year: 'numeric' }).format(new Date(timestamp));

module.exports = (config) => {
config.addFilter('date', date);
};
2 changes: 1 addition & 1 deletion pages/11ty/hidden.filter.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module.exports = (config) => {
/** Filter items by hidden marker */
const notHiddenFilter = (collection) => collection.filter( item => !item.data.hidden );
const notHiddenFilter = (collection) => (collection || []).filter( item => !item.data.hidden );

config.addFilter('notHidden', notHiddenFilter);
};
2 changes: 1 addition & 1 deletion pages/11ty/released.filter.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const {isDev} = require('./env.config');

const identical = (values) => values;
const draftsFilter = (values) => {
return values.filter((item) => {
return (values || []).filter((item) => {
const tags = [].concat(item.data.tags);
return !tags.includes('draft');
});
Expand Down
21 changes: 14 additions & 7 deletions pages/11ty/sort.filter.js
Original file line number Diff line number Diff line change
@@ -1,24 +1,31 @@
module.exports = (config) => {
/** Generic sort njk filter */
const sortFilter = (comparer) => (values) => {
if (!values || !Array.isArray(values)) {
const createSortFilter = (comparer) => (values) => {
if (!Array.isArray(values)) {
console.error(`Unexpected values for sort filter: ${values}`);
return values;
}
return [...values].sort(comparer);
};

// Utils
const resoleDate = (item) => new Date(item.date).getTime();
const resoleDateStrict = (item) => item.data.date ? new Date(item.date).getTime() : Number.POSITIVE_INFINITY;

/** Comparer composer */
const compose = (cmpA, cmpB) => (a, b) => cmpA(a, b) || cmpB(a, b);
const compose = (...cmps) => (a, b) => cmps.reduce((res, cmp) => res || cmp(a, b), 0);

/** Name metadata comparer */
const nameComparer = (a, b) => a.data.name.localeCompare(b.data.name);
/** Order metadata comparer */
const orderComparer = (a, b) => (a.data.order || 0) - (b.data.order || 0);
/** Date metadata comparer */
const dateComparer = (a, b) => new Date(b.date).getTime() - new Date(a.date).getTime();
const dateComparer = (a, b) => resoleDate(a) - resoleDate(b);
/** Date metadata comparer (will not use file creation date) */
const dateComparerStrict = (a, b) => resoleDateStrict(a) - resoleDateStrict(b);

config.addFilter('sortByName', sortFilter(nameComparer));
config.addFilter('sortByNameAndOrder', sortFilter(compose(orderComparer, nameComparer)));
config.addFilter('sortByDate', sortFilter(dateComparer));
config.addFilter('sortByName', createSortFilter(nameComparer));
config.addFilter('sortByNameAndOrder', createSortFilter(compose(orderComparer, nameComparer)));
config.addFilter('sortByDate', createSortFilter(dateComparer));
config.addFilter('sortByDateStrict', createSortFilter(dateComparerStrict));
};
50 changes: 0 additions & 50 deletions pages/src/landing/blogs/blogs.less

This file was deleted.

2 changes: 1 addition & 1 deletion pages/src/landing/landing.less
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
@import "./benefits/benefits.less";
@import "./browser-support/browser-support.less";
@import "./promo-banner/promo-banner.less";
@import "./blogs/blogs.less";
@import "./newsline/newsline.less";
//@import "./overview/overview.less";
101 changes: 101 additions & 0 deletions pages/src/landing/newsline/newsline.less
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
@import (reference) "../../common/variables.less";

.newsline {
position: relative;
margin: 0 auto 10rem;

&-list {
display: flex;
flex-direction: column;
}

&-item {
position: relative;
list-style: none;
}

&-link {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
z-index: 1;
}

&-content {
padding: 1.5rem 1rem 1.5rem 3rem;
@media @sm-xl {
padding: 1.5rem 5rem;
}

color: white;
border-left: 3px solid white;
transition: border-color .25s ease-in-out;

&::before {
content: '';
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-image: linear-gradient(to right, fade(@nav-dark-selected, 25%), fade(@nav-dark-selected, 0%));
pointer-events: none;
opacity: 0;
transition: opacity .25s ease-in-out;
}

& &-title {
font-size: 1.5rem;
margin-left: -1px;
margin-bottom: 1rem;
}
& &-emoji {
position: absolute;
transform: translateX(-100%);
margin-left: -.4rem;
@media @sm-xl {
margin-left: -.8rem;
}
}
& &-date {
display: block;
font-size: .85rem;
margin-top: .4rem;
opacity: .75;
}

& &-text {
font-size: 1rem;

a[href] {
position: relative;
z-index: 2;
}

// h1-h3 are not allowed in content of the newsline
h1, h2, h3 { display: none; }

h4, .h4 {
font-size: 1.2rem;
}
h5, .h5 {
font-size: 1.1rem;
}
p {
margin-bottom: .2rem;
}
}
}

&-item-highlighted &-content {
color: #fbf9a2;
border-color: #fbf9a2;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Proposition. Add this color to colors.less

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will be done separately with the final cleanup on the epic/redesign branch

}

&-item &-link:hover + &-content {
border-color: @nav-dark-accent;
&::before { opacity: 1; }
}
}
19 changes: 0 additions & 19 deletions pages/views/_includes/landing/blogs.njk

This file was deleted.

34 changes: 34 additions & 0 deletions pages/views/_includes/landing/newsline.njk
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{% set releasedNews = collections.news | released | sortByDateStrict | reverse %}
{% if releasedNews.length %}
<div class="newsline container">
<h2>{{ landing.news.title }}</h2>
<ul class="newsline-list">
{% for item in releasedNews | limit(3) %}
{% set isArticle = [].concat(item.data.tags).includes('blogs') %}
{% set isHighlighted = [].concat(item.data.tags).includes('highlight') %}

<li class="esl-animate-slide up newsline-item {{ 'newsline-item-highlighted' if isHighlighted }}"
esl-animate="{group: true}">
{% if item.data.link or isArticle %}
<a class="newsline-link"
aria-describedby="newsline-item-{{ loop.index }}"
href="{{ item.data.link or (item.url | url) }}"></a>
{% endif %}
<div id="newsline-item-{{ loop.index }}" class="newsline-content">
<h3 class="newsline-content-title"><span class="newsline-content-emoji" aria-hidden="true">{{ item.data.emoji }}</span>{{ item.data.title or item.data.name }}</h3>

{% if isArticle %}
<div class="newsline-content-text markdown-container">{{ item.templateContent | text | truncate(250) }}</div>
{% else %}
<div class="newsline-content-text markdown-container">{{ item.templateContent | safe }}</div>
{% endif %}

{% if item.data.date %}
<time class="newsline-content-date" datetime="{{ item.date.toISOString() }}">{{ item.date | date }}</time>
{% endif %}
</div>
</li>
{% endfor %}
</ul>
</div>
{% endif %}
2 changes: 1 addition & 1 deletion pages/views/_layouts/collection-grid.njk
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ layout: content
<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 list }}">
{% for item in collections[collection] | notHidden | released | sortByNameAndOrder %}
{% for item in collections[collection] | released | notHidden | sortByNameAndOrder %}
{% set isDraft = [].concat(item.data.tags).includes('draft') %}
{% set isBeta = [].concat(item.data.tags).includes('beta') %}
{% set isNew = [].concat(item.data.tags).includes('new') %}
Expand Down
9 changes: 9 additions & 0 deletions pages/views/blogs/Contribution Needed - Docs.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note for reviewers: that one is not a stub. So feel free to make notes regarding content

name: Documentation
title: Contribute to ESL documentation
tags: [highlight, news]
emoji: 💙
---

Found a typo? Have an interesting usage example to share? Want to help improve our documentation?
You are very welcome to contribute to ESL. Check out our [documentation contribution guide](../introduction/index.njk).
Loading