From ea7150ed4cea7be0354894a912b4b2cbde3f6ae2 Mon Sep 17 00:00:00 2001 From: marcofaggian Date: Tue, 11 Oct 2022 00:34:29 +0200 Subject: [PATCH] feat(microsite): added "new" ribbon to plugins Signed-off-by: marcofaggian --- microsite/pages/en/plugins.js | 22 +++++++++++++++++++++- microsite/static/css/plugins.css | 29 +++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+), 1 deletion(-) diff --git a/microsite/pages/en/plugins.js b/microsite/pages/en/plugins.js index de336444ab..3e7868cd30 100644 --- a/microsite/pages/en/plugins.js +++ b/microsite/pages/en/plugins.js @@ -16,11 +16,24 @@ const { const pluginsDirectory = require('path').join(process.cwd(), 'data/plugins'); const pluginMetadata = fs .readdirSync(pluginsDirectory) - .map(file => yaml.load(fs.readFileSync(`./data/plugins/${file}`, 'utf8'))) + .map(file => { + const fileContent = fs.readFileSync(`./data/plugins/${file}`, 'utf8'); + let metadata = yaml.load(fileContent); + + const gitIsoDate = require('child_process') + .execSync( + `git log -1 --format="%ai" --reverse ./data/plugins/${file} | cat -`, + ) + .toString(); + + return { ...metadata, date: new Date(gitIsoDate) }; + }) .sort((a, b) => a.title.toLowerCase().localeCompare(b.title.toLowerCase())); const truncate = text => text.length > 170 ? text.substr(0, 170) + '...' : text; +const newForDays = 100; + const addPluginDocsLink = '/docs/plugins/add-to-marketplace'; const defaultIconUrl = 'img/logo-gradient-on-dark.svg'; @@ -100,8 +113,15 @@ const Plugins = () => ( authorUrl, documentation, category, + date, }) => (
+ {Math.trunc((Date.now() - date) / (1000 * 60 * 60 * 24)) < + newForDays && ( +
+ NEW +
+ )}
{title} diff --git a/microsite/static/css/plugins.css b/microsite/static/css/plugins.css index b9aebfa84c..55a0c6df40 100644 --- a/microsite/static/css/plugins.css +++ b/microsite/static/css/plugins.css @@ -4,6 +4,7 @@ padding: 16px; display: flex; flex-direction: column; + position: relative; } .PluginGrid { @@ -141,3 +142,31 @@ #add-plugin-card { border: 1px solid #69ddc7; } + +/* RIBBON */ + +.ribbon { + width: 80px; + height: 80px; + overflow: hidden; + position: absolute; +} +.ribbon span { + position: absolute; + display: block; + width: 140px; + padding: 4px 0; + background-color: rgb(54, 186, 162, 0.85); + box-shadow: 0 5px 10px rgba(0, 0, 0, 0.1); + color: #fff; + text-align: center; +} +.ribbon-top-right { + top: 0; + right: 0; +} +.ribbon-top-right span { + left: -17px; + top: 11px; + transform: rotate(45deg); +}