Merge pull request #14098 from marcofaggian/microsite/feat/new-plugins
feat(microsite): added "new" ribbon to plugins
This commit is contained in:
@@ -16,11 +16,30 @@ 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')
|
||||
.execFileSync('git', [
|
||||
'log',
|
||||
'-1',
|
||||
'--format="%ai"',
|
||||
'--reverse',
|
||||
`./data/plugins/${file}`,
|
||||
])
|
||||
.toString();
|
||||
|
||||
metadata.date = new Date(gitIsoDate);
|
||||
|
||||
return metadata;
|
||||
})
|
||||
.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 +119,15 @@ const Plugins = () => (
|
||||
authorUrl,
|
||||
documentation,
|
||||
category,
|
||||
date,
|
||||
}) => (
|
||||
<div className="PluginCard">
|
||||
{Math.trunc((Date.now() - date) / (1000 * 60 * 60 * 24)) <
|
||||
newForDays && (
|
||||
<div className="ribbon ribbon-top-right">
|
||||
<span>NEW</span>
|
||||
</div>
|
||||
)}
|
||||
<div className="PluginCardHeader">
|
||||
<div className="PluginCardImage">
|
||||
<img src={iconUrl || defaultIconUrl} alt={title} />
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user